Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add(PeriodType.Day,1) for 5min charts vs. Tick Bar charts

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

    Add(PeriodType.Day,1) for 5min charts vs. Tick Bar charts

    I have several ES strategies that run on 5min charts using the code below to add a 200 day MA as a long term trend filter. It works fine with these strategies, but if I apply it to a tick bar chart, using a strategy that I'm developing it returns no results at all. No trades, nada! If I // comment out the code the strategy returns various trades. Please note that I have purchased several years of ES data from Tick Data dot com, so there's plenty of data for the 200 day MA going all the way back to 2007.

    I would like to use the 200 day MA as a long term filter on my intraday 1364 tick bar chart but am not having any luck. The session template I'm using is US Equities RTH, same as with the 5 minute charts. Any help will be greatly appreciated.

    Thanks,

    protected override void Initialize()
    {
    Add(PeriodType.Day,1);

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (SMA(BarsArray[1], 1)[1] > SMA(BarsArray[1], 200)[1])

    {
    if ( My Entry Conditions)

    {
    EnterLong(positionsize, "LE");

    #2
    Hello padddler,

    Thank you for your post.

    You would need to ensure 200 days are set to load on the chart (right click > Data Series > DaysToLoad) and that you perform a CurrentBars check as seen below at the beginning of your Initialize() method:
    Code:
    if(CurrentBars[0] <= 200 || CurrentBars[1] <= 200)
    return;
    This ensures we have enough daily bars before processing calculations. For information on this item please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

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

    Comment


      #3
      Hi Patrick,

      Thanks for the quick response but your suggestion hasn't helped. As I mentioned before, I made sure there was enough data Data Series > Custom Range> 6/1/2007 to 6/24/2007 but your code snippet didn't to the trick.

      Again, the problem lies with the 2 snippets of code below that are being applied to a 1364 tick bar chart. And to re-iterate, this code works on a 5 minute chart, but does NOT work on a tick bar chart.

      Add(PeriodType.Day,1);
      and
      if (SMA(BarsArray[1], 1)[1] > SMA(BarsArray[1], 200)[1])

      When they are "//" commented out various trades show up, if not then I don't see any trades.

      Any help with this issue will be appreciated.

      Thanks,

      Comment


        #4
        Hello padddler,

        Thank you for your response.

        Can you provide the full code being tested or a sample version that reproduces the same issue?

        Comment


          #5
          Hi Patrick,

          Thanks for the quick reply. Attached is the script. The entry logic has been replaced but the problem persists. Remember that the ES data I'm using is imported and was purchased from Tick Data Inc.

          The Custom Range is 6/1/2007 thru 6/24/2014 on a 1364 tick bar chart using a strategy analyzer.

          The session template is US Equities RTH. Let me know if you need anything else.

          Thanks,
          Attached Files

          Comment


            #6
            Hello padddler,

            Thank you for your response.

            In backtesting if uncomment or comment out the following lines I still see trades. Do you see trades in backtesting?
            Code:
            			if(CurrentBars[0] <= 200 || CurrentBars[1] <= 200)			
            				return;
            ...
            if (SMA(BarsArray[1], 1)[1] > SMA(BarsArray[1], 200)[1])

            Comment


              #7
              Again, the problem lies with the 2 snippets of code below that are being applied to a 1364 tick bar chart. And to re-iterate, this code works on a 5 minute chart, but does NOT work on a tick bar chart.

              Add(PeriodType.Day,1);
              and
              if (SMA(BarsArray[1], 1)[1] > SMA(BarsArray[1], 200)[1])

              When they are "//" commented out various trades show up, if not then I don't see any trades.

              Comment


                #8
                Hello paddler,

                And I am seeing trades with these items not commented. Please set the 'Load data based on' to Days and then the 'Days to load' to 365, and finally re-test. This is what I used without issue.

                Comment


                  #9
                  Hi Patrick,

                  When using the strategy analyzer it doesn't give the option of "Days to Load" only a "From" and "To" date. If I try to run the strategy off of a 1364 tick bar chart, I can use the "Days to Load" but I am unable to load ANY strategy as that option is grayed out.

                  Note that I also have to shut down my connections with Kinetic and IB to load the imported data.

                  Could you please call to remote and help trouble shoot.

                  Thanks,

                  Comment


                    #10
                    Hello padddler,

                    Thank you for your response.

                    I have responded to your private message, I look forward to assisting you further.

                    Comment


                      #11
                      Hello padddler,

                      Thank you for your note.

                      I look forward to our support call later today.

                      Comment


                        #12
                        Hello padddler,

                        Thank you for your time today.

                        We were able to determine the root cause was that the Add(PeriodType.Day, 1); was requesting daily data from your custom instrument that you used to import the tick data, but unfortunately had no daily data. We resolved it by changing the line to Add("ES 09-14", PeriodType.Day, 1);.

                        Alternatively, import the tick data again for the custom instrument and make sure to select the option in the Historical Data Manager Import tab to generate Day bars from imported tick data and then you can continue to use Add(PeriodType.Day, 1);.

                        Comment


                          #13
                          Thanks for the help resolving the problem!

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          649 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          370 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          109 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          574 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          576 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X