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

Historical vs Real time

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

    Historical vs Real time

    Hi,

    I am working on an indicator that detects a certain pattern and then draws a dot below the bar where the pattern was confirmed.

    Because the pattern can easily start in historical time and complete in real time I need to account for the crossover. In trying to work through that logic I have Print statements at various junctures.

    I am testing this in replay mode with volume bars (which may account for what I see) I noticed NinjaTrader appears to recognize the last full bar as the first real time bar.


    if (Historical == true)
    Print(
    "Historical bar " + Time[0]);
    else
    Print("Real time bar " + Time[0]);

    On the first real time bar, print Time[0] and I get the close time of the last bar; all the historical bars show the right time. I am aligning this with the replay clock and using the session break in the futues i.e. I am starting the replay on a Sunday at 1801 (Eastern) and I am getting 1659 (close of the previous bar) on the previous Friday as the first real time bar.

    Is this because on the first tick of the bar in real time Time[0] is the last tick of the previous bar? I can understand that under most conditions but on a session break that doesn't seem correct.

    I don't particularly care how NinjaTrader decided to handle this, I only want to verify I don't have an issue in my code.

    As an aside, I have found having a bars ago offset that is set based on the bar's historical status and then added to every bars ago index - Close[2 + barsAgoOffset] works really well. For historical bars the offset is 0 and for real time bars it is 1. When used in conjunction with FirstTickOfBar the crossover is handled correctly.


    Any suggestions will be appreciated.

    Best Regards,
    Scott

    #2
    Hello,

    Thanks for your forum post.

    We worked to keep the crossover from historical to live as seamless as possible.

    You should not run into any issues here.

    Yes your assumption is correct here if I understand you currently. You can verify this by printing the bar numbers.

    Print CurrentBar along with Time[0].


    Let me know if I can be of further assistance.

    Comment


      #3
      Brett, thanks for the verification; I appreciate it.

      Best Regards,
      Scott

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by alifarahani, Today, 09:40 AM
      6 responses
      28 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X