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 llanqui, Today, 03:53 AM
      0 responses
      4 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      14 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      14 views
      0 likes
      Last Post strategist007  
      Working...
      X