Fallo en sumatorio/contador

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #237894 quote
    FeroxFerox
    Participant
    New

    Hola:

    me estoy volviendo loco con una cuestión muy sencilla.
    Prestar atención en el sumatorio de valores del RSI de este código:

    indi = rsi[14](close)
    sum = sum + indi
    //sum = sum + 1
    
    if barindex = 500 then
    drawtext(sum,barindex,75,SansSerif,Bold,12)coloured(0,0,255)
    endif
    
    
    RETURN 50 as "50%", indi AS "indi", sum AS "sum"

    Pues, al menos a mí, no me sale nada en el gráfico.
    El resultado del código de texto es “n/d” (desconocido).

    Sin embargo, si que funciona sin problema si se sustituye por esta línea de código:
    sum = sum + 1

    ¿Qué está pasando?

    #237899 quote
    JSJS
    Participant
    Master

    Hola,

    El “BarIndex” debe ser mayor o igual que el “período RSI”…

    If BarIndex>13 then

    Indi=rsi[14](close)

    Sum=sum+indi

    EndIf

    Iván González thanked this post
    Scherm­afbeelding-2024-09-21-om-11.48.20.png Scherm­afbeelding-2024-09-21-om-11.48.20.png
    #237901 quote
    ZigoZigo
    Participant
    Master
    Sustitúyase la linea 2 por : linea 2 / summation[n](indi)/n
    #237903 quote
    ZigoZigo
    Participant
    Master
    Gráfico
    #237906 quote
    FeroxFerox
    Participant
    New
    Gracias por las respuestas 😀
    Hola, El “BarIndex” debe ser mayor o igual que el “período RSI”… If BarIndex>13 then Indi=rsi[14](close) Sum=sum+indi EndIf
    @JS, gracias a tu código he podido deducir el problema que es el siguiente: Si en el cálculo antes descrito (sum = sum + x), PRT le atribuye a sum un valor indefinido (n/d), que proviene de x en este caso , el resultado del cálculo ya siempre será n/d, aunque más adelante x ya tenga un valor conocido. Esto se puede entender mejor con este código:
    If BarIndex = 10 then
    x = undefined
    else
    x = 1
    endif
    
    sum2 = sum2 + x
    
    RETURN sum2 as "sum2"
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Fallo en sumatorio/contador


ProBuilder: Indicadores y Herramientas

New Reply
Author
author-avatar
Ferox @ferox Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by FeroxFerox
1 year, 12 months ago.

Topic Details
Forum: ProBuilder: Indicadores y Herramientas
Language: Spanish
Started: 09/20/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...