Sto cercando di settare il codice per fare in modo che
il DAX
dopo l’apertura delle ore 9.00 ed entro le 9.30
una volta che il range (differenza minimo massimo in corso) sia di 24 punti
entri
in acquisto sul minimo del range
oppure
in vendita sul massimo del range
e che poi non inserisca altri ordini
il problema è che invece nel backtest
l’entrata risulta sempre sul minimo o massimo della candela
e non del range che considero, qualsiasi timeframe
posto il codice che ho scritto
come faccio a correggerlo ? finora non mi sono stati di aiuto i post che mi sembravano trattare la stessa impostazione
grazie
defparam cumulateorders=false
IF time >= 090000 AND time =< 093000 and HIGH - LOW = 24 * pipsize AND close = low THEN
BUY 1 CONTRACT LIMIT
ELSIF time >= 090000 AND time =< 093000 AND HIGH - LOW = 24 * pipsize AND close = high THEN
SELLSHORT 1 CONTRACT LIMIT
ENDIF
Eccolo:
defparam cumulateorders=false
IF IntraDayBarIndex = 0 THEN
HH = 0
LL = 0
ENDIF
OTD = Barindex - TradeIndex(1) > IntradayBarIndex //Una sola operazione al giorno (One Trade per Day)
IF time >= 090000 AND time =< 093000 and OTD THEN
IF LL = 0 THEN
LL = low
ENDIF
HH = max(HH,high)
LL = min(LL,low)
myRange = HH - LL
IF close > LL and myRange >= 24 THEN
BUY 1 CONTRACT AT LL LIMIT
ELSIF close < HH and myRange >= 24 THEN
SELLSHORT 1 CONTRACT at HH LIMIT
ENDIF
SET TARGET PROFIT myRange * 2
SET STOP LOSS myRange
ENDIF
//graphonprice HH coloured("Blue")
//graphonprice LL coloured("Red")
//graph OTD
Questo è più corretto nel piazzare gli ordini:
defparam cumulateorders=false
IF IntraDayBarIndex = 0 THEN
HH = 0
LL = 0
ENDIF
OTD = Barindex - TradeIndex(1) > IntradayBarIndex //Una sola operazione al giorno (One Trade per Day)
IF time >= 090000 AND time =< 093000 AND OTD THEN
IF LL = 0 THEN
LL = low
ENDIF
HH = max(HH,high)
LL = min(LL,low)
myRange = HH - LL
IF close > LL AND myRange >= 24 THEN
BUY 1 CONTRACT AT LL LIMIT
ENDIF
IF close < HH AND myRange >= 24 THEN
SELLSHORT 1 CONTRACT at HH LIMIT
ENDIF
SET TARGET PROFIT myRange * 2
SET STOP LOSS myRange
ENDIF
//graphonprice HH coloured("Blue")
//graphonprice LL coloured("Red")
//graph OTD