Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy: Days to Load/Start Date

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

    Strategy: Days to Load/Start Date

    Hi -

    Is there a way to set -- within the code -- the "start date" for the days to load?

    For example, let's say I want to set "2/2/2015" in the code. Is there a way to do this?

    Thanks!

    #2
    Hello bigsurftrader,

    Thanks for writing in.

    As the days to load is intended for input by the end user in the GUI, there is not a way to force the days to load in the primary data series of an indicator or a strategy. You may however add a return condition to prevent your indicator or strategy from processing historical data from before that period of time.

    The following example will not process anything in OnBarUpdate() if a) there are not enough bars, and b) The date of the bars are before 02/02/2017. A message will also be displayed when from OnBarUpdate() method before it gets returned.

    Code:
    protected override void OnBarUpdate()
    {
    	if (CurrentBars[0] < 1)
    	  return;
    
    	// Return if the bar date is before 02/02/2017
    	if (Times[0][0] == new DateTime(2017, 2, 2))
    	{
    	  Draw.TextFixed(this, @"ReturnMessage", @"Bars taking place before 02/02/2017", TextPosition.TopRight);
              return;
    	}
    			
    }
    Usage for the Times series and DateTime can be referenced below. I will also link the documentation for Draw.TextFixed():

    Times - http://ninjatrader.com/support/helpG...ries_times.htm
    DateTime - https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
    Draw.TextFixed - http://ninjatrader.com/support/helpG..._textfixed.htm

    Please let me know if you have any further questions.

    Comment


      #3
      Ah, gotcha. Thank you! This will have to do then. Thank you,

      Big Surf

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      132 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X