LeoParticipant
Veteran
WOW !
Now I noticed that your will never work beacuse a moving avearage never intersect a previous highest high!
how would you rewrite my code in post 1, to make it actually trade if the close[0] > highest high in past 20 candles?
Here’s your code
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
DEFPARAM preloadbars=100
// Conditions to enter long positions
buy1 = highest[20](high)
sell1 = lowest[20](low)
buysignal = buy1[1] < close
sellsignal = sell1[1] > close
if buysignal then
buy 1 contract at market
elsif sellsignal then
sellshort 1 contract at market
endif
if longonmarket and Close < Close[2] then
sell at market
endif
IF shortonmarket and Close> Close[2] then
exitshort at market
endif
@Leo, thanks, makes much more sense now. Im not pushing anything out in live hehe just trying to understand 🙂