Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Direction Movement(DM) Error on Multi-Time Frames?

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

    Direction Movement(DM) Error on Multi-Time Frames?

    Hi all:

    I have a 1500 tick bar chart as my primary chart. A 4500 tick bar chart is my secondary chart. I have the DM(14) indicator on both charts. While running market replay data for the ES contract the output values on the secondary chart do not correspond with indicator on the 4500 tick bar graph. Run the strategy below in the primary 1500 tick bar chart and observe the output window with secondary chart values. Please confirm they do not correspond. If so, why?

    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class DMADXError : Strategy
    {
    #region Variables

    private double myDMPrimaryChart = 0;
    private double myDMSecondaryChart = 0;

    // User defined variables (add any user defined variables below)
    #endregion

    /// <summary>
    /// This method is used to configure the strategy and is called once before any strategy method is called.
    /// </summary>
    protected override void Initialize()
    {

    CalculateOnBarClose = false;
    TraceOrders = true;
    Add(PeriodType.Tick, 4500);
    BarsRequired = 3;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired)
    return;

    if(BarsInProgress != 0)
    return;

    myDMPrimaryChart = DM(14)[0];
    myDMSecondaryChart = DM(BarsArray[1], 14)[0];
    Print("DM Primary Chart = " + myDMPrimaryChart.ToString());
    Print("DM Seconday Chart = " + myDMSecondaryChart.ToString());
    }


    }
    }

    #2
    Hello geekodude,

    Thank you for your post.

    Are you running both the strategy and the indicator with CalculateOnBarClose set to false?

    Can you provide a screenshot of your setup?

    To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and attach the file to your post. Click Reply -> Go Advanced -> select the Paperclip icon from the toolbar.

    For detailed instructions please visit the following link

    http://take-a-screenshot.org/
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Attached are the screenshots for the working ADX and non-working ADX. Somehow my current work-space is corrupt. Even if I reload my template graphs into my current work-space the values still output incorrectly. However, if I create a new work-space & load up my templates graphs, the values display correctly. Some gremlin in my current work-space is messing things up. So the solution is to re-create my work-space....
      Attached Files

      Comment


        #4
        Well even after I rebuilt my work space, things went a muck again. I initiated a market replay connection to this week 4/13/14 to 4/17/14 for the ES contract. I don't think it will matter what contract you load up. I run the strategy in the 1500 tick chart. Everything is fine. When I go back in time e.g. previous week 4/6/14 to 4/11/14 the output is wrong.

        The fix? One has to right mouse click on the 1500 tick bar chart (where the strategy is running) ---> Data Series ---> Days to load and toggle the number in the days to load field to something different. See attached & try for yourself & confirm this happens on your ninjatrader also.

        Is this the correct behavior or a bug? If it's the correct behavior please document it somewhere obvious.

        Thank you
        Attached Files

        Comment


          #5
          Hello geekodude,

          Thank you for your response.

          I see what you are detailing here, I would ask if the 1500 and 4500 tick charts are loading the same amount of days or bars? You can check this by right clicking in your chart > select Data Series > check the Load Data Based On setting and the BarsToLoad or DaysToLoad and make sure they match on both charts.

          Comment


            #6
            Yes they both match - default set to 3 days. In my case, I toggle from 3 days to 4 days ---- then from 4 back to 3 after I change market replay date. That make things work. I also notice after doing this a few times with a chart with many indicators, Ninjatrader eventually runs out of memory.

            Comment


              #7
              Hello geekodude,

              Thank you for your response.

              Please send me your log and trace files for today so that I may look into what occurred. You can do this by going to the Control Center-> Help-> Mail to Support. Please place 'ATTN: Patrick - 1058268' in the subject line and reference this thread in the body of the email: http://www.ninjatrader.com/support/f...ad.php?t=65473

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, 08-09-2023, 09:04 AM
              10 responses
              298 views
              0 likes
              Last Post MrHump
              by MrHump
               
              Started by jpapa, Today, 07:22 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by kevinenergy, 02-17-2023, 12:42 PM
              116 responses
              2,758 views
              1 like
              Last Post kevinenergy  
              Started by franatas, 12-04-2023, 03:43 AM
              7 responses
              106 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Jltarrau, Today, 05:57 AM
              3 responses
              9 views
              0 likes
              Last Post Jltarrau  
              Working...
              X