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

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

    Comment


      #3
      Thank you Paul, it works fine!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by PeakTry, Today, 10:49 AM
      0 responses
      2 views
      0 likes
      Last Post PeakTry
      by PeakTry
       
      Started by llanqui, Today, 10:32 AM
      0 responses
      4 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by StockTrader88, 03-06-2021, 08:58 AM
      45 responses
      3,992 views
      3 likes
      Last Post johntraderuser2  
      Started by TAJTrades, Today, 09:46 AM
      0 responses
      8 views
      0 likes
      Last Post TAJTrades  
      Started by rhyminkevin, Yesterday, 04:58 PM
      5 responses
      62 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Working...
      X