Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EMA Crossing Formula

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

    EMA Crossing Formula

    Hi,

    I found one indicator in this forum for EMA crossing, it is called the "DoubleMA". However, the code is too complicated for me to understand. I need to abstract the formula for the code so that I may use it to develop a code that suits me.

    The out come of my EMA crossing formula looks OK. Somehow the formula is always one bar behind (slower) when compare to "DoubleMA". I wonder why. So I attached here my formula in hope that somebody can give some help:



    for (int idx = Math.Min(CurrentBar, Ema_fast - 1); idx >= 0; idx--)
    fasterEMAnow= EMA(Close, Ema_fast)[0];
    fasterEMAprevious= EMA(Close, Ema_fast)[+1];
    slowerEMAnow=EMA(Close,Ema_slow)[0];
    slowerEMAprevious= EMA(Close, Ema_slow)[+1];

    //Actual formula for EMA formula
    if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) )
    { trend = 50; }
    if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious))
    { trend = 25; }

    Ema_plot.Set(trend);

    I wish to know why my code is always one bar slower????? Thanks!!!

    shek
    Last edited by pipsheker; 05-18-2008, 05:29 AM.

    #2
    Unfortunately this is beyond the level of support we can offer due to bandwidth.

    I suggest you investigate the values of your indicator on all intermediate steps to determine its behavior.
    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
    627 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    359 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    562 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    567 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X