Various experimental studies and strategies written in Thinkscript for users of the Thinkorswim investment platform.
USE AT YOUR OWN RISK!
Disclaimer: In order to demonstrate the functionality of these apps, actual ticker symbols may be used. However, we do not make recommendations or determine the suitability of any security or strategy for individual traders. Any investment decision you make in your self-directed account is solely your responsibility. Be sure to backtest any strategy to determine if you understand the risks involved with each strategy.
This ThinkOrSwim chart study visualizes the performance of a trading position over time. It plots the current Invested Capital and Total Profit as lines on a lower chart panel and displays the Time-Adjusted Return (a simplified Modified Dietz Return) as a label. The study leverages real-time position data to track capital deployment and profitability, with a special emphasis on the time-averaged invested capital for assessing capital efficiency.
- Invested Capital Plot: Tracks the current cost basis of your position (in dollars) as a dark green line.
- Total Profit Plot: Displays the combined realized and unrealized gains/losses (in dollars) as an orange line.
- Time-Adjusted Return: A label showing the return percentage, calculated as Total Profit divided by the time-averaged invested capital, adjusted for the duration capital was deployed.
- Labels:
- Average Invested Capital: Shows the time-averaged invested capital (in dollars). Only bars when some capital was working count. Bars without any invested capitals are not counted for the average.
- Total Profit: Displays the current total profit (in dollars).
- Time-Adjusted Return: Presents the return percentage.
- Customizable Colors: Users can adjust label colors via dropdown inputs (default: light gray).
Position Capital Efficiency and Time Weighted Returns Study can be imported directly into ToS Desktop from this link
- Execution Price: The study approximates the sale price for realized gains using the bar’s closing price (
close
) because ThinkOrSwim chart studies don’t provide access to exact execution prices. This is annotated in the code whererealizedPL
is calculated. - Time-Adjusted Return: This metric simplifies the traditional Modified Dietz method by using average invested capital instead of precise cash flow timing, making it practical within ThinkScript’s limitations but less granular.
Example ToS Charts with Capital Efficiency Study and trades along the price chart of example stocks.
Thinkscript source code is available in this repo: position-capital-efficiency.ts
This study was built in collaboration with Grok 3.
Leading market trend indicator that shows whether stocks in a given period have net new 52 week highs or net new lows. Generally if periods of net new highs are more frequent than periods with net new lows, it may indicate that a bullish market trend is forming. Respectively if periods of net new lows are more frequent, that may indicate that a bear market trend is forming.
Celebrity investor Matt Caruso explains in the video below when this indicator can be helpful:
New Highs and Lows ToS Study can be imported from this link
Example ToS Chart for TSLA and Net New Highs / Lows studies from NYSE and NASDAQ:
Thinkscript source code is available in this repo: new_highs_lows_STUDY.ts
Thinkscript code is based on Melvin's work.
The study uses ToS built-in Net Highs and Net Lows symbols such as : $NYHGH
, $NYLOW
and others. A more complete list is available in the ToS Learning Center.
This indicator is inspired by Matt Caruso 's CARS (Carusso Adaptive Relative Strength) indicator.
Relative Strength indicator is a popular tool for measuring whether a stock price is growing faster or slower relative to a base index. However when the stock is highly volatile, RS becomes a proxy for the stock price which is not very useful. This Beta Adjusted Relative Strength indicator removes the noise from RS by adjusting for the typical stock volatility relative to the index. See screenshot example below.
RS in solid gray line, and Beta Adjusted RS in dashed gray line. Notice how due to TSLA's high volatility relative to SPX (purple line), RS does not provide meaningful information at first glance. Whereas Beta Adjusted RS shows more pronounced spikes and slopes as a stock trend develops relative to the index.
Beta Adjusted Relative Strength ToS Study can be imported from this link .
Thinkscript source code is available in this repo: relative_strength_beta_adjusted_STUDY.ts
IBD CANSLIM is a popular system with a number of rules for recognizing and acting on leading stocks in cooperating market conditions. CANSLIM has extreme focus on True Market Leader (TML) stocks with exceptional fundamentals (IBD Composite Rating 96+).
This Thinkscript strategy is a simplified interpretation of the CANSLIM 52 week high breakout setup. It is intended to be used with pre-screened TML watchlist stocks. This strategy is NOT intended as a replacement for applying the full CANSLIM system. It is simply a tool to help spot entry opportunities within TML watchlists for further analysis.
NOT A RECOMMENDATION! NOT FINANCIAL ADVICE! USE AT YOUR OWN RISK!
NOTE: This strategy is designed and tested only for DAILY aggregation charts. Not tested for other aggregation periods.
Example ToS Chart applying this breakout strategy to AAPL:
This strategy seems to provide one possible answer to celebrity investor Mark Minervini's question posed on his Twitter/X account:
Direct Thinkorswim import via this link
Thinkscript source code is available in this repo: CANSLIM_Breakout_Strategy.ts
Bug fixes and improvements are welcome! Please read the CONTRIBUTING GUIDE and CODE OF CONDUCT before your first contribution.