Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

calculating differences between 2 SMA

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

    calculating differences between 2 SMA

    Is there a way to calculate differences between 2 SMA using strategy, and if at certain distance, the condition is true.

    I only see >= and <=, but nothing says larger(smaller) by a certain tick.

    Any way to do this?

    #2
    If it doesn't matter which SMA is above the other you can do something like...

    if(Math.Abs(SMA1 - SMA2) >= someValue)
    {
    //insert logic here
    }

    if it does matter which is greater than the other just add
    && sma1 > sma2

    or

    && sma1 < sma2

    hope this helps
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Thanks. Yes in my case, which one is above which matters.

      So I will have 2 "if"s for above, and below.

      Comment


        #4
        yes

        if(Math.Abs(SMA1 - SMA2) >= someValue && SMA1 > SMA2)
        {
        //logic 1 here
        }
        else if(Math.Abs(SMA1 - SMA2) >= someValue && SMA1 < SMA2)
        {
        //logic 2 here
        }
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Also remember if you want "some" tick value to use TickSize.

          Code:
          10 * TickSize
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thanks for advice, guys.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            116 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            61 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            40 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            43 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            82 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X