Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need Help with Bollinger Indicator

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

    Need Help with Bollinger Indicator

    I'm getting an error at this part of the code:

    protected override void OnBarUpdate()
    {
    if (CurrentBar > Period)
    {
    //bhigh = MAX(High, 150)[0];


    bandwidth = (Bollinger(Deviation,Period).Upper[0] - Bollinger(Deviation,Period).Lower[0])/SMA(20)[0];
    bulge = MAX(bandwidth(0), 150)[0];

    Plot0[0] = (bandwidth/bulge)*100;


    }
    else {
    Plot0[0] = 0;
    }
    }

    The error is bandwidth is a field but used as a method. Any ideas?

    #2
    Hello omermirza,

    That would be this line:
    Code:
    bulge = MAX(bandwidth(0), 150)[0];
    You likely need:
    Code:
    bulge = MAX(bandwidth, 150)[0];

    Comment


      #3
      That's what I had before but I do get the attached errors if I write it like that. Click image for larger version

Name:	error2.PNG
Views:	213
Size:	11.0 KB
ID:	1174599
      Variables are defined as follows:

      private int bulgelength=150;
      private double bulge;
      private double bandwidth;
      private double bhigh;

      Comment


        #4
        Hello omermirza,

        MaX takes a series, you would need to make a series<double> and not a double.

        The code you are getting an error with is trying to get the max of 1 data point named bandwidth.

        You can find samples of using a series here: https://ninjatrader.com/support/help...t8/seriest.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        569 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X