• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

dataSeries pointer or mirror

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

    dataSeries pointer or mirror

    EMA(), Falling(), Rising(), and many other useful functions require a DataSeries as argument. My indicator allows the user to select open, high, low, or close to use in all price calcs. I would like to be able to use a pointer to hold the current selection and just use the pointer everywhere the price is needed. Is something like this possible? Currently I use switch case statements everywhere I need to pass the price DataSeries as argument.

    #2
    Hello bernie_c,

    Thank you for your post.

    I would suggest the same item, pass the input selected to the data series and use that as the Input.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      I wasn't very clear. Up until now all my calculations have been on Close.

      Code:
      for( i=0; i < kGups_total; i++)
      {
      	Values[i].Set( EMA( Close, gup_periods[i] )[0] );
      }
      I do other things with Close in the code as well. I am changing things to be more generic. For example, The user will select from a menu in the dialog:

      Code:
      [Description("")]
      [GridCategory("Parameters -- General")]
      [Gui.Design.DisplayName ("100 - Price based on:")]
      public eCalc_type2 Calc_enum
      {
           get { return calc_enum; }
           set { calc_enum = value; }
      }
      
      public enum eCalc_type2
      {
      	Open,
      	Close,
      	High,
      	Low,
      }
      I don't want to use if() or switch() statements everywhere I currently use Close. For example, the first code snippet above would look like this:

      Code:
      for( i=0; i < kGups_total; i++)
      {
      	switch( calc_enum )
      	{
      		case eCalc_type2.Open:	Values[i].Set( EMA( Open, 	gup_periods[i] )[0] );	break;
      		case eCalc_type2.Close:	Values[i].Set( EMA( Close, gup_periods[i] )[0] );	break;
      		case eCalc_type2.High:	Values[i].Set( EMA( High, 	gup_periods[i] )[0] );	break;
      		case eCalc_type2.Low:	Values[i].Set( EMA( Low, 	gup_periods[i] )[0] );	break;
      	}
      }
      I would have to do something like this in about 7 places in my code. It would be a lot cleaner if when the user selected a different price type I could set a DataSeries pointer to the desired OCLH DataSeries. Then I would simply pass the pointer to EMA(), etc.. I doubt if this can be done as simply as I am illustrating it. This is how I would do this in C. I am just illustrating it this way to get my point across. How is this sort of thing done in NinjaScript?

      Comment


        #4
        Hello bernie_c,

        Just run the case and switch once in Intialize() and set the DataSeries as the desired input.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          set the DataSeries as the desired input
          So, are you saying that I can have a DataSeries pointer? If so, what would this look like?

          Comment


            #6
            Hello bernie_c,

            Thank you for your response.

            My mistake as we cannot set the DataSeries values in Initialize(). You would need to instead check the case and switch in the OnBarUpdate() and place the full code for each choose in each switch much like the SampleUniversalMovingAverage example: http://www.ninjatrader.com/support/f...ead.php?t=3420
            Patrick H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ct, Today, 01:57 PM
            0 responses
            5 views
            0 likes
            Last Post ct
            by ct
             
            Started by 7robert, Today, 01:13 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by Newtrader101, Today, 12:52 PM
            2 responses
            6 views
            0 likes
            Last Post Newtrader101  
            Started by 7robert, Today, 12:23 PM
            3 responses
            12 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Started by brownsfan019, Today, 12:52 PM
            3 responses
            8 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Working...
            X