Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 DanielTynera, Today, 01:14 AM
    0 responses
    2 views
    0 likes
    Last Post DanielTynera  
    Started by yertle, 04-18-2024, 08:38 AM
    9 responses
    40 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    12 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,615 views
    0 likes
    Last Post aligator  
    Working...
    X