I have a line that sends telegram message when an order is executed.
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (State == State.Realtime)
{
SendMessage(execution.Order.Name + " @"+price.ToString()+ "\r\n" + Time[0]);
}
}
I want to prevent it to send every msg when backtesting. I just want to get msg when I run this strategy in realtime trades.
That's why I put the line (State == State.Realtime) but apparently it doesn't work.
How can I distinguish the strategy's state b/w backtesting and real-time so that I can put logic differently by the state?

Comment