Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code using different PrimaryDataSeries

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

    Code using different PrimaryDataSeries

    Hi.
    A coding question for NT7. I have a 5Min chart which I sometimes switch to 15Min and back. Depending on which of the two timeframes is in use I want a certain EMA to show. Let's say when I am using the 5min chart I want to see an EMA40, when I switch it to 15Min I do not want to see the EMA40 but an EMA80. Is there a way to put this into the code? Perhaps something like this:

    protected override void OnBarUpdate()

    if (PrimaryDataSeries=5min)
    {
    show EMA 40
    remove EMA80
    ​}

    else ​if (PrimaryDataSeries=15min)
    {
    show EMA 80
    remove EMA40
    ​}

    My question is how to express the parts in bold in correct coding language.

    sandman


    #2
    Hello sandman,

    Yes, this is possible.

    The BarsPeriod holds information about the bars object.


    For example
    if (BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 5)
    {
    Value.Set( EMA(40)[0] );
    }

    else if (BarsPeriod.Id == PeriodType.Minute && BarsPeriod.Value == 15)
    {
    Value.Set( EMA(80)[0] );
    }

    You could choose to have two plots and set the Values instead, but I think if only one plot line is going to show, you could just use the one plot.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea. Exactly what I was looking for
      Thank you - and have a great day. sandman

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X