• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Start Date Using Chart Strategy

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

    Start Date Using Chart Strategy

    Hi if I am running a strategy from a chart and select # of days to load. As the strategy walks forward in time will it also move the start date/time of the strategy? For futures will it move the start date up 1 day at the close or open of the next day? If so what is the best way to prevent this behavior? I would like to have a firm start date/time for my VMA indicator since it builds recursively and therefore depends on all previous bars not just the last X number of bars.

    Thanks,
    John

    #2
    Hello John,

    Thanks for opening this thread.

    The number of days to load will place the start date a certain number of days from the current date. It will not limit you to having a view of a certain number of days, it simply determines where the data series should begin. You can pre-load a large amount of historical data that can be used for calculations in your strategy.

    If you specifically rely on a period of real time data for your indicator, I would advise to make sure you have given enough time for it to calculate the data it needs before you begin making trades. For example, you can create a condition using ToTime() or ToDay() to control a bool that would then control your entries and exits.

    The following sample code will allow control any logic by your strategy until the current time is within 7:45AM and 1:45PM and 3 days of data has iterated through the strategy.

    Code:
    private int DayActivated;
    protected override void OnBarUpdate()
    {
    	if (CurrentBar == 0)
    		DayActivated = ToDay(Time[0]);
    	
    	if ((ToTime(Time[0]) >= 74500 && ToTime(Time[0]) <= 134500)
    		&& (ToDay(Time[0]) >= DayActivated + 3))
    	{
    	    // Strategy logic goes here
    	}
    }
    You may reference the documentation on Time objects and ToTime() and ToDay()

    ToTime() - https://ninjatrader.com/support/help...-us/totime.htm

    ToDay() - https://ninjatrader.com/support/help...n-us/today.htm

    Time - https://ninjatrader.com/support/help...eries_time.htm

    If you have any further questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply. The logic to force the strategy to wait a certain amount of days makes sense and is worthwhile implementing, but right now I am more concerned with how the strategy adapts as it runs forward.

      For example say I load 3 days of data on the chart and add my strategy to that data series. Today for CME FX futures it would pull data from 4/4,4/3 and 4/2 (after 17:00 CT). Now the strategy runs for a 2 days until 4/6 will the data series now begin at 4/3 instead of 4/2 17:00CT? Will any indicators in the strategy have adjusted their calculations to begin at this later date?

      This is something I can obviously test live but would prefer not to have to wait a day or two to observe the behavior.

      Ultimately, is there any way to force a strategy to begin calculating at a specific date rather than a number of days back from the current date?

      John

      Comment


        #4
        Hello jlkramer16,

        Thanks for the reply.

        Now the strategy runs for a 2 days until 4/6 will the data series now begin at 4/3 instead of 4/2 17:00CT?
        The data series will still begin at the same start date.

        Will any indicators in the strategy have adjusted their calculations to begin at this later date?
        The start date does not get changed, there would not be any need to adjust indicators to specify a different period as time passes.

        Ultimately, is there any way to force a strategy to begin calculating at a specific date rather than a number of days back from the current date?
        Yes, you can. Within the data series window, you can select "Custom Range" from the "Load data based on" pull down menu to specify a start date and an end date. The end date will continue to stay current with the data running through it.

        Please let me know if I may be of further assistance.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by dadarara, Today, 12:18 PM
        0 responses
        6 views
        0 likes
        Last Post dadarara  
        Started by joemiller, Today, 07:33 AM
        0 responses
        8 views
        0 likes
        Last Post joemiller  
        Started by isnercrypto, Today, 06:42 AM
        0 responses
        4 views
        0 likes
        Last Post isnercrypto  
        Started by Coursocied67, Today, 04:02 AM
        0 responses
        5 views
        0 likes
        Last Post Coursocied67  
        Started by TheGameOfProbabilities, 07-18-2019, 06:56 AM
        7 responses
        37 views
        0 likes
        Last Post DaveS
        by DaveS
         
        Working...
        X