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