Salve, ho un problema con un sistema sullo Spot gold (E1) timeframe h4.
Le condizioni c5 e c55 dovrebbero far si che il sistema entri solo se l’high[0] è maggiore dell’high più alto delle ultime 3 candele (per il long), e se il low[0] è minore del low più basso delle ultime 3 candele (per lo short).
Per quanto riguarda l’entrata dovrebbe entrare long sul low[0] e entrare short sull’high[0].
Ecco il codice intero
defparam cumulateorders=false
smaC=average[11] (close)
smaH=average[12] (high)
smaL=average[12] (low)
x1=abs(close-open)<(close/100)*0.067
x2=abs(close-open)>(close/100)*0.025
x22=abs(close[1]-open[1])>(close[1]/100)*0.02
//long
c=close[0]<open[0]
c0=close>smaL
c1=open<smaH
c3=close[1]<smaH
c4=open[1]>smaL
c5=high>highest[3]
c6=high[1]>smaC
c7=high>smaC
//short
cc=close[0]>open[0]
c00=open>smaL
c11=close<smaH
c33=open[1]<smaH
c44=close[1]>smaL
c55=low<lowest[3]
c66=low[1]<smaC
c77=low<smaC
exit=barindex-tradeindex=8
// Condizioni per entrare su posizioni long
IF c and c0 and c1 and c3 and c4 and c5 and c6 and c7 and x1 and x2 and x22 THEN
BUY 1 CONTRACTS AT low+0*pointsize stop
ENDIF
// Condizioni per uscire da posizioni long
If LongOnMarket AND exit THEN
SELL AT MARKET
ENDIF
// Condizioni per entrare su posizioni short
IF cc and c00 and c11 and c33 and c44 and c55 and c66 and c77 and x1 and x2 and x22 THEN
SELLSHORT 1 CONTRACTS AT high-0*pointsize stop
ENDIF
// Condizioni per uscire da posizioni short
IF ShortOnMarket AND exit THEN
EXITSHORT AT MARKET
ENDIF
// Stop e target: Inserisci qui i tuoi stop di protezione e profit target
set stop %loss 1.37
set target %profit 2.88