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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X