• 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

State.Realtime during Playback Historical Bars

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

    State.Realtime during Playback Historical Bars

    Hello NT8 Support,

    Inside OnBarUpdate(), I want to avoid executing certain code while the Playback connection loads historical bars as it gets itself to the date/time I choose. Then, after I press the "Play" button I want to begin executing that code -- just like normal real-time trading.

    Calculate is set to Calculate.OnBarClose;

    When I use the following test, the code inside the brackets executes during load of Playback bars (historical) and when printing bars in "real time":

    if ( State == State.Realtime ) // Have also tried if ( State == State.Realtime & CurrentBar == Count - 2 )
    {
    // Do something - should only execute this code after "Play" button is pressed, not while Playback is loading chart with historical bars
    }

    How can I keep the code inside the brackets above from executing until "Play" is pressed?

    Thank you.
    Last edited by D Trader; 07-11-2020, 01:45 PM.

    #2
    Hello D Trader,

    Thank you for your post.

    Where within your script is the code you don't wish to execute until play is hit? If you specify if (State == State.Realtime) within OnBarUpdate(), that code will not execute until play is pressed, regardless of the indicator reaching a real time state as no real time ticks are coming in yet.

    I'm attaching an example indicator that illustrates this. This example will print the state of the indicator from OnStateChange() and then also print that State.Realtime was reached on whatever the current bar is once play is pressed.

    Thanks in advance; I look forward to assisting you further.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Unsuitable, Today, 07:26 AM
    0 responses
    2 views
    0 likes
    Last Post Unsuitable  
    Started by bumbledbee, Today, 04:28 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Marco  
    Started by Tmaninc, Today, 02:13 AM
    3 responses
    12 views
    0 likes
    Last Post Tmaninc
    by Tmaninc
     
    Started by rexmie888, Yesterday, 09:37 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by larkmail, Yesterday, 06:19 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Marco  
    Working...
    X