• 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

Historical keyword in Replay mode

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

    #16
    Hello poseidon_sthlm,

    Correct, you code is quite simple and easy to follow. No real concerns on how you are detailing this matter.

    If the Caller Indicator calls the Callee and the Callee has yet to update (OnBarUpdate()), then it's value is the "previous" value.
    Patrick H.NinjaTrader Customer Service

    Comment


      #17
      Ok, I'll try once again to explain my point. Please also read the print statments in post #11 that illustrates what I try to show you.

      This is the expected behaviour of the Historical property:
      1. Historical = true in replay mode as well as in real time mode when NT does recalculate indicators and strategies for the historical data on the chart before the real time data starts.

      2. Historical = false on the phantom bar that is injected by NT between historical data and first tick of real time data.

      3. Historical = false on real time data.

      The Historical property for any referenced indicator must be of the same value as the calling indicator for every tick. Else there is some unexpected problem.

      In my example in post #11 I show a general situation for the phantom bar where the Historical property of the Caller and the Calle have different values. This can not be correct. The question is if this inconsistency depens on my code or on NT:s code.

      The situation where the Historical property of the Caller and the Calle differs occurs although the Caller calls the Callee to update. The property Historical flips to False for the Caller but stays TRUE for the Calle on the phantom bar. This is inconsistent behaviour.

      After a lot of trouble shooting I found that if I skip the update call to the Calle on just the phantom bar, (but still call the Calle to update on every other bar) the Historical property for the Calle also flips to False just like the Caller. So this is my work around to this problem.

      The work around makes the situation with different values for the Caller and the Callee where the Calle is updated on every bar even more suspect.

      Questions:
      1. Why doesn't the Historical property for a referenced indicator flip to FALSE on the phantom bar although I do update the Calle on every bar?

      2. How come that the Historical property for the Calle suddenly flips to FALSE on the phantom bar (as expected), when I skip the update call from the Caller only for the phantom bar?

      3. Is it possible that an update call from the caller on the phantom bar somehow prevents the Historical property for the Callee to flip to FALSE? If so, why? Is this excpected behaviour?

      (It is important that the Historical property takes the same value for every referenced indicator as the calling indicator or strategy on the phantom bar since this affects indicator values at the start of a live session. An intraday trader that trades the E-mini RTH session usually reloads his NT chart before the sesison starts to update indicator history. If the Historical property for referenced indicators is TRUE on the phantom bar when the live session starts, then this may distort his indicator value for the entire session.)

      /Poseidon_Sthlm
      Last edited by poseidon_sthlm; 03-18-2015, 05:43 AM.

      Comment


        #18
        Hello poseidon_sthlm,

        Thank you for your detailed response here.

        I beleive we are trying to tell each other the same thing here so I will try to be as candid as possible.

        I tested your provided code and saw what you were detailing on my end. I then created my own simple test for this and found the same results.
        Once I placed Callee.Update() before I actually called the indicator, the value produced was for the current bar and was accurate.

        To answer your questions:
        1. You are setting the value to a double, this value is the previous value as Update() was not called.
        2. This occurs as you are not calling the value before the indicator has updated.
        3. This is occurring as you are not actually updating the indicator you are just calling it's value.


        This is expected behavior, if the indicator has not updated on the current bar and/or tick and we call it we should expect the previous value. This is why Update() is used, but I advised to call Update() before you call the indicator where as you are setting the indicator to a double but never using Update() to update the indicator.
        Originally posted by NinjaTrader_PatrickH View Post
        Hello poseidon_sthlm,

        Thank you for your response.

        If you force an update to the callee before printing the values in the caller, it should correct this.
        Code:
        TestHistoricalCallee().Update();
        Patrick H.NinjaTrader Customer Service

        Comment


          #19
          Thanks for your answer and your patience. I apologize for the confusion. I thought that calling the Calle with a double is equivalent with an update call. My misstake.

          Can you please show me where I would place the update call in my example code?
          I have tested this new Caller (with the same Callee as below), but I still receive the inconsistent values for the Historical property.

          Code:
           public class TestHistoricalCaller2 : Indicator
              {	
          
          	/// Variables
          	TestHistoricalCallee myTestHistoricalCallee;
          		
          	protected override void OnStartUp()
                  {
          		myTestHistoricalCallee = TestHistoricalCallee();	/// Instantiate Indicator
          	}
          		
          		
                  protected override void OnBarUpdate()
                  {		
          			if ( FirstTickOfBar )
          			{
          				
          				Print("");
          				Print("TestHistoricalCaller2:");
          				Print("*******************************************");
          				Print("CurrentBar: " + CurrentBar);
          				Print("CalculateOnBarClose: " + CalculateOnBarClose);
          				Print("Historical: " + Historical);
          
          				
          				myTestHistoricalCallee.Update();	/// Update calle on every bar
          				double v1 = myTestHistoricalCallee[0];
          
          				
          				Print("");
          			}	
                  }
              }

          Comment


            #20
            Hello poseidon_sthlm,

            Thank you for your response.

            In your TestHistoircalCaller[1] script, set the Update() as follows:
            Code:
             protected override void OnBarUpdate()
                    {		
            			if ( FirstTickOfBar )
            			{
            				TestHistoricalCallee().Update();
            				Print("");
            Patrick H.NinjaTrader Customer Service

            Comment


              #21
              Hello!

              Thanks for your propmt reply.

              I have now tried different alternatives with the .Update() method, but it doesn't affect the issue with the Historical property for me. (Alternative 3, 4 and 5 in the code below).

              My test is done in Replay mode on the ES RTH session where real time data starts on the FTOB of the first bar in session (and the phantome bar is thus injected between the end of the prior session and the start of the current session.)

              Do I place the Update() incorrectly in the code below? If not, could you add your indicator where you succesfully tested the Historical property, so I could test it on my side?

              TestHistoricalCallee:
              ----------------------------------------------
              CurrentBar: 80
              CalculateOnBarClose: False
              Historical: True

              TestHistoricalCaller:
              *******************************************
              CurrentBar: 80
              CalculateOnBarClose: False
              Historical: True


              TestHistoricalCallee:
              ----------------------------------------------
              CurrentBar: 81
              CalculateOnBarClose: False
              Historical: True

              TestHistoricalCaller:
              *******************************************
              CurrentBar: 81
              CalculateOnBarClose: False
              Historical: False

              Code:
              public class TestHistoricalCaller : Indicator
                  {	
              
              		/// Variables
              		int alt				        = 1;
              		bool historicalCurrentBar	        = true;
              		bool historicalPrevBar		= true;
              		
              		TestHistoricalCallee myTestHistoricalCallee;
              
              
              		protected override void OnStartUp()
                             {
              			myTestHistoricalCallee = TestHistoricalCallee();	/// Instantiate Indicator
              		}
              		
              		
                      protected override void OnBarUpdate()
                      {		
              			if ( FirstTickOfBar )
              			{
              				switch(alt)
              				{
              					case 1:	/// Update calle on every bar with a double
              						double v1 = myTestHistoricalCallee[0];
              						break;
              						
              					case 2:	/// Don't update calle on the injected phantom bar 
              							/// (This is my work around)
              						historicalPrevBar 		= historicalCurrentBar;
              						historicalCurrentBar 	= Historical;
              						
              						if ( historicalPrevBar == historicalCurrentBar )
              						{
              							double v2 = myTestHistoricalCallee[0];
              						}
              						break;
              						
              					case 3:	/// Update Calle with .Update() insteda of calling a double
              							myTestHistoricalCallee.Update();
              						break;
              						
              					case 4:	/// Update Calle with .Update() insteda of calling a double
              							TestHistoricalCallee().Update();
              						break;
              						
              					case 5:	/// Update Calle with .Update() and then call the double
              							myTestHistoricalCallee.Update();
              							double v2 = myTestHistoricalCallee[0];
              						break;			
              				}
              				
              				Print("");
              				Print("TestHistoricalCaller:");
              				Print("*******************************************");
              				Print("CurrentBar: " + CurrentBar);
              				Print("CalculateOnBarClose: " + CalculateOnBarClose);
              				Print("Historical: " + Historical);
              
              			}	
                      }

              Comment


                #22
                Hello poseidon_sthlm,

                Thank you for your update.

                Place the Update right at the beginning of OnBarUpdate():
                Code:
                        protected override void OnBarUpdate()
                        {
                        	TestHistoricalCallee().Update();
                Patrick H.NinjaTrader Customer Service

                Comment


                  #23
                  Hello again!
                  I have now tried to update with
                  Code:
                  TestHistoricalCallee().Update();
                  as well as
                  Code:
                  myTestHistoricalCallee.Update();
                  at the beginning of OnBarUpdate() before the FTOB section, but I still get the inconsitent result for the Historical property.

                  My test is done in Replay mode on the ES RTH session where real time data starts on the FTOB of the first bar in session (and the phantome bar is thus injected between the end of the prior session and the start of the current session.) Have you tested this on your side?


                  Regards,
                  Poseidon_Sthlm
                  Last edited by poseidon_sthlm; 03-19-2015, 02:59 AM.

                  Comment


                    #24
                    Hello poseidon_sthlm,

                    Thank you for your response.

                    Market Replay would treat the called indicator as historical, and the flag for Historical will not be False until one bar after the current bar or one tick after the first tick of the bar. Unfortunately, there is no way around this in replay, in live testing you should not see this though.
                    Patrick H.NinjaTrader Customer Service

                    Comment


                      #25
                      Thanks for the clarification.

                      May I report this issue with the inconsitent Historical property value in Market Replay as a request for improvement in NT8? Could you give me a tracking number?

                      Best Regards,
                      Poseidon_sthlm

                      Comment


                        #26
                        Hello poseidon_sthlm,

                        Thank you for your response.

                        I can confirm this is not the case in NinjaTrader 8 for playback of data.
                        Patrick H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by rontronimous, Today, 06:12 PM
                        1 response
                        3 views
                        0 likes
                        Last Post NinjaTrader_ShawnB  
                        Started by Vinhasa, Today, 03:15 PM
                        3 responses
                        13 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by 1001111, Today, 03:03 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Tyler  
                        Started by Seedbird, Today, 03:06 PM
                        1 response
                        13 views
                        0 likes
                        Last Post NinjaTrader_BrendanC  
                        Started by mtamaku, Today, 02:46 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_Kate  
                        Working...
                        X