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

Data Series Variable

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

    Data Series Variable

    Code:
    #region Variables
    ....
    private DataSeries myDataSeries;
    private DataSeries myDataSeries2;
    private DataSeries myDataSeries3;
    ....
    
     protected override void OnBarUpdate()
            {
    
    .....
    
    myDataSeries.Set(PriorDayOHLC().PriorClose[0] -PriorDayOHLC().PriorLow[0]);
    		myDataSeries2.Set(PriorDayOHLC().PriorHigh[0] -PriorDayOHLC().PriorClose[0]);
    			
    myDataSeries3.Set(Math.Max(myDataSeries[0], myDataSeries2[0]));
    			
    						
    double MaxOffsetAvg = SMA(myDataSeries3, 3)[0];
    			
    Print(myDataSeries3[0]);
    			
    
    					
    				
    
    ....

    What my script should do.

    -Calculate yesterday's Close-Low and Close-High range
    -Take the higher value of both and calculate the 3 day moving average


    Script is compiling but no output, template of the script is running with other strategies.
    Last edited by markus1000; 10-09-2012, 01:12 PM.

    #2
    Hello Markus1000,

    Thank you for your post.

    Have you tried using the Print() method to Print out each DataSeries Class as well as the SMA?
    Is the output on the Output Window correct for each DataSeries Class and the SMA?

    I look forward to assisting you further.
    Last edited by NinjaTrader_PatrickH; 10-09-2012, 02:50 PM.

    Comment


      #3
      Originally posted by markus1000 View Post
      Code:
      #region Variables
      ....
      private DataSeries myDataSeries;
      private DataSeries myDataSeries2;
      private DataSeries myDataSeries3;
      ....
      
       protected override void OnBarUpdate()
              {
      
      .....
      
      myDataSeries.Set(PriorDayOHLC().PriorClose[0] -PriorDayOHLC().PriorLow[0]);
              myDataSeries2.Set(PriorDayOHLC().PriorHigh[0] -PriorDayOHLC().PriorClose[0]);
                  
      myDataSeries3.Set(Math.Max(myDataSeries[0], myDataSeries2[0]));
                  
                              
      double MaxOffsetAvg = SMA(myDataSeries3, 3)[0];
                  
      Print(myDataSeries3[0]);
                  
      
                          
                      
      
      ....
      What my script should do.

      -Calculate yesterday's Close-Low and Close-High range
      -Take the higher value of both and calculate the 3 day moving average


      Script is compiling but no output, template of the script is running with other strategies.
      How do you mean no output? What output are you expecting?

      Any errors on your log?

      Comment


        #4
        Originally posted by koganam View Post
        How do you mean no output? What output are you expecting?

        Any errors on your log?
        Im expecting myDataSeries3 to be printed in the output file.

        When i tried to print the other dataseries, i get messages like this

        Error on calling 'OnBarUpdate' method for strategy 'BetterBreakout/d65a7e818de943efbb6bf0bdcb61ff46': Object reference not set to an instance of an object

        Comment


          #5
          Hello markus1000,
          Have you created instance of the DataSeries
          Code:
          protected override void OnStartUp()
          {
            myDataSeries = new DataSeries(this);
            myDataSeries2 = new DataSeries(this);
            myDataSeries3 = new DataSeries(this);
          }
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Joydeep View Post
            Hello markus1000,
            Have you created instance of the DataSeries
            Code:
            protected override void OnStartUp()
            {
              myDataSeries = new DataSeries(this);
              myDataSeries2 = new DataSeries(this);
              myDataSeries3 = new DataSeries(this);
            }
            http://www.ninjatrader.com/support/h...?onstartup.htm
            ok thank you output is printing. should i put it before or after protected override void Initialize() or doesnt it matter

            Comment


              #7
              Hello markus1000,
              Its a method so you can put it anywhere you like.
              JoydeepNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Belfortbucks, Today, 09:29 PM
              0 responses
              3 views
              0 likes
              Last Post Belfortbucks  
              Started by zstheorist, Today, 07:52 PM
              0 responses
              7 views
              0 likes
              Last Post zstheorist  
              Started by pmachiraju, 11-01-2023, 04:46 AM
              8 responses
              150 views
              0 likes
              Last Post rehmans
              by rehmans
               
              Started by mattbsea, Today, 05:44 PM
              0 responses
              6 views
              0 likes
              Last Post mattbsea  
              Started by RideMe, 04-07-2024, 04:54 PM
              6 responses
              33 views
              0 likes
              Last Post RideMe
              by RideMe
               
              Working...
              X