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 cmoran13, Yesterday, 01:02 PM
    0 responses
    31 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    22 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    162 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    95 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    151 views
    2 likes
    Last Post CaptainJack  
    Working...
    X