Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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.
      JimNinjaTrader Customer Service

      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 ageeholdings, Today, 07:43 AM
        0 responses
        7 views
        0 likes
        Last Post ageeholdings  
        Started by pibrew, Today, 06:37 AM
        0 responses
        4 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Started by llanqui, Today, 03:53 AM
        0 responses
        6 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        12 views
        0 likes
        Last Post burtoninlondon  
        Working...
        X