Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Show a indicator to use another Data Series

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

    Show a indicator to use another Data Series

    Hi I would like to get help how to show an indicator to use another Data Series.

    for example, I would like to show 5 minutes data Series SMA(5) when I load the 30 minutes chart.

    So follow the guide: https://ninjatrader.com/support/help...erence_wip.htm

    I used "AddDataSeries("ES 06-20", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);", but I am not sure how to use it. It seems that "secondarySeries = new Series<double>(SMA(BarsArray[0], 50)); " didn't work.


    My code example below, Please help me fix it. thanks
    ************************************************** ********************************


    public class ChanBiNT5M : Indicator
    {

    private Series<double> secondarySeries;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    .....................
    }
    else if (State == State.Configure)
    {
    AddDataSeries("ES 06-20", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);

    }
    }

    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.


    secondarySeries = new Series<double>(SMA(BarsArray[0], 50));


    }
    }
    }

    #2
    Hi LadGta2018, thanks for your question.

    Take out the new Series line within OnBarUpdate, it is not needed and it will create a new Series object every time OnBarUpdate is called. Series objects should be created within State.DataLoaded.

    I attached a sample script for your reference that plots a 20 SMA of a 5 minute series.

    Kind regards.
    Attached Files

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi LadGta2018, thanks for your question.

      Take out the new Series line within OnBarUpdate, it is not needed and it will create a new Series object every time OnBarUpdate is called. Series objects should be created within State.DataLoaded.

      I attached a sample script for your reference that plots a 20 SMA of a 5 minute series.

      Kind regards.
      Great! it works and totally answered my question.

      Surprised get your feedback in weekend! Thanks a lot.

      Comment


        #4
        Originally posted by NinjaTrader_ChrisL View Post
        Hi LadGta2018, thanks for your question.

        Take out the new Series line within OnBarUpdate, it is not needed and it will create a new Series object every time OnBarUpdate is called. Series objects should be created within State.DataLoaded.

        I attached a sample script for your reference that plots a 20 SMA of a 5 minute series.

        Kind regards.
        Hi Chris L. ,

        I tried plots a 5 minute ZigZag in 30 minutes chart. but the code didn't work.

        Could you please create a sample script for Zigzag? Thanks!

        Comment


          #5
          Hi LadGta2018, thanks for your reply.

          The Zig Zag indicator is different because it does not have a plot value for every bar like the SMA does. You need to use either the HighBar, LowBar, HighValue, or LowValue methods of the ZigZag indicator noted here to get this to work. The concept is still the same though, pass in the second BarsArray object into a ZigZag indicator object just like we passed in the second BarsArray into the SMA indicator object.

          https://ninjatrader.com/support/help...t8/?zigzag.htm - ZigZag documentation.

          Please let me know if I can assist any further.





          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X