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 helpwanted, Today, 03:06 AM
            1 response
            16 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            11 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            6 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            244 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            387 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X