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 futtrader, 04-21-2024, 01:50 AM
        4 responses
        41 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        11 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        7 views
        0 likes
        Last Post port119
        by port119
         
        Started by Philippe56140, Today, 02:35 PM
        0 responses
        7 views
        0 likes
        Last Post Philippe56140  
        Started by 00nevest, Today, 02:27 PM
        0 responses
        7 views
        0 likes
        Last Post 00nevest  
        Working...
        X