Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MACD Interface to get the values

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

    MACD Interface to get the values

    Hi,

    The result of the MACD indicator is the value for Fast, Slow and Smooth.

    What is the interface to get the values from the MACD indicator?

    How do you call the MACD within a strategy and write the values into own variables?

    I know the NinjaScript Language Reference unfortunately it doesn't answer the question.

    Can anyone help?

    #2
    jazzman,

    Thanks for your note.

    You can call MACD and assign it to a variable as follows :

    Code:
    double macd_avg = Macd(fast,slow,smooth).Avg[0];
    
    double macd_diff = Macd(fast,slow,smooth).Diff[0];
    
    double macd_macd = Macd(fast,slow,smooth).Macd[0];
    This would only assign the most current bar, which is index 0, to these double variables that are defined above.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by jazzmann View Post
      Hi,



      I know the NinjaScript Language Reference unfortunately it doesn't answer the question.

      Can anyone help?
      Forunately it does. I'm on my phone right so I can't point you to it.

      Comment


        #4
        Jazzman,

        As sledge mentioned, there is a sample of how to call it at the following link.



        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Check out this post.

          Comment


            #6
            Thanks to everybody for your quick help.
            Yes, my little problem can be solved that way.

            Comment


              #7
              Jazzman, it may have been a while since you posted this ,and may not need it anymore, but I had the same question. How do I get the fast and slow lines in the MACD. As far as I can tell calling MACD(12,26,9)[0].ToString() yields an average of the fast and slow line.

              BUT, I discovered:

              FAST line:
              MACH(12,26,9).values[0]

              SLOW Line:
              MACH(12,26,9).values[1]

              I wish it did have a functioning 'FAST and .SLOW property too. it took some experimenting to discover this.

              Hope that helps.

              Michael

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              634 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              364 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              567 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              568 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X