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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 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