I am new to NT and coding but have made significant strides thanks to the forums. This will be the first post I have made on any forum so I will be as clear as possible.
I am unable to find a solution to this set-up:
For a long only strategy, one condition requires all entries to occur above 200 SMA.
One exit condition writes,
if(CountIf (delegate {return SMA(200)[0] < Close [0];}, 100) < 99)
ExitLongStop(SMA(90)[0], "", "");
An open trade can be closed when price crosses below 90 SMA. My problem now is that it is possible for another trade to open on the next bar with the countif condition met and the 90 SMA still above price. My trades are being closed next day because the price was above the 200 SMA for 100 days but is entered below the 90 SMA.
I need to create an additional ExitLongStop condition and as a newbie I came up:
if(CountIf (delegate {return SMA(200)[0] < Close [0];}, 100) < 99
&& (BarsSinceEntry() > 0)
&& (Position.AvgPrice < SMA(90)[BarsSinceEntry]))
BarsSinceEntry is not accepted here; it is unfortunately the only idea I had to update how many days to go back and find the SMA value from the entry bar.
How can I recall the value of the 90 SMA on the entry bar for this condition? Thanks.
Comment