# Sistema giornaliero con loss e profit

Forums ProRealTime forum Italiano Supporto ProOrder Sistema giornaliero con loss e profit

Viewing 5 posts - 1 through 5 (of 5 total)
• #220920

Nel codice trovato in libreria (allego) ho aggiunto un loss e profit, ma essendo il TF giornaliero , gli stessi operano a fine giornata e il drawdown è veramente alto. Vorrei limitarlo agendo sul loss e profit che dovrebbero agire dentro la candela, ma non so se è possibile.

Grazie a chi mi può aiutare.

//Universal XBody STrategy
// instrument: DAX
// timeframe : Daily
// 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
ENDIF
// Conditions for entering short positions and exit long positions
IF signal<0 THEN
SELLSHORT n CONTRACTs AT market

SET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)

ENDIF

#220922

secondo me l’unico modo è inserire un TF diverso sulla parte di esecuzione e inserire un timeframe giornaliero sull’indicatore, per esempio:

//Universal XBody STrategy
// instrument: DAX
// timeframe : Daily
// created and coded by davidelaferla
//————————————————————————-

//————————————————————————-
defparam cumulateorders=false

Timeframe ( 1 day, updateonclose)

//***********************************************************************************************************
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

Timeframe ( 1 hour, default)

// Conditions for entering long positions and exit short positions
IF signal>0 then
ENDIF
// Conditions for entering short positions and exit long positions
IF signal<0 THEN
SELLSHORT n CONTRACTs AT market

SET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)

ENDIF

###### 1 user thanked author for this post.
#220923

da adattare i valori di AverageTrueRange, perchè lavoranso ull’orario, quidni da moltiplicare per 24 presumo

#221012

Lo sto provando, ma mi da l’errore che allego

#221015

Devi usare un TF di 1 ora o minore (però se minore, bisogna che 60, che sono i minuti di un’ora ne siano multipli).

Viewing 5 posts - 1 through 5 (of 5 total)