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

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 tradingnasdaqprueba, 04-09-2024, 09:52 AM
    6 responses
    26 views
    0 likes
    Last Post tradingnasdaqprueba  
    Started by PaulMohn, Today, 02:06 AM
    1 response
    2 views
    0 likes
    Last Post PaulMohn  
    Started by Mindset, Today, 01:27 AM
    0 responses
    4 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by EB Worx, 03-07-2023, 05:05 AM
    4 responses
    98 views
    1 like
    Last Post cls71
    by cls71
     
    Started by patricia70, 11-23-2020, 10:17 AM
    17 responses
    548 views
    1 like
    Last Post PaulMohn  
    Working...
    X