Environment.IsAutoTradingMode problem  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Environment.IsAutoTradingMode problem

Postby darob » 30 Nov 2018

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

darob
Posts: 207
Joined: 20 Nov 2014
Has thanked: 57 times
Been thanked: 32 times

Re: Environment.IsAutoTradingMode problem  [SOLVED]

Postby darob » 04 Dec 2018

I initially had this on the same script that sent the orders and that appears to have been the problem. Now I have it as a separate strategy and it's working.


Return to “MultiCharts .NET”