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

Overflow Error

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

    Overflow Error

    Hi Support...

    Since last week I am trying to develop a Predictive Indicator that can be use for 2 directional break-outs. This is what I am trying to do.

    1: First I will try to revert back from MACD formula to get the Current Close. To achieve this I used the following statement in the OnBarUpdate Method.

    Upper.Set((MACD(Fast,Slow,Smooth)[0] - (1 - (2/(1 + Fast)))*EMA(Fast)[1] + (1 - (2/(1 + Slow)))*EMA(Slow)[1])/((2/(1 + Fast)) - (2/(1 + Slow))));

    Fast, Slow and Smooth are Input Variables defined under Variables
    EMA(Fast)[1], EMA(Slow)[1] are previous bar EMA's for the given period.
    MACD(Fast,Slow,Smooth)[0] is current bar MACD for the given inputs.

    Upper must plot the Current Bar Close and this is what I am expecting it to do as I extracted the above formula from MACD formula working in the reverse dierction.

    This is my first step to see if it can plot Current Close and from thereon I am planning to develop it further to give break-out signals.

    I compiled this indicator and it did not give me any error.

    So far so good.

    However when I am trying to plot it on the chart, I am not getting anything.

    The scale sets to MACD scale ie; in the range of -2 to +2 on the y-axis. If it has to plot the Close[0] then this should not be the case .

    Log file show the error stating:

    Error on plotting indicator MACDUpper. Please check the 'Plot' method. Overflow error.

    I tried going through Help files but could not get anything in this context and hence I am asking for help from support to assist me in getting this.

    Your kind support is appreciated as usual.

    Thanks & best regards,
    Yusuf SHAIKH

    #2
    Maybe this helps

    Hi Yusuf,

    I had a similar error here.

    First I have overridden the plot method to find the bar where the error happens:

    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
    {
    try {
    base.Plot(graphics,bounds,min,max);
    } catch (Exception ex)
    {
    Print(Time[0].ToString() +
    CurrentBar.ToString() +
    ex.ToString());
    }

    }

    With this I found out that I set a infinite value and solved this with:

    if ( ! ( double.IsInfinity(myValue) || double.IsNaN(myValue) ) ) {
    MyPlot.Set(myValue);

    Comment


      #3
      Hi,

      That's a pretty big equation to stare at.

      Personally would try to breakdown the equation into sections.

      Make EMA Fast, EMA Slow, and MACD portions their own equations.

      Use the PRINT output screen to confirm each sub equation's output values.

      With each section now defined and tested, Rebuild a simplified final equation with the new terms for each sub equation defined.

      Test this with the output screen as well.

      Good Luck,

      RJay
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        Thanks...

        Hi Michael, Hello RJay...

        Many thanks for your kind replies. Actually I just cannot sit untill the issue is resolved. Thanks for all your time and advice. I actually broke up the equation and could manage to find out the problem. It was due to very small denominator value tending to making the ratio closer to infinity and thereby giving overflow error, though the equation was not incorrect. So I decided to multiply the numerator bracket with the reciprocal of denominator rather than dividing it by a very smaller number. this resolved the issue though I was able to figure it out only by step by step evaluation for how the equation responded by isolating some part of the equation each time. So guys thanks once again for your kind support. Maybe my experience will help someone to address such issues. I am going to test this method for atleast 15 days and then post it in the indicator section if it attracts some use in such volatile market conditions.

        Thanks & best regards,
        Yusuf SHAIKH

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,279 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        5 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X