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 bortz, 11-06-2023, 08:04 AM
          47 responses
          1,606 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          13 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X