Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LastBarOnChart

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

    LastBarOnChart

    Hello,

    how can I check if NinjaScript has calculated until the last bar of the dataseries to start automated trading?

    Gerik

    #2
    Hello Gerik,

    Thanks for your post.

    If I understand correctly, you want to know when the strategy has processed the latest historical bar and is now working on real time bars?

    If that is the question, you can always check the "State" as the strategy will transition from State.Historical to State.RealTime

    if (State == State.Historical)
    {
    // do something
    }
    if (State = State.Realtime)
    {
    // do something
    }

    Reference: https://ninjatrader.com/support/help...nt8/?state.htm

    Comment


      #3
      Hello Paul!


      If I execute the strategy in real but on the chart I have 5 days ( as an example), what does the strategy do with the historical data days?

      Thanks & regards

      Mariano

      Comment


        #4
        Hello Mariano,

        Thanks for your post.

        I'm not sure if your question is asked in the context of the previous post or this thread so i will answer as if this is an unrelated question.

        When a strategy (or any script) is added to a chart, the script will run its code starting on the first bar of the dataseries (which would be 5 days ago) The script would perform according to the logic in the script. Once the bar has been processed, the next bar is loaded and again the script logic applied. This processes is repeated for each bar until the right edge of the chart. If the script conditions to place an order are true, historically, it will place the historical order. If an historical order hits a stop or profit target the trade will be closed. You would expect to see historical trades if the strategy conditions for a trade are true.

        If the strategy is in an historical trade when the bars change to real time and if the strategy is set to "wait until flat(default)" then the strategy will not place a live trade order until the historical position is finally closed through the normal strategy logic, there after it would place real time trades.

        Comment


          #5
          Thanks Paul!!!!!!

          Whats the meaning of "wait until flat(default)" is there any configuration in the strategy what I don't know??
          Thanks for your answer!!!
          Last edited by mbcito; 12-22-2019, 06:52 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          47 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          23 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          33 views
          1 like
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          51 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          42 views
          0 likes
          Last Post CarlTrading  
          Working...
          X