diferencias en calculo de TP y SL cuando cambio de Time Frame

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #248288 quote
    RAM24
    Participant
    New

    Buenas 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 //Boolean

    limitday=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
    endif

    if 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 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 Once Myt1 = openLO Once Myt2 = endtime Once 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=mini

    if 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

    #248293 quote
    Iván González
    Moderator
    Master

    Hola. Lo siento pero es imposible ver nada en el código que has compartido…
    Para compartir código tienes que pinchar en el botón de “Añadir código PRT” y pegar tu código en el cuadro emergente.

    #248303 quote
    RAM24
    Participant
    New

    openLO=143000
    closeLO=160000
    //Long=1 //Boolean
    //Short=1 //Boolean

    limitday=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
    endif

    if 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
    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
    Once Myt1 = openLO
    Once Myt2 = endtime
    Once 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=mini

    if 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

    #248304 quote
    RAM24
    Participant
    New

    De acuerdo Ivan, espero que el codigo  ahora sea legible.

    saludos

    #248322 quote
    Iván González
    Moderator
    Master

    Buenas. 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:

    openLO=143000
    closeLO=160000
    Long=0//Boolean
    Short=1 //Boolean
    
    limitday=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
    endif
    
    if 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
    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
    Once Myt1 = openLO
    Once Myt2 = endtime
    Once 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=mini
    
    if 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.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")
    endif
    return
    #248341 quote
    RAM24
    Participant
    New

    mil 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?

    #248367 quote
    RAM24
    Participant
    New

    en time frame de m1 no respeta los niveles y calcula un rango diferente y valores distintos de entrada, SL y TP. Donde esta el error?

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

diferencias en calculo de TP y SL cuando cambio de Time Frame


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
RAM24 @ram24 Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by RAM24
7 months, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 06/15/2025
Status: Active
Attachments: 3 files
Logo Logo
Loading...