Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Reading MACD values on previous bars

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

    Reading MACD values on previous bars

    Hello,

    For my strategy I want to check that the MACD lines stay below the zero line between the current bar (yellow arrow) and the previous swing low (orange arrow).

    Click image for larger version

Name:	Screenshot 2021-11-17 171202.png
Views:	226
Size:	44.1 KB
ID:	1178823

    I'm able to use the Swing indicator to count the number of bars the previous swing low occurred but the number of bars will vary depending on when the trade is taken.

    I was therefore wondering what the best way would be to retrieve the values, is it possible to store the values in a series then use the number of bars between the yellow and orange arrows to call back the data of each bar against the series to then check if they meet the conditions?

    Any help you can provide is appreciated.

    Thanks,

    Neil

    #2
    Hello Neil,

    Thanks for your post.

    You can use the SwingLowBar method to detect the last swing low's BarsAgo and the swing low before that.

    You could then loop from 0 to the BarsAgo found from the above, and within your loop, you can check where the MACD lines are at within the loop. This would check the MACD values from the current bar to where the last swing low was found.

    Swing indicator documentation can be found here - https://ninjatrader.com/support/help...html?swing.htm

    I have attached a quick example to help illustrate.
    Attached Files
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by fx.practic, 10-15-2013, 12:53 AM
    5 responses
    5,406 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by Shai Samuel, 07-02-2022, 02:46 PM
    4 responses
    98 views
    0 likes
    Last Post Bidder
    by Bidder
     
    Started by DJ888, Yesterday, 10:57 PM
    0 responses
    8 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by MacDad, 02-25-2024, 11:48 PM
    7 responses
    160 views
    0 likes
    Last Post loganjarosz123  
    Started by Belfortbucks, Yesterday, 09:29 PM
    0 responses
    9 views
    0 likes
    Last Post Belfortbucks  
    Working...
    X