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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      168 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      324 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      250 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      351 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      180 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X