Hello, could you please help me with this exit strategy? It’s not generating any exits for me. I want to exit on a close above the three-day High from entry. Here is the full code. Thank you.
// definice
atr5 = AverageTrueRange[5]
indicatorValue = (highestHigh - close) / atr5
// Logika
IF indicatorValue CROSSES OVER 2 AND onmarket = 0 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// exit rules
IF longonmarket THEN
highestexit = Highest[3]
IF close > highestexit THEN
SELL AT MARKET
ENDIF
ENDIF
Hi,
In your exit rule the condition IF close > highestexit THEN will never happen.
Iǜe defined the highestHigh as HHV3 = highest[3](high) because it was not defined.
This should do more or less what you want.
// definice
HHV3 = highest[3](high)
atr5 = AverageTrueRange[5]
indicatorValue = (HHV3 - close) / atr5
// Logika
IF indicatorValue CROSSES OVER 2 AND onmarket = 0 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// exit rules
IF longonmarket and close > HHV3[1] THEN
SELL AT MARKET
ENDIF
graphonprice HHV3 coloured("red")
graph indicatorvalue coloured("red")
graph 2 coloured("blue")
Hi,
Yes that’s it, thanks so much for the help!