Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy start-up initialization

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

    Strategy start-up initialization

    Where is there information on the startup of a strategy in terms of how much data is used and how it is used prior to the first OnBarUpdate? I need this in particular for the ATR. The ATR is the EMA of True Ranges. But at first it is the SMA over the initial period, then it continues as the EMA from there. I am effectively having to reverse engineer the way NT handles the startup of the ATR, even though the ATR formula is public.

    #2
    Hello,

    There is a page in our Help Guide on the BarsRequired for a strategy:



    The strategy will wait until BarsRequired have been met (20 by default, user definable) are added before it will call OnBarUpdate.

    The is NOT the same as the BarsRequired for indicator, which will process data starting on Bar 0. It just simply waits until the BarsRequired have been met before it plots an indicator:



    You will often find your indicator is in an unstable period between the bar 0 and the BarsRequired in an indicator. The value of the indicator will be available, but will not actually plot it until the bars required have been met to ensure we're working with stable values before it plots.
    MatthewNinjaTrader Product Management

    Comment


      #3
      I set BarsRequired = 100, and I still get the first CurrentBar = 20. It looks like it is ignoring my setting.

      Comment


        #4
        Hi,

        If you're referring to the strategy, note that there is both the option to set the BarsRequired from the UI when starting the strategy, and from the Initialize method.

        The UI settings will override the Initialize.

        The following is taken in the strategy base and works to my expectations

        Code:
        		protected override void Initialize()
        		{
        			BarsRequired = 100;
        		}
        
        		protected override void OnBarUpdate()
        		{
        			
        			Print("BarsRequired: " + BarsRequired);
        			Print("CurrentBar: " + CurrentBar);	
        		
        		}
        //first output
        CurrentBar: 100
        BarsRequired: 100
        If you're getting a different CurrentBar and BarsRequired, there there would be something else setting the BarsRequired than what you Initalized.
        MatthewNinjaTrader Product Management

        Comment


          #5
          It was the one in the UI that was set to 20. I changed it to 100 and it worked!

          Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          8 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X