Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2 color EMA missing some segments !

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

    2 color EMA missing some segments !

    I am working on a 2 color EMA which changes color based on the intensity of the trend. When I run the indicator, the first segment that color changes is missing and does not draw; I cannot figure out why!!

    I am testing this EMA on CL - 6 Range bars.

    can't imagine this be a Ninja bug. Any insight would be greatly appreciated.

    This is the indicator code:

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Gold), PlotStyle.Line, "Plot0"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Black), PlotStyle.Line, "Plot1"));
    Overlay = true;
    }

    protected override void OnBarUpdate()
    {

    if (CurrentBar<13)return;
    double tValue = EMA(Close, 13)[0] - EMA(Close, 13)[3];

    if (tValue > 0.025 || tValue < -0.025)
    Plot0.Set(EMA(Close,13)[0]);
    else
    Plot1.Set(EMA(Close,13)[0]);
    }
    Last edited by afshinmoshrefi; 12-24-2012, 07:10 AM.

    #2
    Hello afshinmoshrefi,
    The values are there, however it is the way NinjaTrader draws the plot values and thus you are witnessing the scenario.

    For coloring the Plot values we suggest using only one Plot series and use the PlotColors method to color the Plot.

    Please refer to our help guide to know more about PlotColors


    A sample code will be like
    Code:
    if (CurrentBar<13)return;
    double tValue = EMA(Close, 13)[0] - EMA(Close, 13)[3];
    
    Plot0.Set(EMA(Close,13)[0]);
    			
    if (tValue > 0.025 || tValue < -0.025)
    	PlotColors[0][0] = Color.Green;	
    else
    	PlotColors[0][0] = Color.Red;
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    598 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
    557 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    556 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X