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

Custom indicator in strategy - error onbarupdate

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

    Custom indicator in strategy - error onbarupdate

    Hello,
    I have only basic programming skills, but browsing the online manual i found a way to measure the slope angle of a indicator (EMA). Its only one row of code and when i run it on any chart it works fine, i can see the digits in the Output. However when i try to include it in a strategy (which also works fine standalone) i receive error:

    "Strategy 'GameOverTest': Error on calling 'OnBarUpdate' method on bar 16: Index was outside the bounds of the array."

    I guess this is happening, because when i run the indicator alone it will calculate and return in the Output window a lot of digits (i can presume it calculates everything from the beginnig of the chart). I dont need this, i only need the last digit. How can i achieve this?

    The indicator:

    double angle = (Math.Atan(Slope(EMA(25), 5, 0))*18000/Math.PI);
    Print (angle);

    Best regards,
    Hristo

    #2
    Hello Hristo,

    Thanks for opening the thread.

    I am noticing the same behavior on my end when calling an indicator that contains an indicator from a strategy.

    I will be looking into this further and will provide a complete answer of my findings.

    EDIT:

    Upon further investigation, it looks like the indicator being called is creating an issue because it is not setting a plot value. You can work around this issue by adding a plot and setting its value to something.

    Attached is an example strategy for demonstration.

    Thanks in advance for your patience.
    Attached Files
    Last edited by NinjaTrader_Jim; 07-06-2017, 01:30 PM.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,611 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    9 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    19 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    6 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    22 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X