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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X