Sistema giornaliero con loss e profit
Forums › ProRealTime forum Italiano › Supporto ProOrder › Sistema giornaliero con loss e profit
- This topic has 4 replies, 3 voices, and was last updated 1 year ago by robertogozzi.
-
-
09/13/2023 at 10:27 AM #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
// 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)
endifif 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
ENDIF
// Conditions for entering short positions and exit long positions
IF signal<0 THEN
SELLSHORT n CONTRACTs AT marketSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)ENDIF
09/13/2023 at 11:25 AM #220922secondo 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
// Spread: 4
// created and coded by davidelaferla
//————————————————————————-//————————————————————————-
defparam cumulateorders=falseTimeframe ( 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)
endifif 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
endifTimeframe ( 1 hour, default)
// Conditions for entering long positions and exit short positions
IF signal>0 then
BUY n contract AT market
ENDIF
// Conditions for entering short positions and exit long positions
IF signal<0 THEN
SELLSHORT n CONTRACTs AT marketSET STOP LOSS l*AverageTrueRange[10](close)
SET TARGET PROFIT p*AverageTrueRange[12](close)ENDIF
1 user thanked author for this post.
09/13/2023 at 11:27 AM #22092309/14/2023 at 9:57 AM #221012Lo sto provando, ma mi da l’errore che allego
09/14/2023 at 12:03 PM #221015Devi usare un TF di 1 ora o minore (però se minore, bisogna che 60, che sono i minuti di un’ora ne siano multipli).
-
AuthorPosts
Find exclusive trading pro-tools on