How to read messages in FXTS2

To read messages in FXTS2 you need to get a key and modify your strategy or indicator.

Step 1. Install Notification Library

Run ProfitRobots Installer, select your FXTS2, select Notification Library in the list of products and click install.

Step 2. Add key parameter

The messages requested from our server by the key (someone should send these messages using the same key). You can hardcode it or add a parameter into the Init function

function Init()
    -- ...
    strategy.parameters:addString("key", "Key", "", "");

Step 3. Load AdvancedNotifications

This library connects to the server and loads messages from the server. You can receive these messages later on by calling a special function from that library. You can load it by inserting require call into your Prepare function. Also, you need to check for new messages from time to time. We do recommend to use a timer for that.

local TIMER_ID = 1;
local started = false;
function Prepare(name_only)
    -- ..."setTimer", TIMER_ID, 1);
    -- ...

Step 4. Connect and receive messages

We will connect and receive messages by timer in this example. You need to call AdvancedNotifications.StartListener(key, 0) to establish a connection with the server. The first parameter is a key and the second is a reserved parameter for future use. Always use 0.

You can get a message by calling AdvancedNotifications.GetNextMessage(). It'll return an empty string if there are no new messages.

function ExtAsyncOperationFinished(cookie, success, message, message1, message2)
    if cookie == TIMER_ID then
        if not started then
            local res = AdvancedNotifications.StartListener(instance.parameters.key, 0);
            started = true;
        local message = AdvancedNotifications.GetNextMessage();
        while message ~= "" do
  "We have a new message!!! " .. message);
            message = AdvancedNotifications.GetNextMessage();

Step 5. Disconnect from the server

You need to disconned from the server before strategy/indicator destroy. Add AdvancedNotifications.StopListener() call in the ReleaseInstance function.

function ReleaseInstance() 
    if started then