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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    29 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    17 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    9 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    15 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X