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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          68 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          150 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          100 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          288 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X