Hi I have a little problem if anyone can help me!
I would like to know how to code an exit from a trade based on a new lower low in the current trade.
For an ex then latest bar is lower than the last 30 bars then sell position
// Breakout strategy with new Higher high for go long and new lower low for go short
highh = highest[50](high) // when the price is higher than the last 50 bars i want to go long
lowl = lowest[30](low) // When the price is lower than the last 30 bars want to exit my long trade
Size = 1 //position size
Condlong = highh > close
Condexitlong = barindex-tradeindex(1)<=lowl // " Here is something wrong i can´t figure out how to get it right for exit ??? "
Condshort= lowl < close
IF not onmarket and condlong THEN
buy size shares at market
endif
IF longonmarket and condexitlong THEN
sell size shares at market
endif
//
Best Regards! =)
Pellejons – Welcome to the forums. Your post has been edited as you did not follow the forum rules regarding using the ‘Insert PRT Code’ button:
- Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Change line 8 to:
Condexitlong = low = lowl