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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    156 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    138 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X