Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Passing data from one Indicator to another

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

    Passing data from one Indicator to another

    I'm in the process of writing a test Indicator that reads data from another indicator.

    Specifically, I want to get data from Bollinger Bands and process them. In my code in the OnBarUpdate() method I can have statements of the type:

    double bollLower = Bollinger(2,20).Lower[0];
    double bollUpper = Bollinger(2,20).Upper[0];

    which will get the lower and upper Bollinger Bands for the present bar for a standard deviation of 2 and a period of 20. That's all fine and well and works.

    However, I want to get the standard deviation and period from the Bollinger Indicator that is attached to the chart together with my Indicator, rather than specifying them separately in my Indicator. If I include the statement:

    Bollinger bollinger = new Bollinger();

    at the top of my indicator class where the variables are declared, in order to create an instance of the Bollinger class, then in my OnBarUpdate() method I can include a statement like:

    Print("Period = " + bollinger.Period.ToString());

    which works and prints out the period. However, it only prints the default value of 14, regardless of how I set the period when the Bollinger Indicator is included in the chart.

    The idea is to pass the standard deviation and period from the Bollinger Indicator to my call of it in my own Indicator. This is obviously much more convenient than having to set manually the values in my indicator to the Bollinger Indicator, and would be most grateful for some advice on this.

    I am rather more familiar with Java than C#, so there is some confusion. Specifically I think of Bollinger (with a big "B") as being a class, and bollinger (with a small "b") as being an instance of the class.

    Help in getting this issue resolved would be most appreciated.

    csharp

    #2
    Hi charp, only indicator plots would be exposed / accessible per default, you can custom-expose other internal series and variables though, too - http://www.ninjatrader.com/support/f...ead.php?t=4991

    Comment


      #3
      Originally posted by csharp View Post
      I'm in the process of writing a test Indicator that reads data from another indicator.

      Specifically, I want to get data from Bollinger Bands and process them. In my code in the OnBarUpdate() method I can have statements of the type:

      double bollLower = Bollinger(2,20).Lower[0];
      double bollUpper = Bollinger(2,20).Upper[0];

      which will get the lower and upper Bollinger Bands for the present bar for a standard deviation of 2 and a period of 20. That's all fine and well and works.

      However, I want to get the standard deviation and period from the Bollinger Indicator that is attached to the chart together with my Indicator, rather than specifying them separately in my Indicator. If I include the statement:

      Bollinger bollinger = new Bollinger();

      at the top of my indicator class where the variables are declared, in order to create an instance of the Bollinger class, then in my OnBarUpdate() method I can include a statement like:

      Print("Period = " + bollinger.Period.ToString());

      which works and prints out the period. However, it only prints the default value of 14, regardless of how I set the period when the Bollinger Indicator is included in the chart.

      The idea is to pass the standard deviation and period from the Bollinger Indicator to my call of it in my own Indicator. This is obviously much more convenient than having to set manually the values in my indicator to the Bollinger Indicator, and would be most grateful for some advice on this.

      I am rather more familiar with Java than C#, so there is some confusion. Specifically I think of Bollinger (with a big "B") as being a class, and bollinger (with a small "b") as being an instance of the class.

      Help in getting this issue resolved would be most appreciated.

      csharp
      With your line, you created the bollinger object with default parameters. If you want to change any of the public properties, you have to use the standard OOP syntax.

      Code:
      bollinger.Period = whatever_int;
      Last edited by koganam; 09-14-2011, 11:04 PM.

      Comment


        #4
        Many thanks for the two replies, which are noted, and will be taken account of.

        Christopher Sharp = csharp

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        574 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        332 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
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X