Announcement

Collapse
No announcement yet.

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:	299
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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 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
    31 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
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X