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 bmartz, 03-12-2024, 06:12 AM
        4 responses
        32 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X