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:	216
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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        156 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        90 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        140 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        130 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X