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

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 dcriador, Today, 12:06 PM
        0 responses
        6 views
        0 likes
        Last Post dcriador  
        Started by dcriador, Today, 12:04 PM
        0 responses
        5 views
        0 likes
        Last Post dcriador  
        Started by cutzpr, Today, 08:54 AM
        0 responses
        11 views
        0 likes
        Last Post cutzpr
        by cutzpr
         
        Started by benmarkal, Today, 08:44 AM
        0 responses
        17 views
        0 likes
        Last Post benmarkal  
        Started by Tin34, Today, 03:30 AM
        2 responses
        28 views
        0 likes
        Last Post Tin34
        by Tin34
         
        Working...
        X