I have an alert in an autotrading signal that should fire only when autotrading is on, there is no open position and conditions no longer support taking a position. But when I use Environment.IsAutoTradingMode in my code the alert doesn’t fire at all, ever. When I remove it, the alert fires regardless of whether autotrading is on or not.
Can anyone suggest what I’m overlooking? Environment.IsAutoTradingMode occurs for the first and only time in CalcBar(). Does it have to be declared earlier? Many thanks.
Code: Select all
if (Environment.IsAutoTradingMode && StrategyInfo.MarketPositionAtBroker == 0
&& *a couple more conditions*){
Alerts.Alert("Cancel AT");