Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamically determining BarsRequired on initialization?

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

    Dynamically determining BarsRequired on initialization?

    Is this possible? In other words, can I do a calculation in Initialize() whereby I look at my known indicator/strategy parameters, calculate the max value of those, and set that as "BarsRequired"?

    #2
    Hello,

    You can do this in OnStartUp(). Here is a loose example:

    Code:
    			protected override void OnStartUp()
    			{
    				
    				if(Instrument.FullName == "ES 12-12")
    				{
    					BarsRequired = 20;
    				}
    				
    				if(Instrument.FullName == "NQ 12-12")
    				{
    					BarsRequired = 100;
    				}
    			}
    MatthewNinjaTrader Product Management

    Comment


      #3
      Interesting. So my next question is, which comes first - Initialize() or OnStartUp()?

      Comment


        #4
        Initialize() will always be called first



        Definition
        You can override the OnStartUp() method to initialize any variables or resources you wish to use in the custom indicator or strategy. This method is called only once immediately prior to the start of your script processing its logic in OnBarUpdate(), but after the Initialize() method.
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Taddypole, 04-26-2024, 02:47 PM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by futtrader, 04-21-2024, 01:50 AM
        6 responses
        58 views
        0 likes
        Last Post futtrader  
        Started by sgordet, Today, 11:48 AM
        0 responses
        4 views
        0 likes
        Last Post sgordet
        by sgordet
         
        Started by Trader146, Today, 11:41 AM
        0 responses
        5 views
        0 likes
        Last Post Trader146  
        Started by jpapa, 04-23-2024, 07:22 AM
        2 responses
        22 views
        0 likes
        Last Post rene69851  
        Working...
        X