diferencias en calculo de TP y SL cuando cambio de Time Frame
Forums › ProRealTime foro Español › Soporte ProBuilder › diferencias en calculo de TP y SL cuando cambio de Time Frame
- This topic has 6 replies, 2 voices, and was last updated 4 months ago by RAM24. 
- 
	
		
- 
		
			
				
06/15/2025 at 9:23 PM #248288Buenas tardes a todos, 
 Alguien me podria ayudar a encontrar los errores con el codigo para el Range europeo, el grafico es correcto, pero al cambiar de time frames a veces se desconfigura y se cambian los datos para el TP y SL.openLO=143000 
 closeLO=160000
 //Long=1 //Boolean
 //Short=1 //Booleanlimitday=220000 
 endentry=closeLO + 050000
 endtime=closeLO
 atr=AverageTrueRange[14](close)if ticksize=1 or ticksize=0.01 then 
 decimalsPlaces=0
 elsif ticksize=0.001 then//
 decimalsPlaces=1
 elsif ticksize=0.0001 then//
 decimalsPlaces=3
 elsif ticksize=0.00001 then
 decimalsPlaces=4
 endifif gettimeframe<=3600 then maxHighLO=high minLowLO=low if opentime>=openLO and opentime<=closeLO THEN maxi = highest[max(1,barras+1)](high) mini = LOWEST[max(1,barras+1)](low) rangol = maxi-mini objetivool = maxi+rangol ENDIF if opentime>=openLO and opentime<=closeLO then barLO=barLO+1 if high>=maxHighLO then 
 maxHighLO=high
 else
 maxHighLO=maxHighLO
 endif
 if low<=minLowLO then minLowLO=low else minLowLO=minLowLO endif endif if opentime=closeLO then MidRange0 = (maxHighLO - minLowLO) / 2 MidPrice = minLowLO + MidRange0 drawsegment(barindex[barLO],MidPrice,barindex,MidPrice)coloured("blue") style(dottedline,2)coloured("cadetblue",75) ENDIF endif if opentime=closeLO then Myt1 = openLO Myt2 = endtime Count = 0 MidRange=(maxHighLO - minLowLO) / 2 If OpenTime >= MyT1 AND OpenTime <= Myt2 then Count = Count + 1 barras=barlo-1 if decimalsPlaces=0 then pp=round(MidRange*2) nivel=pp elsif decimalsPlaces=1 then pipsF=round(MidRange*200) nivel=pipsF elsif decimalsPlaces=3 then pipsJ=MidRange*20000 nivel=pipsJ elsif decimalsPlaces=4 then pipsD=round(MidRange*20000) nivel=pipsD endif Endif drawrectangle(barindex[barLO],minLowLO,barindex,maxHighLO) coloured("cadetblue") fillcolor("cadetblue",30) drawtext("UP #maxHighLO#",barindex[round(barLO/2)],maxHighLO+0.15*atr)coloured("cadetblue") drawtext("DOWN: #minLowLO# ",barindex[round(barLO/2)],minLowLO-0.15*atr)coloured("cadetblue") drawtext("#nivel#",barindex[round(barLO/2)],MidPrice ,SansSerif,Bold,85)coloured("cadetblue",95) prevLowLO=minLowLO prevHighLO=maxHighLO previdxLO=barindex barLO=0 minLowLO=high*100 maxHighLO=0 ENDIF if low crosses under prevLowLO then drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured("cadetblue") prevLowLO=0 elsif opentime=limitday and prevLowLO<>0 then
 drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured(“cadetblue”)
 prevLowLO=0
 elsif islastbarupdate and prevLowLO<>0 then
 drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured(“cadetblue”)
 endif
 if high crosses over prevHighLO then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 prevHighLO=0
 elsif opentime=limitday and prevHighLO<>0 then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 prevHighLO=0
 elsif islastbarupdate and prevHighLO<>0 then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 endif////////////////////////////////////////////LONG//////////////////////////////////////////// 
 if time = openlo then
 startbarl = barindex
 maximo = highest[max(1,barras+1)](high)
 minimo = LOWEST[max(1,barras+1)](low)
 endif
 if time = closelo then
 endbarl = barindex
 maximo = highest[max(1,barras+1)](high)
 minimo = LOWEST[max(1,barras+1)](low)
 ENDIF
 rangl=maxi-mini
 objetivol= maxi+rangl
 objetivos =mini -((abs(maximo-minimo)))
 stoplosl=miniif time <= endentry and long=1 then// short=0 if time>endtime and time<=endentry and long=1 then DrawRectangle(endbarl+barras,objetivool,endbarl+1,maxi)coloured("cadetblue",50)bordercolor("cadetblue",50 ) DrawRectangle(endbarl+barras,maxi,endbarl+1,stoplosl)coloured("lightgray",70)bordercolor("lightgray",90) ENDIF endif if time=closelo and time<=endentry and long=1 then short=0 DrawText("ENTRY LEVEL #maxi#",endbarl+0.5*barras,maxi+(+0.15*atr),SansSerif,standard,10)coloured("cadetblue") DrawText("TARGET: #objetivol# #objetivos#",endbarl+0.5*barras,objetivol+(+0.15*atr),SansSerif,bold,10) coloured("cadetblue") DrawText("STOPLOSS LEVEL #mini#",endbarl+0.5*barras,(mini+0.10*atr),SansSerif,bold,10)coloured("cadetblue") endif ////////////////////////////////////////////SHORT/////////////////////////////////////////// if time = openlo then startbars = barindex maximol = highest[max(1,barras+1)](high) minimos = LOWEST[max(1,barras+1)](low) endif if time = closelo then endbars = barindex maximol = highest[max(1,barras+1)](high) minimo = LOWEST[max(1,barras+1)](low) ENDIF if time <= endentry and short=1 then// long=0 if time>endtime and time<=endentry and short=1 then DrawRectangle(endbars+barras,mini,endbars+1,maxi)coloured("lightgray",70)bordercolor("lightgray",70) DrawRectangle(endbars+barras,objetivos,endbars+1,mini) coloured("cadetblue",50)bordercolor("cadetblue",50 ) ENDIF endif if time>closelo and time<=endentry and short=1 then Long=0 DrawText("ENTRY LEVEL #mini#",endbars+0.5*barras,mini-(0.7*pointsize),SansSerif,standard,10)coloured("cadetblue") DrawText("TARGET: #objetivos#",endbars+0.5*barras,objetivos+(1*pointsize),SansSerif,bold,10) coloured("cadetblue") DrawText("STOPLOSS LEVEL #maxi#",endbars+0.5*barras,maximo+(0.7*pointsize),SansSerif,bold,10)coloured("cadetblue") endif return 06/16/2025 at 10:12 AM #24829306/16/2025 at 3:30 PM #248303openLO=143000 
 closeLO=160000
 //Long=1 //Boolean
 //Short=1 //Booleanlimitday=220000 
 endentry=closeLO + 050000
 endtime=closeLO
 atr=AverageTrueRange[14](close)if ticksize=1 or ticksize=0.01 then 
 decimalsPlaces=0
 elsif ticksize=0.001 then//
 decimalsPlaces=1
 elsif ticksize=0.0001 then//
 decimalsPlaces=3
 elsif ticksize=0.00001 then
 decimalsPlaces=4
 endifif gettimeframe<=3600 then 
 once maxHighLO=high
 once minLowLO=low
 if opentime>=openLO and opentime<=closeLO THEN
 maxi = highest[max(1,barras+1)](high)
 mini = LOWEST[max(1,barras+1)](low)
 rangol = maxi-mini
 objetivool = maxi+rangol
 ENDIFif opentime>=openLO and opentime<=closeLO then 
 barLO=barLO+1
 if high>=maxHighLO then
 maxHighLO=high
 else
 maxHighLO=maxHighLO
 endif
 if low<=minLowLO then
 minLowLO=low
 else
 minLowLO=minLowLO
 endif
 endif
 if opentime=closeLO then
 MidRange0 = (maxHighLO – minLowLO) / 2
 MidPrice = minLowLO + MidRange0
 drawsegment(barindex[barLO],MidPrice,barindex,MidPrice)coloured(“blue”) style(dottedline,2)coloured(“cadetblue”,75)
 ENDIF
 endifif opentime=closeLO then 
 Once Myt1 = openLO
 Once Myt2 = endtime
 Once Count = 0
 MidRange=(maxHighLO – minLowLO) / 2If OpenTime >= MyT1 AND OpenTime <= Myt2 then 
 Count = Count + 1
 barras=barlo-1
 if decimalsPlaces=0 then
 pp=round(MidRange*2)
 nivel=pp
 elsif decimalsPlaces=1 then
 pipsF=round(MidRange*200)
 nivel=pipsF
 elsif decimalsPlaces=3 then
 pipsJ=MidRange*20000
 nivel=pipsJ
 elsif decimalsPlaces=4 then
 pipsD=round(MidRange*20000)
 nivel=pipsD
 endif
 Endif
 drawrectangle(barindex[barLO],minLowLO,barindex,maxHighLO) coloured(“cadetblue”) fillcolor(“cadetblue”,30)
 drawtext(“UP #maxHighLO#”,barindex[round(barLO/2)],maxHighLO+0.15*atr)coloured(“cadetblue”)
 drawtext(“DOWN: #minLowLO# “,barindex[round(barLO/2)],minLowLO-0.15*atr)coloured(“cadetblue”)
 drawtext(“#nivel#”,barindex[round(barLO/2)],MidPrice ,SansSerif,Bold,85)coloured(“cadetblue”,95)
 prevLowLO=minLowLO
 prevHighLO=maxHighLO
 previdxLO=barindex
 barLO=0
 minLowLO=high*100
 maxHighLO=0
 ENDIFif low crosses under prevLowLO then 
 drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured(“cadetblue”)
 prevLowLO=0
 elsif opentime=limitday and prevLowLO<>0 then
 drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured(“cadetblue”)
 prevLowLO=0
 elsif islastbarupdate and prevLowLO<>0 then
 drawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured(“cadetblue”)
 endif
 if high crosses over prevHighLO then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 prevHighLO=0
 elsif opentime=limitday and prevHighLO<>0 then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 prevHighLO=0
 elsif islastbarupdate and prevHighLO<>0 then
 drawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured(“cadetblue”)
 endif////////////////////////////////////////////LONG//////////////////////////////////////////// 
 if time = openlo then
 startbarl = barindex
 maximo = highest[max(1,barras+1)](high)
 minimo = LOWEST[max(1,barras+1)](low)
 endif
 if time = closelo then
 endbarl = barindex
 maximo = highest[max(1,barras+1)](high)
 minimo = LOWEST[max(1,barras+1)](low)
 ENDIF
 rangl=maxi-mini
 objetivol= maxi+rangl
 objetivos =mini -((abs(maximo-minimo)))
 stoplosl=miniif time <= endentry and long=1 then// 
 short=0
 if time>endtime and time<=endentry and long=1 then
 DrawRectangle(endbarl+barras,objetivool,endbarl+1,maxi)coloured(“cadetblue”,50)bordercolor(“cadetblue”,50 )
 DrawRectangle(endbarl+barras,maxi,endbarl+1,stoplosl)coloured(“lightgray”,70)bordercolor(“lightgray”,90)
 ENDIF
 endifif time=closelo and time<=endentry and long=1 then 
 short=0
 DrawText(“ENTRY LEVEL #maxi#”,endbarl+0.5*barras,maxi+(+0.15*atr),SansSerif,standard,10)coloured(“cadetblue”)
 DrawText(“TARGET: #objetivol# #objetivos#”,endbarl+0.5*barras,objetivol+(+0.15*atr),SansSerif,bold,10) coloured(“cadetblue”)
 DrawText(“STOPLOSS LEVEL #mini#”,endbarl+0.5*barras,(mini+0.10*atr),SansSerif,bold,10)coloured(“cadetblue”)
 endif////////////////////////////////////////////SHORT/////////////////////////////////////////// 
 if time = openlo then
 startbars = barindex
 maximol = highest[max(1,barras+1)](high)
 minimos = LOWEST[max(1,barras+1)](low)
 endif
 if time = closelo then
 endbars = barindex
 maximol = highest[max(1,barras+1)](high)
 minimo = LOWEST[max(1,barras+1)](low)
 ENDIFif time <= endentry and short=1 then// 
 long=0
 if time>endtime and time<=endentry and short=1 then
 DrawRectangle(endbars+barras,mini,endbars+1,maxi)coloured(“lightgray”,70)bordercolor(“lightgray”,70)
 DrawRectangle(endbars+barras,objetivos,endbars+1,mini) coloured(“cadetblue”,50)bordercolor(“cadetblue”,50 )
 ENDIF
 endifif time>closelo and time<=endentry and short=1 then 
 Long=0
 DrawText(“ENTRY LEVEL #mini#”,endbars+0.5*barras,mini-(0.7*pointsize),SansSerif,standard,10)coloured(“cadetblue”)
 DrawText(“TARGET: #objetivos#”,endbars+0.5*barras,objetivos+(1*pointsize),SansSerif,bold,10) coloured(“cadetblue”)
 DrawText(“STOPLOSS LEVEL #maxi#”,endbars+0.5*barras,maximo+(0.7*pointsize),SansSerif,bold,10)coloured(“cadetblue”)
 endif
 return06/16/2025 at 3:32 PM #24830406/17/2025 at 9:40 AM #248322Buenas. Lo único que he visto es que para los cortos el texto lo ubicas en función del pointsize y no del atr. 
 Además de utilizar time>closelo por lo que que escribe varias veces mientras se cumpla la condicion.
 Te paso una modificacion:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177openLO=143000closeLO=160000Long=0//BooleanShort=1 //Booleanlimitday=220000endentry=closeLO + 050000endtime=closeLOatr=AverageTrueRange[14](close)if ticksize=1 or ticksize=0.01 thendecimalsPlaces=0elsif ticksize=0.001 then//decimalsPlaces=1elsif ticksize=0.0001 then//decimalsPlaces=3elsif ticksize=0.00001 thendecimalsPlaces=4endifif gettimeframe<=3600 thenonce maxHighLO=highonce minLowLO=lowif opentime>=openLO and opentime<=closeLO THENmaxi = highest[max(1,barras+1)](high)mini = LOWEST[max(1,barras+1)](low)rangol = maxi-miniobjetivool = maxi+rangolENDIFif opentime>=openLO and opentime<=closeLO thenbarLO=barLO+1if high>=maxHighLO thenmaxHighLO=highelsemaxHighLO=maxHighLOendifif low<=minLowLO thenminLowLO=lowelseminLowLO=minLowLOendifendifif opentime=closeLO thenMidRange0 = (maxHighLO - minLowLO) / 2MidPrice = minLowLO + MidRange0drawsegment(barindex[barLO],MidPrice,barindex,MidPrice)coloured("blue")style(dottedline,2)coloured("cadetblue",75)ENDIFendifif opentime=closeLO thenOnce Myt1 = openLOOnce Myt2 = endtimeOnce Count = 0MidRange=(maxHighLO - minLowLO) / 2If OpenTime >= MyT1 AND OpenTime <= Myt2 thenCount = Count + 1barras=barlo-1if decimalsPlaces=0 thenpp=round(MidRange*2)nivel=ppelsif decimalsPlaces=1 thenpipsF=round(MidRange*200)nivel=pipsFelsif decimalsPlaces=3 thenpipsJ=MidRange*20000nivel=pipsJelsif decimalsPlaces=4 thenpipsD=round(MidRange*20000)nivel=pipsDendifEndifdrawrectangle(barindex[barLO],minLowLO,barindex,maxHighLO)coloured("cadetblue") fillcolor("cadetblue",30)drawtext("UP#maxHighLO#",barindex[round(barLO/2)],maxHighLO+0.15*atr)coloured("cadetblue")drawtext("DOWN: #minLowLO#",barindex[round(barLO/2)],minLowLO-0.15*atr)coloured("cadetblue")drawtext("#nivel#",barindex[round(barLO/2)],MidPrice,SansSerif,Bold,85)coloured("cadetblue",95)prevLowLO=minLowLOprevHighLO=maxHighLOprevidxLO=barindexbarLO=0minLowLO=high*100maxHighLO=0ENDIFif low crosses under prevLowLO thendrawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured("cadetblue")prevLowLO=0elsif opentime=limitday and prevLowLO<>0 thendrawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured("cadetblue")prevLowLO=0elsif islastbarupdate and prevLowLO<>0 thendrawsegment(previdxLO,prevLowLO,barindex,prevLowLO)coloured("cadetblue")endifif high crosses over prevHighLO thendrawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured("cadetblue")prevHighLO=0elsif opentime=limitday and prevHighLO<>0 thendrawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured("cadetblue")prevHighLO=0elsif islastbarupdate and prevHighLO<>0 thendrawsegment(previdxLO,prevHighLO,barindex,prevHighLO)coloured("cadetblue")endif////////////////////////////////////////////LONG////////////////////////////////////////////if time = openlo thenstartbarl = barindexmaximo = highest[max(1,barras+1)](high)minimo = LOWEST[max(1,barras+1)](low)endifif time = closelo thenendbarl = barindexmaximo = highest[max(1,barras+1)](high)minimo = LOWEST[max(1,barras+1)](low)ENDIFrangl=maxi-miniobjetivol= maxi+ranglobjetivos =mini -((abs(maximo-minimo)))stoplosl=miniif time <= endentry and long=1 then//short=0if time>endtime and time<=endentry and long=1 thenDrawRectangle(endbarl+barras,objetivool,endbarl+1,maxi)coloured("cadetblue",50)bordercolor("cadetblue",50)DrawRectangle(endbarl+barras,maxi,endbarl+1,stoplosl)coloured("lightgray",70)bordercolor("lightgray",90)ENDIFendifif time=closelo and time<=endentry and long=1 thenshort=0DrawText("ENTRY LEVEL#maxi#",endbarl+0.5*barras,maxi+(+0.15*atr),SansSerif,standard,10)coloured("cadetblue")DrawText("TARGET: #objetivol##objetivos#",endbarl+0.5*barras,objetivol+(+0.15*atr),SansSerif,bold,10)coloured("cadetblue")DrawText("STOPLOSS LEVEL#mini#",endbarl+0.5*barras,(mini+0.10*atr),SansSerif,bold,10)coloured("cadetblue")endif////////////////////////////////////////////SHORT///////////////////////////////////////////if time = openlo thenstartbars = barindexmaximol = highest[max(1,barras+1)](high)minimos = LOWEST[max(1,barras+1)](low)endifif time = closelo thenendbars = barindexmaximol = highest[max(1,barras+1)](high)minimo = LOWEST[max(1,barras+1)](low)ENDIFif time <= endentry and short=1 then//long=0if time>endtime and time<=endentry and short=1 thenDrawRectangle(endbars+barras,mini,endbars+1,maxi)coloured("lightgray",70)bordercolor("lightgray",70)DrawRectangle(endbars+barras,objetivos,endbars+1,mini)coloured("cadetblue",50)bordercolor("cadetblue",50 )ENDIFendifif time=closelo and time<=endentry and short=1 thenLong=0DrawText("ENTRY LEVEL#mini#",endbars+0.5*barras,mini+(0.15*atr),SansSerif,standard,10)coloured("cadetblue")DrawText("TARGET:#objetivos#",endbars+0.5*barras,objetivos+(0.15*atr),SansSerif,bold,10)coloured("cadetblue")DrawText("STOPLOSS LEVEL#maxi#",endbars+0.5*barras,maximo+(0.15*atr),SansSerif,bold,10)coloured("cadetblue")endifreturn06/17/2025 at 2:00 PM #248341mil gracias Ivan por la correciones propuetas, te paso un ejm de los errores que siguen dando, yo creo que es porque el range box cambia minimamente para cada time frame, pero no consigo calcular los rangos entrada, SL y TP correctos para cada temporalidad. Se puede solucionar? 06/18/2025 at 10:25 AM #248367
- 
		AuthorPosts
			Find exclusive trading pro-tools on 


 
		 
		 
		