Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

accessing indicators

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

    accessing indicators

    I am trying to access various indicators values at various bars but having trouble.

    protected override void OnBarUpdate()

    double x = SuperTrend(14,2.618)[0];


    if (
    SuperTrend(14,2.618)[0] < Close[0] <-- This Works
    x < Close[0] <-- This Works
    x[1] < Close[0] <--- This does NOT work
    )

    Question: How do I access various bars back in brackets once the indicator is named as above?

    Another example of what I want to do:

    x[1] > x[5]

    thanks

    #2
    Originally posted by velocity View Post
    I am trying to access various indicators values at various bars but having trouble.

    protected override void OnBarUpdate()

    double x = SuperTrend(14,2.618)[0];


    if (
    SuperTrend(14,2.618)[0] < Close[0] <-- This Works
    x < Close[0] <-- This Works
    x[1] < Close[0] <--- This does NOT work
    )

    Question: How do I access various bars back in brackets once the indicator is named as above?

    Another example of what I want to do:

    x[1] > x[5]

    thanks
    In order to do that x must be DataSeries and you have it as double

    Comment


      #3
      Thanks for responding.

      I changed it to DataSeries and did the following:

      public class Triggers : Indicator
      {
      #region Variables
      private DataSeries myDataSeries;
      #endregion

      protected override void OnBarUpdate()
      {
      myDataSeries = new DataSeries(SuperTrend(14,2.618));

      if (
      SuperTrend(14,2.618)[0] < Close[0] <--- This Works

      myDataSeries[0] < Close[0] <-- This does not work


      Any ideas?
      Last edited by velocity; 02-21-2009, 06:23 PM.

      Comment


        #4
        This is not how you define a dataseries. Try this:

        private DataSeries x; <- goes in Variables area

        x = new DataSeries(this); <- goes after added plots in Initialize() area

        x.Set(SuperTrend(14,2.618)[0]); <-- in code after OnBarUpdate()

        x[1] < Close[0]
        eDanny
        NinjaTrader Ecosystem Vendor - Integrity Traders

        Comment


          #5
          I must be doing something wrong. Lets say i have the following:

          private DataSeries cci_data; <-- in #region Variables

          cci_data = new DataSeries(this); <-- in protected override void Initialize()

          cci_data.Set(CCI(14)[0]); <-- in protected override void OnBarUpdate()

          if(

          cci_data[0] > 100 <-- this works
          cci_data[1] > 100 <-- this does NOT work

          Where am I going wrong?

          Comment


            #6
            Hello,

            Sorry to jump in here but this may help.

            It should work, unless there is some other issue causing it not to work. You may want to paste in all of the code that is affected so we can test it for you and help you further.

            Remember this [1] accesses a value one bar back, not the value that was stored previously. In other words, there is only one value stored per bar for each DataSeries.

            Sorry if you already know this...
            DenNinjaTrader Customer Service

            Comment


              #7
              thank you Ben, I think I got it. I inserted

              if (CurrentBar < 10)
              return;

              and now if I want to go back up to 10 bars i can do up to cci_data[10] Right?

              with out inserting above code I could only access current bar. Right?
              Last edited by velocity; 02-22-2009, 11:25 AM.

              Comment


                #8
                Hello,

                Yes, you can now reference up to 10 bars back.
                DenNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Blairski, Yesterday, 09:19 AM
                2 responses
                9 views
                0 likes
                Last Post Blairski  
                Started by tonynt, Today, 09:33 AM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by minotti1, Today, 08:31 AM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_Jim  
                Started by SmartArtsStudio, 05-15-2021, 10:46 AM
                1 response
                15 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Airwave, Today, 06:02 AM
                2 responses
                23 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X