PDA

View Full Version : Ninja seems to have a major flaw in evaluating EMA's?


nigeleyre
05-02-2009, 09:32 AM
I'm using this code below to tell the program whether or not to draw a line called "loweave".

if (EMA(10)[0] < EMA(21)[0])
{
DrawLine("loweave", 40, loweave, 0, loweave, Color.Red, DashStyle.Solid, 4);
}

As I understand this, if the 10 period EMA is greater than the 21 period EMA (see attached chart) which it is, then the "DrawLine" command should not happen.

HOWEVER it is! The Red line which corresponds to loweave is being drawn on the chart - Can you help please, this is driving me mad!!

NinjaTrader_Josh
05-02-2009, 03:15 PM
nigeleyre,

You need to debug your code. Add a Print() inside your if-statement to see if it really was evaluated to true. Print the values of EMA(10) and EMA(21) and run calculations by hand based on those values.

Also remember that any line that was drawn before will remain drawn. Just because you don't call DrawLine() does not mean the line will be removed.

nigeleyre
05-02-2009, 03:39 PM
I see re the drawing part but visually you can see that the 10 EMA is well above the 21 EMA

NinjaTrader_Josh
05-03-2009, 04:01 PM
nigeleyre,

You need to debug with Print() to understand what your code is doing.