Last active
May 1, 2026 23:15
-
-
Save dotysan/9cc8346ceabc855d67d462c0eb39174b to your computer and use it in GitHub Desktop.
CAHOLD ThinkScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # This is a refactorted ThinkScript for identifying: | |
| # - close above high of a low day (CAHOLD) | |
| # | |
| # Original: https://tos.mx/3Kykh6C | |
| # - has inconsistent lookback/high references; retained here only for provenance | |
| # | |
| # Notes: | |
| # - Uses daily aggregation explicitly. | |
| # - priorLowestLow is the lowest low among the prior 3 completed daily candles. | |
| # - reversal is true when today's daily close breaks above the high of whichever | |
| # prior daily candle made that 3-day lowest low. | |
| # | |
| input fastLength = 10; | |
| input slowLength = 50; | |
| input lookback = 3; | |
| # Force aggregation to daily; do not depend on chart/watchlist aggregation. | |
| def c = close(period = AggregationPeriod.DAY); | |
| def h = high(period = AggregationPeriod.DAY); | |
| def l = low(period = AggregationPeriod.DAY); | |
| def fast = ExpAverage(c, fastLength); | |
| def slow = ExpAverage(c, slowLength); | |
| def upTrend = fast > slow; | |
| # Lowest low among completed prior daily candles: l[1], l[2], l[3]. | |
| def priorLowestLow = Lowest(l[1], lookback); | |
| def reversal = l[1] == priorLowestLow and c > h[1] | |
| or l[2] == priorLowestLow and c > h[2] | |
| or l[3] == priorLowestLow and c > h[3]; | |
| plot output = if upTrend and reversal then 1 else 0; | |
| assignBackgroundColor( | |
| if output == 1 | |
| then Color.GREEN | |
| else Color.BLACK | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment