Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add indicator to the strategy from parent timeframe

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

    How to add indicator to the strategy from parent timeframe

    Hello,

    I would like to use in a strategy some indicators, which will use current bars array and parent timeframe, for example:

    ** The strategy runs on M1 and I use:
    1/ Parabolic M1
    2/ MA 21 M1
    3/ custom akSuperTrend indicator M5

    so I need some from M1 and some from M5 (current time frame and higher)
    I am trying to do smth like this:

    Code:
    protected override void Initialize()
            {
    			initParabolic();
    			initZigZag();
    			initSuperTrend();
    			
    			switch (BarsPeriod.Id) 
    			{
    				case PeriodType.Minute:
    					Add(PeriodType.Minute, ParentTimeframe); 
    					break;
    			}		
    		}
    
    .....
    		private void initParabolic()
    		{
    			double aFMax = 0.2;
    			double step = 0.02;
    			
    			this.sar = akParabolicSar(aFMax, step);
    			Add(this.sar);
    		}
    		
    		private void initZigZag()
    		{
    			double aFMax = 0.2;
    			double step = 0.02;
    
    			this.zigzag = akParabolicZigZag(aFMax, step);
    			Add(this.zigzag);
    		}
    		
    		private void initSuperTrend()
    		{
    			int length = 14; 
             	double multiplier = 2.618; 
    			
    [B]			this.superTrend = akSuperTrend([COLOR="Red"]BarsArray[1][/COLOR], length, multiplier, false);
    [/B]			Add(this.superTrend);
    		}
    with akSuperTrend indicator, which uses different Bars object it doesn't work.
    what should I do to ?

    #2
    Hello akushyn,

    Thanks for your post.

    In the case of the added indicator using an added dataseries, it is recommended that you code a separate copy of the indicator with the 5 minute data series already added to it, Then call that copy and make sure to also add the 5 minute series to your strategy.

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello akushyn,

      Thanks for your post.

      In the case of the added indicator using an added dataseries, it is recommended that you code a separate copy of the indicator with the 5 minute data series already added to it, Then call that copy and make sure to also add the 5 minute series to your strategy.
      Hello and thank you very much for the quick reply!

      I didn't really get your point.
      Now it looks like picture 1 and have to be like picture 2.

      I made it manually just drag and drop the additional data series to the primary and then made transparent colors of bars of the additional data series.

      And I need the same but programmatically for the strategy.
      Thank you!
      Attached Files

      Comment


        #4
        Hello akushyn,

        Thanks for your reply.

        The issue is that you cannot add a dataseries and then an indicator to display on that added data series in the strategy.

        If you are wanting to use the indicator in the strategy as well as display the indicator via the strategy using a secondary added data series you would need to recode the indicator to run by itself on the 5 minute series. You would still need to add the 5 minute series to your strategy.

        Alternatively, you can use the indicator in the strategy directly in the OnBarUpdate() method for strategy calculations. Something like if (TSSuperTrend(BarsArray[1], .... and then for chart display, you can add the indicator to the hidden dataseries as you showed in your examples.

        Comment


          #5
          Originally posted by NinjaTrader_Paul View Post
          Hello akushyn,

          Thanks for your reply.

          The issue is that you cannot add a dataseries and then an indicator to display on that added data series in the strategy.

          If you are wanting to use the indicator in the strategy as well as display the indicator via the strategy using a secondary added data series you would need to recode the indicator to run by itself on the 5 minute series. You would still need to add the 5 minute series to your strategy.

          Alternatively, you can use the indicator in the strategy directly in the OnBarUpdate() method for strategy calculations. Something like if (TSSuperTrend(BarsArray[1], .... and then for chart display, you can add the indicator to the hidden dataseries as you showed in your examples.
          Could you please, provide some examples or links of how to recode the indicator using additional dataseries

          Comment


            #6
            I've implemented copy of SuperTrend indicator, thank you.
            Have another question:

            how to make it like green one. You see in attached screen that red line and green line is the same indicator, but red one updates every M1 and green one updates every M5 minutes.

            How to make the red equal to green line?
            Attached Files

            Comment


              #7
              Hello akushyn,

              Thanks for your reply.

              Are you sure that the red line is from the 1 minute? It looks more like what I would expect for a 5 minute indicator on a 1 minute chart.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              566 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              547 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              548 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X