In una strategia trovato in libreria (allegato) in bak test i loss e profit funzionano , o almeno cosi sembra, in live non scattano . Inoltre in demo funzionano in live no. Sembra strano ma è quello che sto rilevando ultimamente.
Chiedo a Roberto che ringrazio anticipatamente se mi può aiutare.
//Universal XBody STrategy
// instrument: EUR/USD
// timeframe : Daily
// Spread: 4
// created and coded by davidelaferla
//————————————————————————-
//————————————————————————-
defparam cumulateorders=false
//***********************************************************************************************************
N = 1
//—————— SYSTEM VARIABLES—————————————
//CAC40 Values: ——————————————– Ottimization info
period=per// Optimize best value for each Symbol, range=1-1000, with step=1
mode=md// Optimize the best trading mode , range=1-4, with step=1
invertsignal=inv// 1=positive signal, -1=negative signal, range=-1-1, with step=2
//***********************************************************************************************
//—————— SYSTEM FILTER—————————————
filter1=fl1// to set after the variable optimization, range=1-100, with step=1
filter2=fl2// to set after the variable optimization, range=0-100, with step=1
//—————— INDICATOR —————————————
body=close-open
var=(body-body[1])
sumvar=summation[period](var)
if sumvar>filter1*pipsize then
green=(sumvar)
endif
if sumvar<-filter2*pipsize then
red=(sumvar)
endif
if mode=1 then
c1=red<red[1]
c2=green>green[1]
endif
if mode=2 then
c1=red>red[1]
c2=green<green[1]
endif
if mode=3 then
c1=red<red[1]
c2=green<green[1]
endif
if mode=4 then
c1=red>red[1]
c2=green>green[1]
endif
if c1 then
signal=1*invertsignal
elsif c2 then
signal=-1*invertsignal
endif
// Conditions for entering long positions and exit short positions
IF signal>0 then
BUY n contract AT market
SET STOP PLOSS l
SET TARGET PPROFIT p
ENDIF
// Conditions for entering short positions and exit long positions
IF signal<0 THEN
SELLSHORT n CONTRACTs AT market
SET STOP PLOSS l1
SET TARGET PPROFIT p1
//SET STOP LOSS l*AverageTrueRange[10](close)
//SET TARGET PROFIT p*AverageTrueRange[12](close)
ENDIF
VARIABILI
l =20, p =90, l1=35 ,p1 = 20, per = 269, inv =1, md = 3, f1 =9 , f2 = 9