Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Program EMA price line pivot gaps

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

    Program EMA price line pivot gaps

    As a novice, I'm baffled by a programming issue. My intent seems simple enough. I want to chart in a panel a line EMA of the price. I would further like to color the EMA line green when it is rising and red when it is falling. In the OnBarUpdate() section I use the following coding.

    if (CurrentBar < Period) return;

    if (EMA(Period) [0] >= EMA(Period) [1])
    {
    Upline.Set(EMA(Period) [0]);
    }
    else
    {
    Dnline.Set(EMA(Period) [0]);
    }

    It compiles fine, but when I run it, every period following a pivot point, up or down, is blank. Everything else between pivots displays as expected. I would greatly appreciate any assistance in moving beyond my first NinjaTrader program.

    #2
    Hello,

    The EMA should only have one Plot set if you want it to be a continuous line.

    You can also use the Rising() and Falling() methods to help determine when the line is rising or falling.

    If you have not yet, I would suggest reviewing our Indicator Reference Sample on Multi-Colored Plots for more information:

    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    592 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    343 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    103 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    556 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    554 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X