MACD above 0 for 6 consecutive bars

Optuma Forums Optuma Scripting MACD above 0 for 6 consecutive bars

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #64083
    deepak
    • Topics: 49
    • Replies: 35
    • Posts: 84

    Dear Sir,

    I want to code a condition in which MACD is above 0 for six consecutive bars. Below is the script.
    Its doesnt seem working.

    #64099
    Darren
    • Topics: 66
    • Replies: 616
    • Posts: 682

    Thanks Deepak. Your formula is counting how many days since the MACD-H crossed above zero – not how may days it has been above zero. To see the difference put your formula (without the ==6 so the value will display) in a watchlist column.

    This example shows correctly that it has been 50 days since the MACD crossed above zero for STE, but its not what you are looking for as the MACD is currently below zero:

    Capture

    Instead, change the logic to count the number of days since the MACD-H was last below zero:

    Out of the S&P500 stocks, only CME has had 6 days above zero (but change to >=6 for at least 6 days and there are 44 stocks):

    Capture2

    2 users thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest