Skip to content

Plugin.RefreshData

method · Plugin · cAlgo.API

DesktopCLICloud

Updates Bars, Positions, PendingOrders, History, etc. And sends postponed events after Thread sleep call. If you put the main thread on sleep by calling Thread sleep method then you have to call RefreshData after Thread wakes up to send the postponed events while thread was sleeping.

Environment behaviour

CLI — not supported. Plugins cannot run in the CLI: ctrader-cli runs cBots only.

Cloud — not supported. Plugins cannot run in the cloud: it runs cBots only.

Definition

public void RefreshData()
api.RefreshData() -> None

Examples

var operation = ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000);
while (operation.IsExecuting)
{
    Sleep(100);
    // Without RefreshData the trade result and events are not delivered while waiting
    RefreshData();
}
Print("Order executed: {0}", operation.TradeResult.IsSuccessful);
operation = api.ExecuteMarketOrderAsync(TradeType.Buy, "EURUSD", 10000)
while operation.IsExecuting:
    api.Sleep(100)
    # Without RefreshData the trade result and events are not delivered while waiting
    api.RefreshData()
api.Print(f"Order executed: {operation.TradeResult.IsSuccessful}")