Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninja seems to have a major flaw in evaluating EMA's?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Ninja seems to have a major flaw in evaluating EMA's?

    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!!
    Attached Files

    #2
    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.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I see re the drawing part but visually you can see that the 10 EMA is well above the 21 EMA

      Comment


        #4
        nigeleyre,

        You need to debug with Print() to understand what your code is doing.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, Yesterday, 01:02 PM
        0 responses
        29 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        21 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        160 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        95 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        148 views
        2 likes
        Last Post CaptainJack  
        Working...
        X