error in calculation

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

    Why does this fail?

    With the marvellous debugging support in the language, all I get is “error en el calculo” (calculation error). Not even the line or the expression involved. Any clue?

    Variables are desplx 1 desply 3 tsize 11 and everything else set to 1.

     

    // Cambiado salvajemente a partir del indicador de cotas de Doc.
    // para tener un indicador que para un activo marque mis cotas

    // Para crear un indicador para tener cotas de un activo, usa la ventana que lista todos los indicadores,
    // selecciona este, da a duplicar, da a modificar, cambia el nombre por ejemplo a MisCotasEURCAD o lo que sea.
    // y define tus cotas como se indica en los comentarios.

    DEFPARAM DrawOnLastBarOnly = true
    DEFPARAM CalculateOnLastBars = 1

    once desplvertical = desply

    CHBarindex = barindex

    Voffset = 0.0 + 16 * pipsize + DesplVertical * pipsize // Desplazamiento vertical valor cotas
    Hoffset = 0 – desplx – 40

    // Para marcar apertural anual, dar valor (se muestra junto con las de diario, en amarillo)

    ONCE AperturaAnual = 11598

    // Para trimestrales , usa una nueva linea como estas con el siguiente
    // indice sin usar: [0], [1], [2], ….
    // En estas dos de ejemplo, cambia 00000 por tus cotas
    ONCE $Trimestrales[0] = 2815
    ONCE $Trimestrales[1] = 3980
    ONCE $Trimestrales[2] = 5935
    ONCE $Trimestrales[3] = 7300
    ONCE $Trimestrales[4] = 9260
    ONCE $Trimestrales[5] = 11020
    ONCE $Trimestrales[6] = 12720
    ONCE $Trimestrales[7] = 15980

    // Para semanales, usa una nueva linea como estas con el siguiente
    // indice sin usar: [0], [1], [2], ….
    // Estas son de ejemplo, puedes usarlas para poner tus valores en las primeras
    // y borrar el resto o incluir mas. El valor 0 se ignora
    ONCE $Semanales[0] = 5450
    ONCE $Semanales[1] = 6634
    ONCE $Semanales[2] = 8080
    ONCE $Semanales[3] = 10100
    ONCE $Semanales[4] = 11780
    ONCE $Semanales[5] = 14120

    ONCE $Psicologicas[1] = 1000
    ONCE $Psicologicas[2] = 2000
    ONCE $Psicologicas[3] = 3000
    ONCE $Psicologicas[4] = 4000
    ONCE $Psicologicas[5] = 5000
    ONCE $Psicologicas[6] = 6000
    ONCE $Psicologicas[7] = 7000
    ONCE $Psicologicas[8] = 8000
    ONCE $Psicologicas[9] = 9000
    ONCE $Psicologicas[10] = 10000
    ONCE $Psicologicas[11] = 11000
    ONCE $Psicologicas[0] = 00000

    // Para cada cota diaria, usa una nueva linea como estas con el siguiente
    // indice sin usar: [0], [1], [2], ….
    // Estas son de ejemplo, puedes usarlas para poner tus valores en las primeras
    // y borrar el resto o incluir mas. El valor 0 se ignora
    ONCE $Diarias[0] = 00000
    ONCE $Diarias[0] = 2940
    ONCE $Diarias[1] = 3325
    ONCE $Diarias[2] = 3635
    ONCE $Diarias[3] = 4280
    ONCE $Diarias[4] = 4760
    ONCE $Diarias[5] = 5250
    ONCE $Diarias[6] = 6140
    ONCE $Diarias[7] = 6425
    ONCE $Diarias[8] = 6854
    ONCE $Diarias[9] = 7072
    ONCE $Diarias[10] = 7508
    ONCE $Diarias[11] = 7665
    ONCE $Diarias[12] = 7771
    ONCE $Diarias[13] = 7967
    ONCE $Diarias[14] = 8375
    ONCE $Diarias[15] = 8452
    ONCE $Diarias[16] = 8538
    ONCE $Diarias[17] = 8648
    ONCE $Diarias[18] = 8785
    ONCE $Diarias[19] = 8901
    ONCE $Diarias[20] = 8999
    ONCE $Diarias[21] = 9118
    ONCE $Diarias[22] = 9165
    ONCE $Diarias[23] = 9208
    ONCE $Diarias[24] = 9304
    ONCE $Diarias[25] = 9360
    ONCE $Diarias[26] = 9554
    ONCE $Diarias[27] = 9655
    ONCE $Diarias[28] = 10510
    ONCE $Diarias[29] = 10191 // PA 2024
    ONCE $Diarias[30] = 11480
    ONCE $Diarias[31] = 12030
    ONCE $Diarias[32] = 12475
    ONCE $Diarias[33] = 13530
    ONCE $Diarias[34] = 14670
    ONCE $Diarias[35] = 15330
    // ahora iria $Diarias[2]

    // Para las de corto plazo,
    // Si se define $CortoPlazoAlto[X] para un $CortoPlazo[X] definido, entonces
    // se dibujan dos lineas para marcar una zona: de cota a cota+alto
    // Hay dos ejemplos, [0] y [1], definir mas con [2], [3], …

    ONCE $CortoPlazo[0] = 8290
    // ahora iria $CortoPlazo[2] = XXXX

    // Otro tipo de corto plazo.
    ONCE $CortoPlazo2[0] = 0000

    // Y otro tipo mas de corto plazo
    ONCE $CortoPlazo3[0] = 0000

    IF islastbarupdate THEN
    // Diaras COLOR ROJO OSCURO ********************************************
    // para cambiar la forma de la linea sustituir el parámetro dottedline por line
    // podrias copiar este para poner un nuevo bloque desde aqui….
    if diario then
    n = lastset($Diarias)
    for cota = 0 to n do
    CotaValue = $Diarias[cota]
    if CotaValue = 0 then
    continue
    endif
    DRAWHLINE (cotaValue) COLOURED(220,20,60)style(dottedline, 3)
    if show then
    DRAWTEXT(“D #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(220,20,60) anchor(right,xshift,value)
    endif
    next
    if aperturaanual <> 0 then
    cotaValue = aperturaanual
    DRAWHLINE (cotaValue) COLOURED(250,230,0) style(dottedline, 3)
    if show then
    DRAWTEXT(“AA #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(220,20,60) anchor(right,xshift,value)
    endif
    endif
    endif

    // AZUL MARINO TRIMESTRALES *******************************
    if trimestral then
    n = lastset($trimestrales)
    for cota = 0 to n do
    cotaValue = $Trimestrales[cota]
    IF cotaValue = 0 THEN
    continue
    ENDIF
    DRAWHLINE (cotaValue) COLOURED(0,0,150)style(line,5)
    if show then
    DRAWTEXT(“Q #cotaValue#”, hoffset,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,0,0)anchor(right,xshift,value)
    endif
    next
    endif

    // AZUL CLARO SEMANAL *************************************
    if semanal then
    n = lastset($Semanales)
    for cota = 0 to n do
    CotaValue = $Semanales[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    DRAWHLINE (cotaValue) COLOURED(0,190,255)style(line,3)
    if show then
    DRAWTEXT(“W #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,190,255) anchor(right,xshift,value)
    endif
    next
    endif
    if psico then
    n = lastset($Psicologicas)
    for cota = 0 to n do
    CotaValue = $Psicologicas[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    DRAWHLINE (cotaValue) COLOURED(0,190,255)style(line,3)
    if show then
    DRAWTEXT(“P #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,0,150) anchor(right,xshift,value)
    endif
    next
    endif
    if semanal then
    n = lastset($Semanales)
    for cota = 0 to n do
    CotaValue = $Semanales[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    DRAWHLINE (cotaValue) COLOURED(0,190,255)style(line,3)
    if show then
    DRAWTEXT(“W #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,190,255) anchor(right,xshift,value)
    endif
    next
    endif
    // Corto Plazo COLOR VERDE OSCURO ********************************************
    if cortoplazo then
    n = lastset($CortoPlazo)
    for cota = 0 to n do
    CotaValue = $CortoPlazo[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    nalto = $CortoPlazoAlto[cota]
    if nalto > 0 then
    DRAWHLINE (cotaValue) COLOURED(0,128,0)style(dottedline,2)
    valto = cotaValue+nalto
    DRAWHLINE (valto) COLOURED(0,128,0)style(dottedline,2)
    if show then
    DRAWTEXT(“C #cotaValue# – #valto#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,128,0) anchor(right,xshift,value)
    endif
    else
    DRAWHLINE (cotaValue) COLOURED(0,128,0)style(dottedline1,2)
    if show then
    DRAWTEXT(“C #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(0,128,0) anchor(right,xshift,value)
    endif
    endif

    next
    endif
    // Corto Plazo de segundo tipo
    if cortoplazo2 then
    n = lastset($CortoPlazo2)
    for cota = 0 to n do
    CotaValue = $CortoPlazo2[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    nalto = $CortoPlazo2Alto[cota]
    if nalto > 0 then
    DRAWHLINE (cotaValue) COLOURED(80,210,80)style(dottedline,2)
    valto = cotaValue+nalto
    DRAWHLINE (valto) COLOURED(80,210,80)style(dottedline,2)
    if show then
    DRAWTEXT(“c #cotaValue# – #valto#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(80,210,80) anchor(right,xshift,value)
    endif
    else
    DRAWHLINE (cotaValue) COLOURED(80,210,80)style(dottedline1,2)
    if show then
    DRAWTEXT(“c #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(80,210,80) anchor(right,xshift,value)
    endif
    endif

    next
    endif
    // Corto Plazo de tercertipo
    if cortoplazo3 then
    n = lastset($CortoPlazo3)
    for cota = 0 to n do
    CotaValue = $CortoPlazo3[cota]
    IF CotaValue = 0 THEN
    continue
    ENDIF
    nalto = $CortoPlazo3Alto[cota]
    if nalto > 0 then
    DRAWHLINE (cotaValue) COLOURED(128,40,0)style(dottedline,2)
    valto = cotaValue+nalto
    DRAWHLINE (valto) COLOURED(128,40,0)style(dottedline,2)
    if show then
    DRAWTEXT(“c #cotaValue# – #valto#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(128,40,0) anchor(right,xshift,value)
    endif
    else
    DRAWHLINE (cotaValue) COLOURED(128,40,0)style(dottedline1,2)
    if show then
    DRAWTEXT(“c #cotaValue#”, hoffset ,CotaValue + Voffset,SansSerif,Bold,tsize)coloured(128,40,0) anchor(right,xshift,value)
    endif
    endif

    next
    endif
    ENDIF // lastbarupdate

    RETURN undefined

    #249658

    Hi there,

    The culprit is this :

    Thus with 0 no error. Nothing shows either. 🙁

    Further debugging can be done with Graph, GraphOnPrice and Print.

    I hope this helps you ?
    Peter

    #249662

    This is it :

    #249663

    So it is easy to make the mistake to see that parameter as 1 for true and 0 for false. But it denotes the number of “last bars” to observe (calculate on).

     

    #249666

    And when you show it on the Price pane, it actually does something, but out of view. Rightclick in the right margin (1st pic) –  see the parameter setting below (at the mouse pointer – 2nd pic) to make it visible.
    The price is at 23631,50, so it isn’t completely right. 🙂

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

Create your free account now and post your request to benefit from the help of the community
Register or Login