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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,789 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    838 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,294 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X