Finding stock that performs well on a particular day of year

serendipity2020

Member
Plus
Hello @samer800

I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). If its a weekend on that input day, it can be ignored or consider the next day's close>open comparison, if possible.

This day could be an input or if it can be found programmatically, it could be even better but is this something possible with thinkscript or the platform doesn't support it?


Thanks!
 
Last edited:
Hello @samer800

I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). If its a weekend on that input day, it can be ignored or consider the next day's close>open comparison, if possible.

This day could be an input or if it can be found programmatically, it could be even better but is this something possible with thinkscript or the platform doesn't support it?


Thanks!
While something like this is fairly trivial using a programming language like python with freely available data from yahoo finance, it is likely to be nearly impossible with ThinkScript.

While I don't usually post python here (this forum is specifically for ThinkScript), I'd be happy to think about your issue and perhaps post a link to a jupyter notebook that will do the analysis for you (with the admin's blessings, of course @MerryDay what's your feeling on this?).

As for a thinnkscript solution, I doubt it's practical.

-mashume
 
While something like this is fairly trivial using a programming language like python with freely available data from yahoo finance, it is likely to be nearly impossible with ThinkScript.

While I don't usually post python here (this forum is specifically for ThinkScript), I'd be happy to think about your issue and perhaps post a link to a jupyter notebook that will do the analysis for you (with the admin's blessings, of course @MerryDay what's your feeling on this?).

As for a thinnkscript solution, I doubt it's practical.

-mashume
As long as the python code is a link and not posted to the site.
It should be okay. (y)
 
While something like this is fairly trivial using a programming language like python with freely available data from yahoo finance, it is likely to be nearly impossible with ThinkScript.

While I don't usually post python here (this forum is specifically for ThinkScript), I'd be happy to think about your issue and perhaps post a link to a jupyter notebook that will do the analysis for you (with the admin's blessings, of course @MerryDay what's your feeling on this?).

As for a thinnkscript solution, I doubt it's practical.

-mashume
If its not possible with thinkscript to find the day, how about providing day as the input. Ignore weekend criteria for a moment to make it simple... I tried something like this but not sure how to proceed further.

Code:
def priceOn = if GetYYYYMMDD() == 20231001 then close>open else priceOn[1];

Basically, first trying to identify bars whenever close>open but unable to play with above condition.
Another approach I was trying out is something like below on different timeframes:

Code:
def count = sum(close > open, 10) == 10;

But again not sure how to proceed further.
 
Day of Week Equity Curves perhaps address in part what you're trying to accomplish from the description. A Close >Open (gap) trendline chart for each day is possible in TOS (as are Close-Close, Open-Close). This $KTOS Close-Open chart is 3yr timeframe. Obviously, longer timeframes can chart if the data exists. Hope this helps. Update: To clarify - The chart plots points gained/lost (not price per se) for each day of the week over a timeframe. For example: The Cyan line plots the on-going increment of net points accumulated (via ticks) for each Tuesday for the last 3 years for Close-Open. Example $KTOS Use Case: Buy Mondays (Magenta line) near the Close and Sell Tuesdays (Cyan line) after the Open (gap up) before 11a-12p. The TOS code is proprietary, unfortunately. The chart was intended to try to clarify what samer800 is wanting to accomplish and nudge along development. I'll see if I can put together a limited version of DOW Equity Curves to include the Close-Close and Open-Close features and post the code, which the community may find useful.
KTOS_close-open.png
 
Last edited:
Day of Week Equity Curves perhaps address in part what you're trying to accomplish from the description. A Close >Open (gap) trendline chart for each day is possible in TOS (as are Close-Close, Open-Close). This KTOS Close-Open chart is 3yr timeframe. Obviously, longer timeframes can chart if the data exists. Hope this helps.
Which indicator is this chart using? I'd like to take a look at its think script code.
 
so after some data crunching, I came to the conclusion that I could easily do a trading-day-of-year comparison. I gave up on easily doing a calendar day of year thing. I have two lists, one by ticker and one by trading day. The by ticker list tells you what days of the year (1 to 252) the stock rose every year from 2015 to 2023. The by day list tells you which tickers rose every year between 2015 and 2023 on that trading day.

This is only run against the sp500 tickers.

By Trading Day
2: ['VTR', 'WELL', 'WY'],
4: ['TPR'],
5: ['SYY'],
6: ['TXN'],
9: ['WHR'],
10: ['CHD'],
11: ['EA', 'PLD'],
13: ['MLM'],
20: ['NEM'],
22: ['IT', 'NTAP', 'STLD', 'TRGP', 'TXT'],
29: ['HAL', 'HSY', 'KMI', 'MPC', 'PXD', 'SLB'],
30: ['EL', 'LKQ'],
31: ['AMCR', 'COST', 'EA', 'LOW', 'RMD', 'RTX', 'SNA', 'VTRS', 'WMT'],
32: ['ETR', 'NOC', 'PEG', 'POOL', 'VTR', 'WELL'],
38: ['AAPL', 'KEYS'],
41: ['AES', 'AMCR', 'EIX', 'HES', 'K', 'KMI', 'MPC', 'VZ'],
43: ['NRG', 'PPL', 'REGN'],
48: ['DLR'],
50: ['AMT', 'EVRG', 'PPL'],
52: ['ATO', 'HD', 'PSA'],
54: ['ACN'],
57: ['CAG'],
58: ['ALK', 'AMCR', 'BK', 'BMY', 'FMC', 'KDP', 'LIN', 'MSI', 'PNR', 'TEL'],
59: ['AMCR', 'CL', 'DPZ', 'KMB'],
60: ['CPT', 'ZION'],
61: ['VRSK', 'WST'],
66: ['VTR'],
67: ['CMA', 'CTLT', 'MTD', 'NDSN', 'STLD', 'SYK', 'SYY'],
68: ['HCA'],
69: ['AMCR'],
73: ['STX'],
74: ['CZR', 'FAST', 'UPS'],
75: ['BDX'],
80: ['ACN', 'AJG', 'AMCR', 'BIO', 'CDNS', 'FMC', 'MA', 'MET', 'PFG', 'TSN'],
85: ['MTCH'],
88: ['ALLE', 'HD'],
89: ['ANET', 'TMUS'],
92: ['ALB', 'LLY'],
96: ['CTLT'],
97: ['ADM', 'AME', 'BEN', 'BK', 'CFG', 'CHRW', 'CRL', 'DOV', 'EFX', 'EQT', 'FAST', 'IEX', 'NDAQ', 'NSC', 'NXPI', 'PANW', 'PNR', 'PTC', 'ROK', 'SLB', 'SPGI', 'T'],
100: ['AFL', 'AMP', 'AOS', 'AXON', 'BEN', 'ENPH', 'GPC', 'GRMN', 'LKQ', 'MAR', 'MU', 'NTAP', 'PCAR', 'STT'],
101: ['ADP'],
105: ['ACGL', 'AIG', 'AMCR', 'APH', 'BG', 'BIO', 'CAT', 'CB', 'CDW', 'CE', 'CHD', 'COF', 'DD', 'DG', 'EMR', 'FAST', 'FMC', 'GRMN', 'HSIC', 'IP', 'IPG', 'ITW', 'JCI', 'KMB', 'MMC', 'PG', 'PPG', 'ROK', 'SHW', 'STLD', 'UPS', 'VFC', 'WM'],
107: ['AES'],
108: ['EMN', 'HAS', 'O', 'UDR', 'WELL'],
115: ['PM'],
117: ['MOH'],
118: ['AMZN', 'EG', 'NTAP'],
120: ['FCX'],
124: ['URI'],
125: ['ABBV', 'AVY', 'AXP', 'BALL', 'BEN', 'BG', 'CMCSA', 'CSX', 'DFS', 'EXC', 'EXPD', 'FIS', 'GL', 'HON', 'JKHY', 'LH', 'LNC', 'MDLZ', 'MHK', 'MTB', 'NSC', 'NWS', 'PEP', 'PG', 'RHI', 'SBAC', 'STLD', 'SYF', 'UNP', 'USB', 'WELL'],
126: ['FIS', 'NDAQ', 'ORLY'],
128: ['AVY', 'NUE'],
130: ['CMA', 'GL', 'HBAN', 'IT', 'JKHY', 'MA', 'ORCL', 'RF', 'V'],
131: ['ADI', 'AMAT', 'MCHP', 'MU', 'ON', 'SWKS', 'TXN', 'ZBRA'],
132: ['GPN', 'VRSK'],
134: ['AMGN', 'CMI', 'HIG', 'JCI', 'MSCI', 'TRV', 'VRSK', 'VRTX'],
136: ['KHC'],
137: ['DRI', 'FDS', 'FI', 'FIS', 'HON', 'LYV', 'MSCI', 'MTD', 'O'],
138: ['ENPH', 'QRVO'],
140: ['ADM', 'DGX', 'GLW', 'HPQ', 'LH', 'NUE'],
143: ['NDSN'],
145: ['IVZ'],
147: ['REGN'],
148: ['TRMB'],
150: ['CAT', 'DOV'],
151: ['SO', 'WELL'],
152: ['AFL', 'AIZ', 'AKAM', 'ALL', 'GLW', 'J'],
153: ['AEE', 'DTE'],
154: ['STE'],
155: ['DLR'],
161: ['CZR'],
165: ['APTV', 'ATVI'],
170: ['AON', 'MMC'],
174: ['AMCR'],
177: ['BWA'],
178: ['GIS', 'MKC'],
183: ['WHR'],
191: ['BRO', 'LYV'],
193: ['HII'],
195: ['O', 'SPG', 'VFC'],
197: ['AMCR'],
199: ['AVY', 'FLT', 'GWW', 'HON', 'MMM', 'MS', 'SNA', 'WAB'],
205: ['ADM', 'KEY', 'TFC'],
210: ['AEP', 'ALLE', 'AMT', 'KLAC', 'KMI', 'LDOS', 'LNT', 'LRCX', 'MGM', 'NTAP', 'NVDA', 'NXPI', 'PNW', 'PPL', 'ROK'],
212: ['DLTR', 'NSC', 'SNA', 'TJX'],
213: ['AMZN', 'NDSN', 'NWS', 'WHR'],
214: ['AME', 'CBRE', 'TROW'],
215: ['ABT', 'APD', 'CE', 'CHRW', 'LIN', 'ODFL', 'PODD', 'RSG', 'SPGI', 'WM'],
216: ['CNP'],
217: ['CMCSA', 'FI', 'MMC', 'PAYX', 'TPR'],
218: ['PHM'],
222: ['AVGO', 'CDW', 'JNPR', 'TXN'],
223: ['AKAM', 'IDXX', 'ZTS'],
225: ['DGX', 'DUK', 'MKTX'],
226: ['IPG', 'TGT'],
227: ['AXON', 'ETSY', 'F', 'FICO', 'FSLR', 'MSCI', 'ORCL', 'TDY', 'UNH'],
228: ['DGX', 'PFE'],
229: ['DLR', 'INTC'],
232: ['WRB'],
235: ['BG', 'BSX', 'COO', 'EXR', 'RTX'],
237: ['JBHT'],
238: ['BAX', 'CSCO', 'EQT', 'LLY', 'OXY'],
240: ['ATVI', 'CLX', 'JNJ', 'TMUS', 'TSCO', 'TTWO'],
245: ['JBHT', 'TER'],
247: ['AMCR'],
248: ['AVY', 'BAX', 'COO', 'EG', 'FANG', 'FCX', 'HPE', 'MNST', 'STLD', 'TAP'],
252: ['BKR', 'FDS']

By Ticker
'AAPL': [38],
'ABBV': [125],
'ABT': [215],
'ACGL': [105],
'ACN': [54, 80],
'ADI': [131],
'ADM': [97, 140, 205],
'ADP': [101],
'AEE': [153],
'AEP': [210],
'AES': [41, 107],
'AFL': [100, 152],
'AIG': [105],
'AIZ': [152],
'AJG': [80],
'AKAM': [152, 223],
'ALB': [92],
'ALK': [58],
'ALL': [152],
'ALLE': [88, 210],
'AMAT': [131],
'AMCR': [31, 41, 58, 59, 69, 80, 105, 174, 197, 247],
'AME': [97, 214],
'AMGN': [134],
'AMP': [100],
'AMT': [50, 210],
'AMZN': [118, 213],
'ANET': [89],
'AON': [170],
'AOS': [100],
'APD': [215],
'APH': [105],
'APTV': [165],
'ATO': [52],
'ATVI': [165, 240],
'AVGO': [222],
'AVY': [125, 128, 199, 248],
'AXON': [100, 227],
'AXP': [125],
'BALL': [125],
'BAX': [238, 248],
'BDX': [75],
'BEN': [97, 100, 125],
'BG': [105, 125, 235],
'BIO': [80, 105],
'BK': [58, 97],
'BKR': [252],
'BMY': [58],
'BRO': [191],
'BSX': [235],
'BWA': [177],
'CAG': [57],
'CAT': [105, 150],
'CB': [105],
'CBRE': [214],
'CDNS': [80],
'CDW': [105, 222],
'CE': [105, 215],
'CFG': [97],
'CHD': [10, 105],
'CHRW': [97, 215],
'CL': [59],
'CLX': [240],
'CMA': [67, 130],
'CMCSA': [125, 217],
'CMI': [134],
'CNP': [216],
'COF': [105],
'COO': [235, 248],
'COST': [31],
'CPT': [60],
'CRL': [97],
'CSCO': [238],
'CSX': [125],
'CTLT': [67, 96],
'CZR': [74, 161],
'DD': [105],
'DFS': [125],
'DG': [105],
'DGX': [140, 225, 228],
'DLR': [48, 155, 229],
'DLTR': [212],
'DOV': [97, 150],
'DPZ': [59],
'DRI': [137],
'DTE': [153],
'DUK': [225],
'EA': [11, 31],
'EFX': [97],
'EG': [118, 248],
'EIX': [41],
'EL': [30],
'EMN': [108],
'EMR': [105],
'ENPH': [100, 138],
'EQT': [97, 238],
'ETR': [32],
'ETSY': [227],
'EVRG': [50],
'EXC': [125],
'EXPD': [125],
'EXR': [235],
'F': [227],
'FANG': [248],
'FAST': [74, 97, 105],
'FCX': [120, 248],
'FDS': [137, 252],
'FI': [137, 217],
'FICO': [227],
'FIS': [125, 126, 137],
'FLT': [199],
'FMC': [58, 80, 105],
'FSLR': [227],
'GIS': [178],
'GL': [125, 130],
'GLW': [140, 152],
'GPC': [100],
'GPN': [132],
'GRMN': [100, 105],
'GWW': [199],
'HAL': [29],
'HAS': [108],
'HBAN': [130],
'HCA': [68],
'HD': [52, 88],
'HES': [41],
'HIG': [134],
'HII': [193],
'HON': [125, 137, 199],
'HPE': [248],
'HPQ': [140],
'HSIC': [105],
'HSY': [29],
'IDXX': [223],
'IEX': [97],
'INTC': [229],
'IP': [105],
'IPG': [105, 226],
'IT': [22, 130],
'ITW': [105],
'IVZ': [145],
'J': [152],
'JBHT': [237, 245],
'JCI': [105, 134],
'JKHY': [125, 130],
'JNJ': [240],
'JNPR': [222],
'K': [41],
'KDP': [58],
'KEY': [205],
'KEYS': [38],
'KHC': [136],
'KLAC': [210],
'KMB': [59, 105],
'KMI': [29, 41, 210],
'LDOS': [210],
'LH': [125, 140],
'LIN': [58, 215],
'LKQ': [30, 100],
'LLY': [92, 238],
'LNC': [125],
'LNT': [210],
'LOW': [31],
'LRCX': [210],
'LYV': [137, 191],
'MA': [80, 130],
'MAR': [100],
'MCHP': [131],
'MDLZ': [125],
'MET': [80],
'MGM': [210],
'MHK': [125],
'MKC': [178],
'MKTX': [225],
'MLM': [13],
'MMC': [105, 170, 217],
'MMM': [199],
'MNST': [248],
'MOH': [117],
'MPC': [29, 41],
'MS': [199],
'MSCI': [134, 137, 227],
'MSI': [58],
'MTB': [125],
'MTCH': [85],
'MTD': [67, 137],
'MU': [100, 131],
'NDAQ': [97, 126],
'NDSN': [67, 143, 213],
'NEM': [20],
'NOC': [32],
'NRG': [43],
'NSC': [97, 125, 212],
'NTAP': [22, 100, 118, 210],
'NUE': [128, 140],
'NVDA': [210],
'NWS': [125, 213],
'NXPI': [97, 210],
'O': [108, 137, 195],
'ODFL': [215],
'ON': [131],
'ORCL': [130, 227],
'ORLY': [126],
'OXY': [238],
'PANW': [97],
'PAYX': [217],
'PCAR': [100],
'PEG': [32],
'PEP': [125],
'PFE': [228],
'PFG': [80],
'PG': [105, 125],
'PHM': [218],
'PLD': [11],
'PM': [115],
'PNR': [58, 97],
'PNW': [210],
'PODD': [215],
'POOL': [32],
'PPG': [105],
'PPL': [43, 50, 210],
'PSA': [52],
'PTC': [97],
'PXD': [29],
'QRVO': [138],
'REGN': [43, 147],
'RF': [130],
'RHI': [125],
'RMD': [31],
'ROK': [97, 105, 210],
'RSG': [215],
'RTX': [31, 235],
'SBAC': [125],
'SHW': [105],
'SLB': [29, 97],
'SNA': [31, 199, 212],
'SO': [151],
'SPG': [195],
'SPGI': [97, 215],
'STE': [154],
'STLD': [22, 67, 105, 125, 248],
'STT': [100],
'STX': [73],
'SWKS': [131],
'SYF': [125],
'SYK': [67],
'SYY': [5, 67],
'T': [97],
'TAP': [248],
'TDY': [227],
'TEL': [58],
'TER': [245],
'TFC': [205],
'TGT': [226],
'TJX': [212],
'TMUS': [89, 240],
'TPR': [4, 217],
'TRGP': [22],
'TRMB': [148],
'TROW': [214],
'TRV': [134],
'TSCO': [240],
'TSN': [80],
'TTWO': [240],
'TXN': [6, 131, 222],
'TXT': [22],
'UDR': [108],
'UNH': [227],
'UNP': [125],
'UPS': [74, 105],
'URI': [124],
'USB': [125],
'V': [130],
'VFC': [105, 195],
'VRSK': [61, 132, 134],
'VRTX': [134],
'VTR': [2, 32, 66],
'VTRS': [31],
'VZ': [41],
'WAB': [199],
'WELL': [2, 32, 108, 125, 151],
'WHR': [9, 183, 213],
'WM': [105, 215],
'WMT': [31],
'WRB': [232]


It is an interesting idea.

-mashume
 
so after some data crunching, I came to the conclusion that I could easily do a trading-day-of-year comparison. I gave up on easily doing a calendar day of year thing. I have two lists, one by ticker and one by trading day. The by ticker list tells you what days of the year (1 to 252) the stock rose every year from 2015 to 2023. The by day list tells you which tickers rose every year between 2015 and 2023 on that trading day.

This is only run against the sp500 tickers.

By Trading Day
2: ['VTR', 'WELL', 'WY'],
4: ['TPR'],
5: ['SYY'],
6: ['TXN'],
9: ['WHR'],
10: ['CHD'],
11: ['EA', 'PLD'],
13: ['MLM'],
20: ['NEM'],
22: ['IT', 'NTAP', 'STLD', 'TRGP', 'TXT'],
29: ['HAL', 'HSY', 'KMI', 'MPC', 'PXD', 'SLB'],
30: ['EL', 'LKQ'],
31: ['AMCR', 'COST', 'EA', 'LOW', 'RMD', 'RTX', 'SNA', 'VTRS', 'WMT'],
32: ['ETR', 'NOC', 'PEG', 'POOL', 'VTR', 'WELL'],
38: ['AAPL', 'KEYS'],
41: ['AES', 'AMCR', 'EIX', 'HES', 'K', 'KMI', 'MPC', 'VZ'],
43: ['NRG', 'PPL', 'REGN'],
48: ['DLR'],
50: ['AMT', 'EVRG', 'PPL'],
52: ['ATO', 'HD', 'PSA'],
54: ['ACN'],
57: ['CAG'],
58: ['ALK', 'AMCR', 'BK', 'BMY', 'FMC', 'KDP', 'LIN', 'MSI', 'PNR', 'TEL'],
59: ['AMCR', 'CL', 'DPZ', 'KMB'],
60: ['CPT', 'ZION'],
61: ['VRSK', 'WST'],
66: ['VTR'],
67: ['CMA', 'CTLT', 'MTD', 'NDSN', 'STLD', 'SYK', 'SYY'],
68: ['HCA'],
69: ['AMCR'],
73: ['STX'],
74: ['CZR', 'FAST', 'UPS'],
75: ['BDX'],
80: ['ACN', 'AJG', 'AMCR', 'BIO', 'CDNS', 'FMC', 'MA', 'MET', 'PFG', 'TSN'],
85: ['MTCH'],
88: ['ALLE', 'HD'],
89: ['ANET', 'TMUS'],
92: ['ALB', 'LLY'],
96: ['CTLT'],
97: ['ADM', 'AME', 'BEN', 'BK', 'CFG', 'CHRW', 'CRL', 'DOV', 'EFX', 'EQT', 'FAST', 'IEX', 'NDAQ', 'NSC', 'NXPI', 'PANW', 'PNR', 'PTC', 'ROK', 'SLB', 'SPGI', 'T'],
100: ['AFL', 'AMP', 'AOS', 'AXON', 'BEN', 'ENPH', 'GPC', 'GRMN', 'LKQ', 'MAR', 'MU', 'NTAP', 'PCAR', 'STT'],
101: ['ADP'],
105: ['ACGL', 'AIG', 'AMCR', 'APH', 'BG', 'BIO', 'CAT', 'CB', 'CDW', 'CE', 'CHD', 'COF', 'DD', 'DG', 'EMR', 'FAST', 'FMC', 'GRMN', 'HSIC', 'IP', 'IPG', 'ITW', 'JCI', 'KMB', 'MMC', 'PG', 'PPG', 'ROK', 'SHW', 'STLD', 'UPS', 'VFC', 'WM'],
107: ['AES'],
108: ['EMN', 'HAS', 'O', 'UDR', 'WELL'],
115: ['PM'],
117: ['MOH'],
118: ['AMZN', 'EG', 'NTAP'],
120: ['FCX'],
124: ['URI'],
125: ['ABBV', 'AVY', 'AXP', 'BALL', 'BEN', 'BG', 'CMCSA', 'CSX', 'DFS', 'EXC', 'EXPD', 'FIS', 'GL', 'HON', 'JKHY', 'LH', 'LNC', 'MDLZ', 'MHK', 'MTB', 'NSC', 'NWS', 'PEP', 'PG', 'RHI', 'SBAC', 'STLD', 'SYF', 'UNP', 'USB', 'WELL'],
126: ['FIS', 'NDAQ', 'ORLY'],
128: ['AVY', 'NUE'],
130: ['CMA', 'GL', 'HBAN', 'IT', 'JKHY', 'MA', 'ORCL', 'RF', 'V'],
131: ['ADI', 'AMAT', 'MCHP', 'MU', 'ON', 'SWKS', 'TXN', 'ZBRA'],
132: ['GPN', 'VRSK'],
134: ['AMGN', 'CMI', 'HIG', 'JCI', 'MSCI', 'TRV', 'VRSK', 'VRTX'],
136: ['KHC'],
137: ['DRI', 'FDS', 'FI', 'FIS', 'HON', 'LYV', 'MSCI', 'MTD', 'O'],
138: ['ENPH', 'QRVO'],
140: ['ADM', 'DGX', 'GLW', 'HPQ', 'LH', 'NUE'],
143: ['NDSN'],
145: ['IVZ'],
147: ['REGN'],
148: ['TRMB'],
150: ['CAT', 'DOV'],
151: ['SO', 'WELL'],
152: ['AFL', 'AIZ', 'AKAM', 'ALL', 'GLW', 'J'],
153: ['AEE', 'DTE'],
154: ['STE'],
155: ['DLR'],
161: ['CZR'],
165: ['APTV', 'ATVI'],
170: ['AON', 'MMC'],
174: ['AMCR'],
177: ['BWA'],
178: ['GIS', 'MKC'],
183: ['WHR'],
191: ['BRO', 'LYV'],
193: ['HII'],
195: ['O', 'SPG', 'VFC'],
197: ['AMCR'],
199: ['AVY', 'FLT', 'GWW', 'HON', 'MMM', 'MS', 'SNA', 'WAB'],
205: ['ADM', 'KEY', 'TFC'],
210: ['AEP', 'ALLE', 'AMT', 'KLAC', 'KMI', 'LDOS', 'LNT', 'LRCX', 'MGM', 'NTAP', 'NVDA', 'NXPI', 'PNW', 'PPL', 'ROK'],
212: ['DLTR', 'NSC', 'SNA', 'TJX'],
213: ['AMZN', 'NDSN', 'NWS', 'WHR'],
214: ['AME', 'CBRE', 'TROW'],
215: ['ABT', 'APD', 'CE', 'CHRW', 'LIN', 'ODFL', 'PODD', 'RSG', 'SPGI', 'WM'],
216: ['CNP'],
217: ['CMCSA', 'FI', 'MMC', 'PAYX', 'TPR'],
218: ['PHM'],
222: ['AVGO', 'CDW', 'JNPR', 'TXN'],
223: ['AKAM', 'IDXX', 'ZTS'],
225: ['DGX', 'DUK', 'MKTX'],
226: ['IPG', 'TGT'],
227: ['AXON', 'ETSY', 'F', 'FICO', 'FSLR', 'MSCI', 'ORCL', 'TDY', 'UNH'],
228: ['DGX', 'PFE'],
229: ['DLR', 'INTC'],
232: ['WRB'],
235: ['BG', 'BSX', 'COO', 'EXR', 'RTX'],
237: ['JBHT'],
238: ['BAX', 'CSCO', 'EQT', 'LLY', 'OXY'],
240: ['ATVI', 'CLX', 'JNJ', 'TMUS', 'TSCO', 'TTWO'],
245: ['JBHT', 'TER'],
247: ['AMCR'],
248: ['AVY', 'BAX', 'COO', 'EG', 'FANG', 'FCX', 'HPE', 'MNST', 'STLD', 'TAP'],
252: ['BKR', 'FDS']

By Ticker
'AAPL': [38],
'ABBV': [125],
'ABT': [215],
'ACGL': [105],
'ACN': [54, 80],
'ADI': [131],
'ADM': [97, 140, 205],
'ADP': [101],
'AEE': [153],
'AEP': [210],
'AES': [41, 107],
'AFL': [100, 152],
'AIG': [105],
'AIZ': [152],
'AJG': [80],
'AKAM': [152, 223],
'ALB': [92],
'ALK': [58],
'ALL': [152],
'ALLE': [88, 210],
'AMAT': [131],
'AMCR': [31, 41, 58, 59, 69, 80, 105, 174, 197, 247],
'AME': [97, 214],
'AMGN': [134],
'AMP': [100],
'AMT': [50, 210],
'AMZN': [118, 213],
'ANET': [89],
'AON': [170],
'AOS': [100],
'APD': [215],
'APH': [105],
'APTV': [165],
'ATO': [52],
'ATVI': [165, 240],
'AVGO': [222],
'AVY': [125, 128, 199, 248],
'AXON': [100, 227],
'AXP': [125],
'BALL': [125],
'BAX': [238, 248],
'BDX': [75],
'BEN': [97, 100, 125],
'BG': [105, 125, 235],
'BIO': [80, 105],
'BK': [58, 97],
'BKR': [252],
'BMY': [58],
'BRO': [191],
'BSX': [235],
'BWA': [177],
'CAG': [57],
'CAT': [105, 150],
'CB': [105],
'CBRE': [214],
'CDNS': [80],
'CDW': [105, 222],
'CE': [105, 215],
'CFG': [97],
'CHD': [10, 105],
'CHRW': [97, 215],
'CL': [59],
'CLX': [240],
'CMA': [67, 130],
'CMCSA': [125, 217],
'CMI': [134],
'CNP': [216],
'COF': [105],
'COO': [235, 248],
'COST': [31],
'CPT': [60],
'CRL': [97],
'CSCO': [238],
'CSX': [125],
'CTLT': [67, 96],
'CZR': [74, 161],
'DD': [105],
'DFS': [125],
'DG': [105],
'DGX': [140, 225, 228],
'DLR': [48, 155, 229],
'DLTR': [212],
'DOV': [97, 150],
'DPZ': [59],
'DRI': [137],
'DTE': [153],
'DUK': [225],
'EA': [11, 31],
'EFX': [97],
'EG': [118, 248],
'EIX': [41],
'EL': [30],
'EMN': [108],
'EMR': [105],
'ENPH': [100, 138],
'EQT': [97, 238],
'ETR': [32],
'ETSY': [227],
'EVRG': [50],
'EXC': [125],
'EXPD': [125],
'EXR': [235],
'F': [227],
'FANG': [248],
'FAST': [74, 97, 105],
'FCX': [120, 248],
'FDS': [137, 252],
'FI': [137, 217],
'FICO': [227],
'FIS': [125, 126, 137],
'FLT': [199],
'FMC': [58, 80, 105],
'FSLR': [227],
'GIS': [178],
'GL': [125, 130],
'GLW': [140, 152],
'GPC': [100],
'GPN': [132],
'GRMN': [100, 105],
'GWW': [199],
'HAL': [29],
'HAS': [108],
'HBAN': [130],
'HCA': [68],
'HD': [52, 88],
'HES': [41],
'HIG': [134],
'HII': [193],
'HON': [125, 137, 199],
'HPE': [248],
'HPQ': [140],
'HSIC': [105],
'HSY': [29],
'IDXX': [223],
'IEX': [97],
'INTC': [229],
'IP': [105],
'IPG': [105, 226],
'IT': [22, 130],
'ITW': [105],
'IVZ': [145],
'J': [152],
'JBHT': [237, 245],
'JCI': [105, 134],
'JKHY': [125, 130],
'JNJ': [240],
'JNPR': [222],
'K': [41],
'KDP': [58],
'KEY': [205],
'KEYS': [38],
'KHC': [136],
'KLAC': [210],
'KMB': [59, 105],
'KMI': [29, 41, 210],
'LDOS': [210],
'LH': [125, 140],
'LIN': [58, 215],
'LKQ': [30, 100],
'LLY': [92, 238],
'LNC': [125],
'LNT': [210],
'LOW': [31],
'LRCX': [210],
'LYV': [137, 191],
'MA': [80, 130],
'MAR': [100],
'MCHP': [131],
'MDLZ': [125],
'MET': [80],
'MGM': [210],
'MHK': [125],
'MKC': [178],
'MKTX': [225],
'MLM': [13],
'MMC': [105, 170, 217],
'MMM': [199],
'MNST': [248],
'MOH': [117],
'MPC': [29, 41],
'MS': [199],
'MSCI': [134, 137, 227],
'MSI': [58],
'MTB': [125],
'MTCH': [85],
'MTD': [67, 137],
'MU': [100, 131],
'NDAQ': [97, 126],
'NDSN': [67, 143, 213],
'NEM': [20],
'NOC': [32],
'NRG': [43],
'NSC': [97, 125, 212],
'NTAP': [22, 100, 118, 210],
'NUE': [128, 140],
'NVDA': [210],
'NWS': [125, 213],
'NXPI': [97, 210],
'O': [108, 137, 195],
'ODFL': [215],
'ON': [131],
'ORCL': [130, 227],
'ORLY': [126],
'OXY': [238],
'PANW': [97],
'PAYX': [217],
'PCAR': [100],
'PEG': [32],
'PEP': [125],
'PFE': [228],
'PFG': [80],
'PG': [105, 125],
'PHM': [218],
'PLD': [11],
'PM': [115],
'PNR': [58, 97],
'PNW': [210],
'PODD': [215],
'POOL': [32],
'PPG': [105],
'PPL': [43, 50, 210],
'PSA': [52],
'PTC': [97],
'PXD': [29],
'QRVO': [138],
'REGN': [43, 147],
'RF': [130],
'RHI': [125],
'RMD': [31],
'ROK': [97, 105, 210],
'RSG': [215],
'RTX': [31, 235],
'SBAC': [125],
'SHW': [105],
'SLB': [29, 97],
'SNA': [31, 199, 212],
'SO': [151],
'SPG': [195],
'SPGI': [97, 215],
'STE': [154],
'STLD': [22, 67, 105, 125, 248],
'STT': [100],
'STX': [73],
'SWKS': [131],
'SYF': [125],
'SYK': [67],
'SYY': [5, 67],
'T': [97],
'TAP': [248],
'TDY': [227],
'TEL': [58],
'TER': [245],
'TFC': [205],
'TGT': [226],
'TJX': [212],
'TMUS': [89, 240],
'TPR': [4, 217],
'TRGP': [22],
'TRMB': [148],
'TROW': [214],
'TRV': [134],
'TSCO': [240],
'TSN': [80],
'TTWO': [240],
'TXN': [6, 131, 222],
'TXT': [22],
'UDR': [108],
'UNH': [227],
'UNP': [125],
'UPS': [74, 105],
'URI': [124],
'USB': [125],
'V': [130],
'VFC': [105, 195],
'VRSK': [61, 132, 134],
'VRTX': [134],
'VTR': [2, 32, 66],
'VTRS': [31],
'VZ': [41],
'WAB': [199],
'WELL': [2, 32, 108, 125, 151],
'WHR': [9, 183, 213],
'WM': [105, 215],
'WMT': [31],
'WRB': [232]


It is an interesting idea.

-mashume
How did you do this on ToS? Can you share the code?
 
Hello @samer800

I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). If its a weekend on that input day, it can be ignored or consider the next day's close>open comparison, if possible.

This day could be an input or if it can be found programmatically, it could be even better but is this something possible with thinkscript or the platform doesn't support it? hal_woy


find bars and count those that are 'up' , across several years
rather than try to match up dates year to year, and have to adjust data for weekend dates, i converted the date to a week number and day of week. there may be holidays that keep a match from happening in a year.


pick a multi year, day chart.
enter a month and day, to find on the first year on the chart. (not last)
.convert the date to , week of year(woy) and day of week(dow).
.look at bars with the same woy and dow on multiple years,
..count bars that are up.

draw a green vertical line on bars that match woy and dow.
draw a bubble under each match bar, with the up count.

this looks for exact match of week# and day#.
if the day is not a trading day, it will be skipped. it won't look at nearby days for data.

labels show,
the date, week of year, day of week, up count, over x years.


Code:
# one_day_a_year_counts


#perform_well_on_day_of_year
#https://usethinkscript.com/threads/finding-stock-that-performs-well-on-a-particular-day-of-year.16929/
#Finding stock that performs well on a particular day of year
#I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). If its a weekend on that input day, it can be ignored or consider the next day's close>open comparison, if possible.

def na = double.nan;
def bn = barnumber();

def up = close > open;
def dwn = close < open;

def doy = getday();
def dow = GetDayofWeek(GetYYYYMMDD());
def dom = GetDayofMonth(GetYyyyMmDd());
def year = getyear();

input month = 0;
input day = 0;

addlabel(1, "Month " + month, color.yellow);
addlabel(1, "Day of month " + day, color.yellow);
addlabel(1, "  " , color.black);

#---------------------------

# look at first year on chart,
# determine the week of year of the date and day of week of the date.
# will compare week# and day# for each year

# from tos chat - mobius
def data2 = getYYYYMMDD();
def year2 = Round(data2/10000, 0);
def month2 = Round((data2 % 10000) / 100, 0);
def day2 = (data2 % 100);

#input date2 = no;  hal_woy
#addLabel(date2, "date: " + month2 + "/" + day2 + "/" + AsPrice(year2), color.white);

# find bn of 1st date match
def first_datebn = if bn == 1 then 0
 else if first_datebn[1] > 0 then first_datebn[1]
 else if month == month2 and day == day2 then bn
 else first_datebn[1];

def year_count = if bn == 1 then 1
 else if year != year[1] then year_count[1] + 1
 else year_count[1];

#input test_line = no;
#addverticalline(test_line and first_datebn == bn, "-", color.cyan);

# week of year calcs
def doy_offset = 8 - doy;
def dow_offset = (8 - dow);
def adj = -1;
# calc offset for week count , for each year
def woy_offset = if bn == 1 then 0
 else if doy < doy[1] then (doy_offset - dow_offset + adj)
 else woy_offset[1];

# week of year
def woy = floor((doy + woy_offset) / 7) + 1;

# year cnt
def years = if bn == 1 then 1
 else if doy < doy[1] then years[1] + 1
 else years[1];

#addchartbubble(0, low, years, color.cyan, no);

#-----------------------------

# match week of year
def woy_first = if bn == 1 then 0
 else if woy_first[1] > 0 then woy_first[1]
 else if month == month2 and day == day2 then woy
 else woy_first[1];

# match day of week
def dow_first = if bn == 1 then 0
 else if dow_first[1] > 0 then dow_first[1]
 else if month == month2 and day == day2 then dow
 else dow_first[1];

def match2 = (woy_first == woy and dow_first == dow);
addverticalline(match2, "--", color.green);

def up_cnt = if bn == 1 then 0
 else if match2 and up then up_cnt[1] + 1
 else up_cnt[1];


addlabel(1, "week of year " + woy_first, color.yellow);
addlabel(1, "Day of week " + dow_first, color.yellow);
addlabel(1, "  " , color.black);
addlabel(1, "date up counts " + up_cnt + " in " + year_count + " years", color.yellow);


addchartbubble(match2, low,
up_cnt
, color.yellow, no);

#--------------------------


def f = 4;
def y1 = (1-(0.001*f));
def y2 = y1;

input test1_dow_woy = no;
addchartbubble(test1_dow_woy, low*y2,
#doy + " doy\n" +
dow + " dow\n" +
#dom + " m\n" +
#week_off + "\n" +
#woy_offset + "\n" +
woy + " woy" + "\n" +
woy_first + "\n" +
dow_first
, (if woy != woy[1] then color.yellow else color.gray), no);


input test2_firsts = no;
addchartbubble(test2_firsts and match2, low*y2,
 "up counts\n" +
 up_cnt + "\n" +
 woy_first + " week of year\n" +
 dow_first + " day of week\n" +
 woy + "\n" +
 dow + "\n"
, color.green, no);


input test3_week_of_year = no;
plot xday = if test3_week_of_year then woy else na;
xday.SetPaintingStrategy(PaintingStrategy.VALUES_below);
xday.SetDefaultColor(Color.YELLOW);


input test4_day_of_week = yes;
plot dow_num = if test4_day_of_week then dow else Double.NaN;
dow_num.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
dow_num.SetDefaultColor(Color.YELLOW);


input test5_day_of_week_text = no;
def bubble_offset = 10;
#AddChartBubble(test2_days_week and show_day_of_week == show_day_of_week.text,
AddChartBubble( test5_day_of_week_text, high * (1 + bubble_offset * .002),
    (if dow == 1 then "Mon"
else if dow == 2 then "Tues"
else if dow == 3 then "Wed"
else if dow == 4 then "thur"
else if dow == 5 then "Fri"
else if dow == 6 then "Sat"
else "SU")
, Color.YELLOW, yes);
#
#

KHC 5Yr Day
2021 (middle of chart)
top #s are day or week, 1-5
up to and including this date, there are 3 up bars on the date of 20th week, day 5
there are a total of 4 up bars, over 6 years
UMlx4xd.jpg
 
Last edited:
Hello @samer800

I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). If its a weekend on that input day, it can be ignored or consider the next day's close>open comparison, if possible.

This day could be an input or if it can be found programmatically, it could be even better but is this something possible with thinkscript or the platform doesn't support it?


Thanks!
here is a different version

this is a study to show what could be done. it takes a lot of formulas.

this finds 'up' bar counts, for the first 4 weeks of the years on a chart.
there are 10 formulas for each week. for this to work for the whole year, the 10 formulas would have to be copied 48 times and modified.

it calculates the week of year and day of week, and matches up same numbers, year to year.

colored labels show a color quantity legend for the bubbles
colored bubbles show the count of up bars

can show bubbles for each year or just current year.

Code:
#perform_well_on_day_of_year

#https://usethinkscript.com/threads/finding-stock-that-performs-well-on-a-particular-day-of-year.16929/

#Finding stock that performs well on a particular day of year
#I want to find out whether a stock has closed +ve (close>open) on a particular day (which will probably be an input) for last x years (on the same day). 

def na = double.nan;
def bn = barnumber();

def up = close > open;
def dwn = close < open;

def doy = getday();
def dow = GetDayofWeek(GetYYYYMMDD());
def dom = GetDayofMonth(GetYyyyMmDd());

input current_year = yes;
def last_year = GetYear() == GetLastYear();
def yr = if current_year then last_year else 1;


# week of year calcs
def doy_offset = 8 - doy;
def dow_offset = (8 - dow);
def adj = -1;
# calc offset for week of each year
def woy_offset = if bn == 1 then 0
 else if doy < doy[1] then (doy_offset - dow_offset + adj)
 else woy_offset[1];
# week of year
def woy = floor((doy + woy_offset) / 7) + 1;

# year cnt
def years = if bn == 1 then 1
 else if doy < doy[1] then years[1] + 1
 else years[1];

addchartbubble(0, low, years, color.cyan, no);

# vert offset for bubbles
def f = 4;
def y1 = (1-(0.001*f));
def y2 = y1;

input test1 = no;
addchartbubble(test1, low*y2,
#doy + " doy\n" +
dow + " dow\n" +
#dom + " m\n" +
#week_off + "\n" +
#woy_offset + "\n" +
woy + " woy"
, (if woy != woy[1] then color.yellow else color.gray), no);
#, (if dow == 1 then color.yellow else color.gray), no);


# day counts , ups / (years). each day of years
# week 1-52 , day 1-5 ,  w012
def w011 = if (woy == 1 and dow == 1) then w011[1] + up else w011[1];
def w012 = if (woy == 1 and dow == 2) then w012[1] + up else w012[1];
def w013 = if (woy == 1 and dow == 3) then w013[1] + up else w013[1];
def w014 = if (woy == 1 and dow == 4) then w014[1] + up else w014[1];
def w015 = if (woy == 1 and dow == 5) then w015[1] + up else w015[1];

def w021 = if (woy == 2 and dow == 1) then w021[1] + up else w021[1];
def w022 = if (woy == 2 and dow == 2) then w022[1] + up else w022[1];
def w023 = if (woy == 2 and dow == 3) then w023[1] + up else w023[1];
def w024 = if (woy == 2 and dow == 4) then w024[1] + up else w024[1];
def w025 = if (woy == 2 and dow == 5) then w025[1] + up else w025[1];

def w031 = if (woy == 3 and dow == 1) then w031[1] + up else w031[1];
def w032 = if (woy == 3 and dow == 2) then w032[1] + up else w032[1];
def w033 = if (woy == 3 and dow == 3) then w033[1] + up else w033[1];
def w034 = if (woy == 3 and dow == 4) then w034[1] + up else w034[1];
def w035 = if (woy == 3 and dow == 5) then w035[1] + up else w035[1];

def w041 = if (woy == 4 and dow == 1) then w041[1] + up else w041[1];
def w042 = if (woy == 4 and dow == 2) then w042[1] + up else w042[1];
def w043 = if (woy == 4 and dow == 3) then w043[1] + up else w043[1];
def w044 = if (woy == 4 and dow == 4) then w044[1] + up else w044[1];
def w045 = if (woy == 4 and dow == 5) then w045[1] + up else w045[1];


# bubble colors
#  green , cnt = years
#  cyan , cnt = years - 1
#  yellow , cnt = years - 2
#  blue , cnt = years - 3
#  red , cnt = years - 4

addlabel(1, years + " years", color.cyan);
addlabel(1, "  ", color.black);
addlabel(1, (years-0), color.green);
addlabel(1, (years-1), color.cyan);
addlabel(1, (years-2), color.yellow);
addlabel(1, (years-3), color.blue);
addlabel(1, (years-4), color.red);


input bubbles_ups = yes;
addchartbubble(bubbles_ups and yr and (woy == 1 and dow == 1), low*y1, w011, (if w011 == (years-0) then color.green else if w011 == (years-1) then color.cyan else if w011 == (years-2) then color.yellow else if w011 == (years-3) then color.blue else if w011 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 1 and dow == 2), low*y1, w012, (if w012 == (years-0) then color.green else if w012 == (years-1) then color.cyan else if w012 == (years-2) then color.yellow else if w012 == (years-3) then color.blue else if w012 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 1 and dow == 3), low*y1, w013, (if w013 == (years-0) then color.green else if w013 == (years-1) then color.cyan else if w013 == (years-2) then color.yellow else if w013 == (years-3) then color.blue else if w013 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 1 and dow == 4), low*y1, w014, (if w014 == (years-0) then color.green else if w014 == (years-1) then color.cyan else if w014 == (years-2) then color.yellow else if w014 == (years-3) then color.blue else if w014 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 1 and dow == 5), low*y1, w015, (if w015 == (years-0) then color.green else if w015 == (years-1) then color.cyan else if w015 == (years-2) then color.yellow else if w015 == (years-3) then color.blue else if w015 == (years-4) then color.red else color.gray), no);

addchartbubble(bubbles_ups and yr and (woy == 2 and dow == 1), low*y1, w021, (if w021 == (years-0) then color.green else if w021 == (years-1) then color.cyan else if w021 == (years-2) then color.yellow else if w021 == (years-3) then color.blue else if w021 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 2 and dow == 2), low*y1, w022, (if w022 == (years-0) then color.green else if w022 == (years-1) then color.cyan else if w022 == (years-2) then color.yellow else if w022 == (years-3) then color.blue else if w022 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 2 and dow == 3), low*y1, w023, (if w023 == (years-0) then color.green else if w023 == (years-1) then color.cyan else if w023 == (years-2) then color.yellow else if w023 == (years-3) then color.blue else if w023 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 2 and dow == 4), low*y1, w024, (if w024 == (years-0) then color.green else if w024 == (years-1) then color.cyan else if w024 == (years-2) then color.yellow else if w024 == (years-3) then color.blue else if w024 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 2 and dow == 5), low*y1, w025, (if w025 == (years-0) then color.green else if w025 == (years-1) then color.cyan else if w025 == (years-2) then color.yellow else if w025 == (years-3) then color.blue else if w025 == (years-4) then color.red else color.gray), no);

addchartbubble(bubbles_ups and yr and (woy == 3 and dow == 1), low*y1, w031, (if w031 == (years-0) then color.green else if w031 == (years-1) then color.cyan else if w031 == (years-2) then color.yellow else if w031 == (years-3) then color.blue else if w031 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 3 and dow == 2), low*y1, w032, (if w032 == (years-0) then color.green else if w032 == (years-1) then color.cyan else if w032 == (years-2) then color.yellow else if w032 == (years-3) then color.blue else if w032 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 3 and dow == 3), low*y1, w033, (if w033 == (years-0) then color.green else if w033 == (years-1) then color.cyan else if w033 == (years-2) then color.yellow else if w033 == (years-3) then color.blue else if w033 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 3 and dow == 4), low*y1, w034, (if w034 == (years-0) then color.green else if w034 == (years-1) then color.cyan else if w034 == (years-2) then color.yellow else if w034 == (years-3) then color.blue else if w034 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 3 and dow == 5), low*y1, w035, (if w035 == (years-0) then color.green else if w035 == (years-1) then color.cyan else if w035 == (years-2) then color.yellow else if w035 == (years-3) then color.blue else if w035 == (years-4) then color.red else color.gray), no);

addchartbubble(bubbles_ups and yr and (woy == 4 and dow == 1), low*y1, w041, (if w041 == (years-0) then color.green else if w041 == (years-1) then color.cyan else if w041 == (years-2) then color.yellow else if w041 == (years-3) then color.blue else if w041 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 4 and dow == 2), low*y1, w042, (if w042 == (years-0) then color.green else if w042 == (years-1) then color.cyan else if w042 == (years-2) then color.yellow else if w042 == (years-3) then color.blue else if w042 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 4 and dow == 3), low*y1, w043, (if w043 == (years-0) then color.green else if w043 == (years-1) then color.cyan else if w043 == (years-2) then color.yellow else if w043 == (years-3) then color.blue else if w043 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 4 and dow == 4), low*y1, w044, (if w044 == (years-0) then color.green else if w044 == (years-1) then color.cyan else if w044 == (years-2) then color.yellow else if w044 == (years-3) then color.blue else if w044 == (years-4) then color.red else color.gray), no);
addchartbubble(bubbles_ups and yr and (woy == 4 and dow == 5), low*y1, w045, (if w045 == (years-0) then color.green else if w045 == (years-1) then color.cyan else if w045 == (years-2) then color.yellow else if w045 == (years-3) then color.blue else if w045 == (years-4) then color.red else color.gray), no);

#---------------------

input test3_week_num = no;
plot xday = if test3_week_num then woy else na;
xday.SetPaintingStrategy(PaintingStrategy.VALUES_below);
xday.SetDefaultColor(Color.YELLOW);


input day_of_week_num = yes;
plot dow_num = if day_of_week_num then dow else Double.NaN;
dow_num.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
dow_num.SetDefaultColor(Color.YELLOW);


input day_of_week_text = no;
input bubble_offset = 10;
AddChartBubble( day_of_week_text, high * (1 + bubble_offset * .002),
    (if dow == 1 then "Mon"
else if dow == 2 then "Tues"
else if dow == 3 then "Wed"
else if dow == 4 then "thur"
else if dow == 5 then "Fri"
else if dow == 6 then "Sat"
else "SU")
, Color.YELLOW, yes);
#
#

4 weeks of bubbles,
bubbles with the up count , for each bar, week# / day#
cWY76eB.jpg
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
317 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top