loss e profit non funzionanti
Forums › ProRealTime forum Italiano › Supporto ProOrder › loss e profit non funzionanti
- This topic has 3 replies, 2 voices, and was last updated 1 year ago by robertogozzi. 
- 
	
		
- 
		
			
				
11/08/2023 at 12:09 PM #223360In 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)
 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 marketSET STOP PLOSS l 
 SET TARGET PPROFIT pENDIF // Conditions for entering short positions and exit long positions 
 IF signal<0 THEN
 SELLSHORT n CONTRACTs AT marketSET 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 11/08/2023 at 4:35 PM #223372Credo sia un problema di SL e TP, un pò troppo vicini al prezzo, trattandosi di candele giornaliere. Inoltre pè sempre opportuno usare anche la condizione OnMarket per entrare, in modo da non eseguire il codice anche nelle barre successive, se già a mercato. Questo pè il codice che hai postato, leggermente modificato come ti ho dertto e con l’aggiunta di GRAPHONPRICE per vedere sul grafico dove sono sutuati SL e TP: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081// Universal XBody STrategy// instrument: EUR/USD// timeframe : Daily// Spread : 4// created and coded by davidelaferla//————————————————————————-defparam cumulateorders=falsel = 100//20p = 300//90l1 = 100//35p1 = 300//20per = 269inv = 1md = 3fl1 = 9fl2 = 9//***********************************************************************************************************N = 1//—————— SYSTEM VARIABLES—————————————//CAC40 Values: ——————————————- Ottimization infoperiod=per// Optimize best value for each Symbol, range=1-1000, with step=1mode=md// Optimize the best trading mode , range=1-4, with step=1invertsignal=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=1filter2=fl2// to set after the variable optimization, range=0-100, with step=1//—————— INDICATOR —————————————body=close-openvar=(body-body[1])sumvar=summation[period](var)if sumvar>filter1*pipsize thengreen=(sumvar)endifif sumvar<-filter2*pipsize thenred=(sumvar)endifif mode=1 thenc1=red<red[1]c2=green>green[1]endifif mode=2 thenc1=red>red[1]c2=green<green[1]endifif mode=3 thenc1=red<red[1]c2=green<green[1]endifif mode=4 thenc1=red>red[1]c2=green>green[1]endifif c1 thensignal=1*invertsignalelsif c2 thensignal=-1*invertsignalendif// Conditions for entering long positions and exit short positionsIF signal>0 AND Not OnMarket thenBUY n contract AT marketSLprice = close - l*pipsizeTPprice = close + p*pipsizeSET STOP PLOSS lSET TARGET PPROFIT pENDIF// Conditions for entering short positions and exit long positionsIF signal<0 AND Not OnMarket THENSELLSHORT n CONTRACTs AT marketSLprice = close + l1*pipsizeTPprice = close - p1*pipsizeSET STOP PLOSS l1SET TARGET PPROFIT p1//SET STOP LOSS l*AverageTrueRange[10](close)//SET TARGET PROFIT p*AverageTrueRange[12](close)ENDIFgraphonprice SLprice coloured("Red")graphonprice TPprice coloured("Blue")11/10/2023 at 9:49 AM #223486SLprice = close – l*pipsizeTPprice = close + p*pipsizeSET STOP PLOSS lSET TARGET PPROFIT pMa in questa maniera gli stop e profit sono forse doppiati?Grazie11/10/2023 at 5:03 PM #223508No, le prime due righe definiscono delle variabili (usate per visualizzare TP e SL sul grafico), non sono istruzioni da eseguire. 
 Gli ordini di SL e TP sono le altre due righe che iniziano con SET, quindi non c’è nessuna duplicazione.
- 
		AuthorPosts
			Find exclusive trading pro-tools on 


 
		 
		 
		