UDP Export

The bot can export market data: 5-minutes candles and trades for all active markets (BTC, USDT or ETH) to the local UDP port (IP

The bot can also accept signals sent to UDP port.

This function is currently in beta testing.

To turn it on go to the Settings -> Advanced tab, put the checkbox “UDP Export”

The bot is sending market data in binary format, as arrays of count elements in each UDP packet (look format below) to the UDP port 2000. Use buffer size=65000. Candles are sent as whole array (up to 500 elements) once in 5 minutes. Trades are only new since last update but note that 1 data packet may contain more then 1 trade.

The bot is listening for signals on UDP port 1999, signals should be sent in plain text format. Received signals are handled in the bot buy special “UDP” strategy: (Dont forget to turn on Settings -> Advanced -> “UDP Export” checkbox):

Signal example: ‘Key=Test1 Coin=NEO Order=buy BuyPrice=0.0071’.


  • Key= the keyword by which the bot picks one of UDP strategies. The key must match the strategy “ChannelKey” property, in the example above its “Test1”.
  • Coin= the coin to buy
  • Order=
  • buy – buy order
  • sell – activate Panic Sell on coin bought by any strategy
  • BuyPrice= limit buy order price. If ommited then the strategy settings will be used.

Code example: (download source with small compiled demo)

// structures

 TOrderType = (O_SELL,O_BUY,O_BuyStop);

TUpdateKind = (UK_Candles, UK_Trades);

TUpdateHeader = packed record

Version:         byte;        // 1 byte – packet version, currently 1

TimeStamp:       dword;       // 4 bytes – Unix timestamp

Kind:            TUpdateKind; // 1 byte – candles (0) or trades (1) inside

Coin:            string[7];   // 7 bytes – coin ticker name

Count:           word;        // 2 bytes – elements count in the data array

reserved1:       dword;       // 4 bytes currently unused

reserved2:       dword;        // 4 bytes currently unused


TTradeOrder = record  // 8-bytes aligned

ID:                      integer;

Time:                    TDateTime;

Price:                   double;

Quantity:                double;

BuyerID:                 integer;

reserved:                integer;

OrderType:               TOrderType;

FillType:                byte; // 0 – PARTIAL, 1 – FULL


TCandle = record

OpenP,CloseP,MaxP,MinP:  double;

Vol:                     double;

Time:                    TDateTime;


TTrades = array of TTradeOrder;

TCandles = array of TCandle;

// Data reading and handling

procedure TfrmUDPTest.IdUDPServer1UDPRead(AThread: TIdUDPListenerThread;

const AData: TIdBytes; ABinding: TIdSocketHandle);


hdr:       TUpdateHeader;

Trades:    TTrades;

Candles:   TCandles;


move(AData[0], hdr, SizeOf(hdr));

If hdr.Kind = UK_Trades then begin

SetLength(Trades, hdr.Count);

move(AData[SizeOf(hdr)], Trades[0], hdr.Count * SizeOf(TTradeOrder));

If SelectedCoin = hdr.Coin

then lPrice.Caption:=hdr.Coin + ‘ Last: ‘ + FloatToStr(Trades[hdr.Count – 1].Price);


f hdr.Kind = UK_Candles then begin

SetLength(Candles, hdr.Count);

move(AData[SizeOf(hdr)], Candles[0], hdr.Count * SizeOf(TCandle));

lLastCandle.Caption:=’ Last candle: ‘ + hdr.Coin + ‘ 5m vol: ‘ + FloatToStr(Candles[hdr.Count – 1].Vol);


lLastTrade.Caption:=Format(‘Last update: %s time: %d’, [hdr.Coin, hdr.TimeStamp]);