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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X