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

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
    BertrandNinjaTrader Customer Service

    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 FishTrade, Today, 03:42 PM
        0 responses
        1 view
        0 likes
        Last Post FishTrade  
        Started by Richozzy38, Today, 01:06 PM
        3 responses
        14 views
        0 likes
        Last Post Richozzy38  
        Started by ttrader23, Today, 09:04 AM
        2 responses
        12 views
        0 likes
        Last Post ttrader23  
        Started by geotrades1, Today, 07:54 AM
        10 responses
        26 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by ninza33, Yesterday, 12:31 PM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Working...
        X