Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How can I get the difference between the MACD line and the Avg line?

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

    How can I get the difference between the MACD line and the Avg line?

    I am trying to put a simple MACD cross-over strategy. But I want to avoid the relatively flat crossovers where the distance/difference between MACD line and Avg. line crossovers are under some threshold. How can I get the difference between these two lines?

    As you can see in the attachment, I am trying to avoid the MACD crossover in the middle.

    Thanks.
    Attached Files

    #2
    Hello hasana1,

    Thanks for your post.

    To find the difference between the MACD plot line and the Avg plot line of the MACD indicator, you could subtract one plot value from the other plot value.

    The syntax to access the values of the MACD plot line and the Avg plot line could be seen below and on the MACD help guide page.

    Returns MACD value
    MACD(int fast, int slow, int smooth)[int barsAgo]
    MACD(ISeries<double> input, int fast, int slow, in t smooth)[int barsAgo]

    Returns average value
    MACD(int fast, int slow, int smooth).Avg[int barsAgo]
    MACD(ISeries<double> input, int fast, int slow, in t smooth).Avg[int barsAgo]


    See this help guide page for information about using the MACD indicator in a custom NinjaScript and sample code: https://ninjatrader.com/support/help...gence_macd.htm

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thank you! Exactly what I was looking for.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      72 views
      0 likes
      Last Post PaulMohn  
      Working...
      X