Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error OnCalculateMinMax

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Error OnCalculateMinMax

    Hello. I'm developping a indicator and with some low periods (input variable) I obtain the next message:

    Indicator 'RatioEficiencia': Error on calling 'OnCalculateMinMax' method on bar 0: The calculation results in unrenderable values.

    and the indicator don't plot anything. Could you help me, please?

    I attach the .cs file but the code is:

    protected override void OnBarUpdate()
    {
    if (CurrentBar < Periodo)
    return;

    velocidad = Math.Abs(Input[0]-Input[Periodo]);

    volatilidad = 0;
    for (int i=0; i<Periodo; i++)
    {
    volatilidad += Math.Abs(Input[i]-Input[i+1]);
    Print(i);
    }

    ratioEficiencia = velocidad / volatilidad;

    Value[0] = ratioEficiencia;
    MediaRatioEficiencia[0] = SMA(Value, Periodo)[0];
    }

    Thank you very much
    Attached Files
    Last edited by alibanez; 09-19-2017, 02:37 AM.

    #2
    Hello alibanez,

    Thanks for opening the thread.

    It looks like the issue is coming from using a plot as the input series for the SMA. I'm checking with my other colleagues to get you further input and to get a better understanding of why this is not working.

    Thanks in advance for your patience.

    Comment


      #3
      Hello alibanez,

      We seem to be having trouble reproducing this issue today.

      I suspect that the issue had to do with a divide by zero issue where a calculated value was produced using a demonstrator of 0 and then used as input for the Plot. As of now I do not have a data set that can reproduce this issue.

      If you are continuing to experience this issue, I suggest to add checks to make sure any denominators are not 0, and to assign another value if one is.

      If you are able to reproduce this error after adding the aforementioned checks, please write back with the updated script and a specific data series we can use to reproduce on our end.

      I look forward to being of further assistance.

      Comment


        #4
        Its correct. It was a division by zero. The solution in black letters:

        protected override void OnBarUpdate()
        {
        if (CurrentBar < Periodo)
        return;

        velocidad = Math.Abs(Input[0]-Input[Periodo]);

        volatilidad = 0;
        for (int i=0; i<Periodo; i++)
        {
        volatilidad += Math.Abs(Input[i]-Input[i+1]);
        }

        if (volatilidad==0)
        volatilidad=1;



        ratioEficiencia = velocidad / volatilidad;

        Value[0] = ratioEficiencia;
        MediaRatioEficiencia[0] = SMA(Value, 14)[0];
        }

        Thank you very much

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        72 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        152 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X