Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    636 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    366 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    107 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    568 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    571 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X