• 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

Using Multi-Time frame instruments

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

    Using Multi-Time frame instruments

    Hello,
    I modified an indicator to show 10 range bars on a 12 range chart. As it prints there are blank spaces where the 10 range value of the indicator is N/A. I have read the support material on multi-time frame instruments and I have a decent understanding of why it's printing this way. Unfortunately I have a strategy that is using this 10 range indicator on a 12 range chart and the algorithm is messed up because during those N/A times the Close[0] is input instead of the actual value of that indicator on a 10 range chart. Is there a way around this?
    Thanks

    #2
    Hello CaptainAmericaXX,

    Thank you for your post.

    Please clarify: Do you have an indicator that adds a 10 range series using AddDataSeries or are you actually rendering these bars to the chart, replacing the bars of the primary series?

    It seems like you are running into invalid data points on the 10 range series. See this help guide page on IsValidDataPoint(), it is a method that returns true if a data point exists at the barsAgo parameter.

    I look forward to your reply.

    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Chris thanks for responding.
      To begin with I'm using NT7.
      Here is the code to the indicator:
      Code:
       public class A1DerivitiveOss10Range : Indicator
          {
              #region Variables
                  private int period = 14;
                  private int smooth1 = 5;
                  private int smooth2 = 3;
                  private int smooth3 = 9;
              #endregion
      
              protected override void Initialize()
              {
                  Add(PeriodType.Range, 10);
                  BarsRequired        = 20;
                  Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "DerivativeOscUp"));
                  Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "DerivativeOscDn"));
                  Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "DerivativeOsc"));
                  Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGreen), 0, "Zero"));
                  Overlay                = false;
                  PriceTypeSupported    = true;
                  PaintPriceMarkers   = true;
                  VerticalGridLines   = false;
      
                  Plots[0].Pen.Width = 2;
                  Plots[1].Pen.Width = 2;
                  Plots[2].Pen.Width = 2;            
      
                  Plots[0].PlotStyle = PlotStyle.Bar;
                  Plots[1].PlotStyle = PlotStyle.Bar;
      
                  Plots[0].Min = 0;
                  Plots[1].Max = 0;
              }
              protected override void OnBarUpdate()
              {
                  if(CurrentBar < BarsRequired || CurrentBars[1] < BarsRequired){
                      return;
                  }
                  if(BarsInProgress == 1){
                      double smooth1 = EMA(EMA(RSI(Input, Period, 1), Smooth1), Smooth2)[0];
                      double smooth2 = SMA(EMA(EMA(RSI(Input, Period, 1), Smooth1), Smooth2), Smooth3)[0];
      
                      DerivativeOsc.Set(smooth1 - smooth2);
                      DerivativeOscUp.Set(smooth1 - smooth2);
                      DerivativeOscDn.Set(smooth1 - smooth2);
                  }
              }
      When I add this indicator to a 12 range chart I do have invalid data points.
      I am also referencing this indicator in a method which also produces invalid data points.
      Is there a method in NT7 to solve this?
      Thanks

      Comment


        #4
        Hello CaptainAmericaXX,

        Thank you for your reply.

        This data sparsity always happen with different range charts. The plotting system is plotting the data values at the time of calculation. It does not seem like a 10 range series is needed anyway, since the indicators you are using use the Input series (your primary series.) changing the primary series to match whatever the secondary series is will produce a correct graph (with range charts specificaly).

        Please let me know if I can assist further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          So how can I get the proper data? I'm trying to determine if the indicator value is rising or falling.
          In my method I simply have:
          Code:
          if(der_Oss[several_Bars_Back] > der_Oss[several_Bars_Back + 1]){
                          higher_Low_DO_rising                = true;
                      }
          But during those times of data sparsity the input used by NT is Close[0] or Close[1]. That value, of course, messes everything up. Why am I getting Close and how can I get the right Input?

          Thanks.

          Comment


            #6
            Hello CaptainAmericaXX,

            Thank you for your reply.

            The data is correct, it is just that the plotting will always be synced to the primary series. To get a correct plot (with range charts especially) you would need to plot within BarsInProgress == 0 instead of BarsInProgress == 1.

            Please let me know if I can assist further.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Ok, I guess I'm not being clear on what my issue is. When I use this indicator with BarsInProgress == 1 on a 12 range chart there are invalid data points which when printed to the Output show Close[0] instead of DrivativeOsc. When I change to BarsInProgress == 0 the data is changed from a 10 range to the primary bars series of the range of the chart (in this case 12 range) and yes, all the data is THEN accurate, but that isn't what I want.
              I want to get data from a 10 range indicator while on a primary 12 range bars series and use that data in a method. When I choose BarsInProgress == 1 (10 range) almost all the data is accurate. Occasionally there are invalid data points. When I print those points, as I said before, to the Output I see that the Input used is Close[0] instead of DrivativeOsc.Set(smooth1 - smooth2). Nowhere in my method did I ask for the Close[0]! How can I get the ALL the 10 range data accurately while on a 12 range primary bars series?

              Comment


                #8
                Hello CaptainAmericaXX,

                Thanks for the reply.

                Close[0 ] is the default for a datapoint if none is found from the indicator. What is happening is that the 10 range chart has a close value but nothing exists for the 12 range chart. You would need to move your plotting to the primary series and use the values from the secondary series e.g.

                Code:
                protected override void OnBarUpdate()
                        {
                            if(CurrentBar < BarsRequired || CurrentBars[1] < BarsRequired){
                                return;
                            }
                            if(BarsInProgress == 0){
                                double smooth1 = EMA(EMA(RSI(Closes[1], Period, 1), Smooth1), Smooth2)[0];
                                double smooth2 = SMA(EMA(EMA(RSI(Closes[1], Period, 1), Smooth1), Smooth2), Smooth3)[0];
                
                                Values[0].Set(smooth1 - smooth2);
                                Values[1].Set(smooth1 - smooth2);
                                Values[2].Set(smooth1 - smooth2);
                            }
                        }
                Please let me know if I can assist further.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  That did it! Thank you so much!
                  I was trying
                  Code:
                  double smooth1 = EMA(EMA(RSI(Input, Period, 1), Smooth1), Smooth2)[1][0];
                  double smooth2 = SMA(EMA(EMA(RSI(Input, Period, 1), Smooth1), Smooth2), Smooth3)[1][0];
                  and getting errors. Now I understand what I was doing wrong. Thanks again!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bankavaselina, Today, 10:38 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post bankavaselina  
                  Started by dieterp, Today, 09:40 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_Heath  
                  Started by bankavaselina, Today, 08:51 AM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_PatrickG  
                  Started by ballboy11, Today, 09:05 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Jim  
                  Started by frankduc, Today, 08:39 AM
                  4 responses
                  10 views
                  0 likes
                  Last Post frankduc  
                  Working...
                  X