Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

semi automatic trading script

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

    semi automatic trading script

    Hello,

    I'm coding a strategy just to manage positions. I will open this only when I want to enter to market, and close when this exit the positions. The problem is that when I open the strategy on chart, this initially try to operate the past data of the chart and make a sort of historic run. This is not desired, because this change some variables that I need with initialized values at the beginning of the script.

    In resume, I would like to know if I can avoid this historical run of the strategy, so the strategy start to run just with the current data, the data which is in the current bar as I open the strategy, it should be the start bar, not to try to run on past bars.

    Thanks

    #2
    Hello federicoo,

    Thanks for your post.

    Yes, you can skip processing the historical bars by adding this in your onBarUpdate():

    if (State == State.Historical) return; // return if not real time.

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

    Comment


      #3
      Thank you Paul, it works fine!

      Comment

      Latest Posts

      Collapse

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