Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA EMA Cross

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

    SMA EMA Cross

    Hi,

    I want to add to my strategy something like

    if ema xy crosses sma xy during the last 30 days
    do something

    does anyone know how the correct syntax looks like ?

    regards ali

    #2
    Hello ali321,

    You can use CrossAbove() or CrossBelow() to define a crossing condition.

    An SMA crossing above and EMA within the last 30 bars looks like this:
    Code:
     
     
    if (CrossAbove(SMA(14), EMA(14), 30))
    If you don't care about the direction of the crossing, you could add || to look for crossing in both directions.

    Code:
    if (CrossAbove(SMA(14), EMA(14), 30) || CrossBelow(SMA(14), EMA(14), 30))
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by twitch251, Today, 05:14 PM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_ShawnB  
    Started by robforee2, Today, 05:07 PM
    0 responses
    1 view
    0 likes
    Last Post robforee2  
    Started by blar58, Today, 03:16 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Melissa  
    Started by alcorr247, Today, 02:52 PM
    2 responses
    7 views
    0 likes
    Last Post robforee2  
    Started by Radano, Today, 02:30 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X