Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with coding Moving average differences

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

    Help with coding Moving average differences

    Hello everyone,

    Thanks for all your support on here, its really appreciated for a newbie.

    How do I code the difference between two simple moving averages as the offset function doesn't really work and the trades are just triggered on the close of the cross-over and not the difference between the two SMA's

    For example, I want to trigger a LONG trade if the difference between an SMA(5) and SMA(20) is >10 points and reverse if the difference is negative 10 pts.

    I had a go at the coding but kept getting errors due to my lack of C# skills.

    If anyone out here can help, I can keep the grey hairs at bay!

    cheers,

    Leonie

    #2
    See the following image for the condition where you would EnterLong(), to EnterShort(), just change to "<" and change "10" to "-10".
    Attached Files
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    264 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    168 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    171 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    257 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    209 views
    0 likes
    Last Post CarlTrading  
    Working...
    X