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

IDATASERIES ...how use it

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

    IDATASERIES ...how use it

    private IDataSeries demo;

    protectedoverridevoid Initialize()

    {
    Indicator = new DataSeries(this);
    Indicator = RSI(14,1);
    }

    protectedoverridevoid OnBarUpdate()

    Print(Indicator[0]);

    OUTPUT :
    0
    0

    0
    0



    there is an error....it give me always 0



    Is correct o there is error...?

    thanks you


    Last edited by turbofib; 02-27-2014, 06:59 AM.

    #2
    Turbifib,

    This is expected as the IDataSeries was not meant to be written for this kind of use.

    IDataSeries boils down to being able to create a method that can in turn use the IDataSeries as a parameter.

    For what you are trying to do above I would try this sample snippet -
    Code:
    private DataSeries demo;
    
    protected override void Initialize()
    
    {
          demo = new DataSeries(this);
    }
    
    protected override void OnBarUpdate()
    {
          demo.Set(RSI(14,1)[0]);
          Print(demo[0]);
    }
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I know that code already...


      I wanted to use an example as formulated below using idataseries

      Comment


        #4
        Turbofib,

        Code:
        protected override void OnBarUpdate()
                {
        		Print(RsiReturn(Close));
        			
                }
        		
        private double RsiReturn(IDataSeries pricedata)
        	{
        		return RSI(14,1)[0];
        	}
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          i try it...but OUTPUT is the same

          0
          0
          0
          0
          0
          0

          Comment


            #6
            What does your updated script look like?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              now is..ok!! thanks you...

              but if I wanted to write past 5 boxes ..
              How should I do?

              ex:


              Print(RsiReturn(Close)[5]);

              it give me error: is not possible to indicize with[] an expressione double type

              Comment


                #8
                You will need to change the return in order for that to work

                return RSI(14,1)[5];
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  I asked about IDdataSeries because I need to store a indicator ... and access to past values without incurring the limitation of the maximum bars look back 256 (not setting it to infinity) ...

                  If i write the following code :

                  private DataSeries indicator;

                  protectedoverridevoid Initialize()
                  {
                  Indicator = new DataSeries(this);
                  Indicator = RSI(14,1);
                  }
                  protectedoverridevoid OnBarUpdate()
                  Print(Indicator[300]);==========> it not correct because max bar back =256

                  How do I get around this?

                  (in some indicators I 've see Idataseries use for solve problem .. but did not work properly)

                  Comment


                    #10
                    Turbofib,

                    If you are going to be using more the 256 you will need to use the MaximumBarsLookBack.Infinite.
                    There is no other way around this, just ensure that you limit your amount of days to load to the minimum that you want.
                    Cal H.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by turbofib View Post
                      I asked about IDdataSeries because I need to store a indicator ... and access to past values without incurring the limitation of the maximum bars look back 256 (not setting it to infinity) ...

                      If i write the following code :

                      private DataSeries indicator;

                      protectedoverridevoid Initialize()
                      {
                      Indicator = new DataSeries(this);
                      Indicator = RSI(14,1);
                      }
                      protectedoverridevoid OnBarUpdate()
                      Print(Indicator[300]);==========> it not correct because max bar back =256

                      How do I get around this?

                      (in some indicators I 've see Idataseries use for solve problem .. but did not work properly)
                      That is because you have not quite clarified your idea. What you want to do is to use a named instance of an indicator, in which case your code has many things that are not kosher.

                      Try this instead:
                      Code:
                      private RSI TurboFibIndicator;
                      
                      protected override void Initialize()
                      {
                      TurboFibIndicator = RSI(14,1);
                      }
                      You can now access your named instance to do whatever you want, such as, using your example:
                      Code:
                      protected override void OnBarUpdate()
                      Print(TurboFibIndicator[300]);

                      Comment


                        #12
                        i can't use
                        private RSI TurboFibIndicator;

                        because i must use :
                        public
                        enum typedemo
                        {
                        MACD,
                        RSI,
                        ..
                        ..
                        }
                        switch (Method) {
                        case typedemo.RSI:
                        LinkRSI();
                        Indicator = RSI(Period,1); =======> i'm interested to this..stored value
                        break;


                        I want to Plot a point in the indicator :

                        Ex.:

                        Plot a point on RSI...350 bar ago

                        Error:

                        Error on calling 'OnBarUpdate' method for indicator 'GIL' on bar 0: barsAgo needed to be between 0 and 255 but was 350






                        Last edited by turbofib; 02-27-2014, 02:41 PM.

                        Comment


                          #13
                          Originally posted by turbofib View Post
                          i can't use
                          private RSI TurboFibIndicator;

                          because i must use :
                          public
                          enum typedemo
                          {
                          MACD,
                          RSI,
                          ..
                          ..
                          }
                          switch (Method) {
                          case typedemo.RSI:
                          LinkRSI();
                          Indicator = RSI(Period,1); =======> i'm interested to this..stored value
                          break;


                          I want to Plot a point in the indicator :

                          Ex.:

                          Plot a point on RSI...350 bar ago

                          Error:

                          Error on calling 'OnBarUpdate' method for indicator 'GIL' on bar 0: barsAgo needed to be between 0 and 255 but was 350






                          Your enum has nothing to do with how to use a datastore to manipulate code. Your enum is supposedly a selector: the TurboFibIndicator object is a class.

                          Comment


                            #14
                            Ok .... I try to do as you say

                            But...i ask you.......is not proper use DataSeries?
                            Last edited by turbofib; 02-27-2014, 03:00 PM.

                            Comment


                              #15
                              Originally posted by turbofib View Post
                              Ok .... I try to do as you say

                              But...i ask you.......is not proper use DataSeries?
                              I am using an IDataSeries object: TurboFibIndicator is a named instance of the RSI.If you need to branch to different ones, then declare multiple indicators, each of the correct type and use them. in your branches.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ageeholdings, Today, 07:43 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post ageeholdings  
                              Started by pibrew, Today, 06:37 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post pibrew
                              by pibrew
                               
                              Started by rbeckmann05, Yesterday, 06:48 PM
                              1 response
                              14 views
                              0 likes
                              Last Post bltdavid  
                              Started by llanqui, Today, 03:53 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post llanqui
                              by llanqui
                               
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post burtoninlondon  
                              Working...
                              X