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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    152 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    87 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    131 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    127 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    106 views
    0 likes
    Last Post CarlTrading  
    Working...
    X