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):


UDP Export

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);

If 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]);

Read also:


Trusted Management

Moon Bot version 3.74 has got tools helping to use the bot for trusted management. How it works: when you trade with your bot…

September 13th Discount

Dear users! Celebrating Programmer’s Day, on Friday September 13th we are announcing a huge discount on the PRO version of MoonBot! You will get…

Connecting to Binance servers

By default, the bot uses the original connection method, optimal in most cases. Depending on your region, your ISP and network configuration the bot…

MoonBot for Binance

The main nuance when working with the Binance exchange by API is the limits for operations per minute. When the limits are exceeded, the…

MoonTrader ICO

Dear Users! Our team intends to implement a large-scale project aimed to transform MoonBot into a professional trading terminal MoonTrader and a system of…

Pump Helper tool

Release 3.43 brings new feature – the “Pump Helper” tool. Use it to play pumps where the coin is given in a picture (so…