• 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.


No announcement yet.

Partner 728x90


Indicator different time frame

  • Filter
  • Time
  • Show
Clear All
new posts

    Indicator different time frame

    Hi,is it possible have an indicator with a different time frame than the chart?


    Hello Italianforex,

    Thank you for your post.

    Yes, you can absolutely have an indicator plotting on a different time frame from your chart.

    You could do this in one of two ways. One would be to use a secondary data series on the chart and simply have the your indicator calculate on that secondary series, but apply it to plot over your primary data series.

    Here is an example of how to plot an indicator based off of a 5 minute chart, but plotted over a 2 minute chart:

    * First create a 2 minute chart as usual (File>New>Chart...)
    * Right click within your chart window and select Data Series...
    * Add a second data series, the same instrument as your 2 minute chart, but set the parameters to be a 5 minute chart
    * You should now see two-paneled chart with 2 minute on top and 5 minute below
    * Next, right click and select Indicators... Find your indicator in the top left hand corner, and click New to add it.
    * In the parameters to the right, set your Input Series to your 5 minute data series (Close)
    * Set your Panel to 1,and click OK
    * Next, move your pointer to the right of your price axis (y-axis) on the top panel of your chart window, and right click>Maximize.

    You now should see a 2 minute chart, with an indicator plotted over it based off of a 5 minute Data series.

    Your other option would be to create your own indicator that utilizes a secondary data series.

    Here's a simple example that plots a 5 minute EMA over any other primary time frame using some best practices, including checking on the current bar, using BarsInProgress to plot on the primary data points, and using a private EMA variable to hold our EMA values from the secondary series:

    private EMA EMA1; // we create a new array of EMA values

    protected override void OnStateChange()
    if (State == State.SetDefaults)
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "EMAon5minData";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;

    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;

    AddPlot(Brushes.LightCoral, "EMAPlot");
    else if (State == State.Configure)
    AddDataSeries(Data.BarsPeriodType.Minute, 5); //add our secondary 5 minute data series for calculating the EMA
    else if (State == State.DataLoaded)
    EMA1 = EMA(BarsArray[1], 20); //set EMA here so we make sure it's calculated on the secondary data series

    protected override void OnBarUpdate()
    if (CurrentBars[0] < 1 || CurrentBars[1] < 20) // make sure there's at least one bar for primary series and at least 20 of the secondary series prior to processing

    if(BarsInProgress == 0) // if OnBarUpdate was called from the primary bar series, then set the current value to the latest EMA1 value
    Value[0] = EMA1[0];

    Here is a link to our help guide with additional information regarding working with multiple data series/time frames in NinjaScript:

    If I may be of further assistance, please let me know.
    Kate W.NinjaTrader Customer Service


      Hello gplatis,

      Thank you for your post.

      The first portion of my example, setting the chart up with two time frames and then hiding one, will work on both NT7 and NT8.

      More information about working with multi-series scripts can be found here: https://ninjatrader.com/support/help...nstruments.htm

      Here's an example for NT7:
      protected override void Initialize()
       // adding a 10 minute series of the same instrument to the script      
      Add(PeriodType.Minute, 10);
      protected override void OnBarUpdate()
      // make sure that all series contain enough bars before beginning      
      // this is checking to see that each series contains at least one bar      
      if (CurrentBars[0] < 1 || CurrentBars[1] < 1)           return;      
      // in my example, I just want the stochastics D value of the primary series to be printed if the primary series is calling OnBarUpdate() and the stochastics D value of the secondary series to be printed if the secondary series is calling OnBarUpdate()    
      if (BarsInProgress == 0)          
      Print(Stochastics(BarsArray[0], 3, 14, 7).D[0];      
      if (BarsInProgress == 1)          
      Print(Stochastics(BarsArray[1], 3, 14, 7).D[0];

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service


      Latest Posts


      Topics Statistics Last Post
      Started by hobah99, Today, 04:12 PM
      0 responses
      Last Post hobah99
      by hobah99
      Started by arguru, Today, 04:07 PM
      0 responses
      Last Post arguru
      by arguru
      Started by Abdullah_KSA, Yesterday, 12:52 PM
      6 responses
      Last Post NinjaTrader_ChristopherD  
      Started by ZivGillat, 06-29-2020, 11:47 AM
      4 responses
      Last Post ZivGillat  
      Started by NinjaTrader_PaulH, Today, 01:48 PM
      0 responses
      Last Post NinjaTrader_PaulH