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

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

    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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 pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          148 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          5 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          5 views
          0 likes
          Last Post tkaboris  
          Started by GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,282 views
          0 likes
          Last Post Leafcutter  
          Working...
          X