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

Two issues building indicator,

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

    Two issues building indicator,

    In an effort to consolidate my custom and some other MA indicators, I'm trying to build one that makes it easier to select. I've run into 2 problems, I cannot call on the indicator I have in my custom folder and I cannot get bollinger or keltner bands to display, only envelopes work.

    Right now, only Line 90 Column 60 is displaying a compile error, that's the indicator in the custom folder, the others are disabled. When I select Bollinger or Keltner, I have no output to the chart.

    I don't need it fixed but If somebody could explain what I'm missing so I can learn a little more, I'd appreciate it.
    Attached Files

    #2
    Here is what I see at a quick glance.

    Bollinger suffers because stdDev is never assigned a value.

    Keltner suffers because on the very first bar of the chart,
    accessing the previous bar High[1] and Low[1] is an error.

    -=o=-

    The very first bar has no previous bar, that's why you'll see
    guard code (usually at the top of OnBarUpdate) like,

    Code:
    if (CurrentBar < 1)
        return;
    Why does this code work?
    Because the very first bar has CurrentBar value of 0, this
    guard says only process when you have at least one bar on
    the chart, which is what your code needs to access the
    previous bar.

    How did I know to use '1' in 'CurrentBar < 1'?
    Because '1' was the highest index your code ever used when
    accessing series values of prior bars.
    Last edited by bltdavid; 09-17-2023, 07:03 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,983 views
    3 likes
    Last Post jhudas88  
    Working...
    X