I have created a code and one of the conditions is that it enters a position when the ADX exceeds the 45 level. During backtesting it works great, but when live testing it doesn't. Please find below my code and attached screenshot of the trades the strategy took live. I have marked the short entries in red and the longs in green. My CalculateOnBarClose() is set to true.
if (ADX(MyADX)[0] > 45
&& ATR(MyATR)[0] < MyATRLevel
&& CrossBelow(RSI(MyRSI, 1).Avg, MyLowerLevel, 1)
&& Position.MarketPosition == MarketPosition.Flat)
{
Print(MyATRLevel);
MyPositionSize = (int) (myRiskAmount / 0.002);
EnterLong(MyPositionSize, "Enter long"); // Enter long
}
Thanks.
Comment