Levels scanner For ThinkOrSwim

This tool is designed to scan for specific conditions in the price action and moving averages of a given security. Here's an explanation of the script:

  1. Study Definition: The script is declared as a lower study, which means it will be plotted on the chart below the price action.
  2. Input Variables: The script allows you to customize various input variables to adjust the length of exponential moving averages (EMAs) used in the calculations. The lengths specified are length1, length2, length3, length4, and length5.
  3. Exponential Moving Averages (EMA): The script calculates five EMAs based on the closing prices of the security using the lengths provided in the input variables. The EMAs are stored in the variables ema1, ema2, ema3, ema4, and ema5, respectively.
  4. Upside and Downside Gaps: The script scans for upside and downside gaps in the price action. An upside gap occurs when the open price is higher than the previous close, and the low price is higher than the previous high. A downside gap occurs when the open price is lower than the previous close, and the high price is lower than the previous low. These conditions are captured using the upsideGap and downsideGap variables.
  5. Breaks Above EMAs: The script scans for breaks above the EMAs. It checks if the current close price is higher than the previous EMA value and if the low price is also higher than the previous EMA value for each EMA length. These conditions are captured using the breakAboveEMA1, breakAboveEMA2, breakAboveEMA3, breakAboveEMA4, and breakAboveEMA5 variables.
  6. Demand and Supply Breaks: The script scans for demand breaks to the downside and supply breaks to the upside. A demand break occurs when the open price is lower than the previous close, and the low price is lower than the previous low. A supply break occurs when the open price is higher than the previous close, and the high price is higher than the previous high. These conditions are captured using the demandBreak and supplyBreak variables.
  7. Scan Filters: The scan filters are combined using the "or" logical operator to identify any occurrence of the defined conditions. The plot "scanFilter" is assigned the value of true whenever any of the conditions (upsideGap, downsideGap, breakAboveEMA1, breakAboveEMA2, breakAboveEMA3, breakAboveEMA4, breakAboveEMA5, demandBreak, or supplyBreak) are met.
The levels scanner tool helps identify potential trading opportunities based on specified conditions, such as gaps, breaks above EMAs, demand breaks, and supply breaks. You can install the script under "scanners" then "studies" and then "custom".
Ruby:
# Levels scanner created by Trader4TOS 06/22/2023

# Additional features include Supply and Demand criteria. Along with gap fills.

# Define study
declare lower;

# Define input variables
input length1 = 21;
input length2 = 50;
input length3 = 100;
input length4 = 200;
input length5 = 300;

# Calculate exponential moving averages (EMA)
def ema1 = ExpAverage(close, length1);
def ema2 = ExpAverage(close, length2);
def ema3 = ExpAverage(close, length3);
def ema4 = ExpAverage(close, length4);
def ema5 = ExpAverage(close, length5);

# Scan for upside and downside gaps
def upsideGap = open > close[1] and low > high[1];
def downsideGap = open < close[1] and high < low[1];

# Scan for breaks above EMAs
def breakAboveEMA1 = close > ema1[1] and low > ema1[1];
def breakAboveEMA2 = close > ema2[1] and low > ema2[1];
def breakAboveEMA3 = close > ema3[1] and low > ema3[1];
def breakAboveEMA4 = close > ema4[1] and low > ema4[1];
def breakAboveEMA5 = close > ema5[1] and low > ema5[1];

# Scan for demand breaks to the downside and supply breaks to the upside
def demandBreak = open < close[1] and low < low[1];
def supplyBreak = open > close[1] and high > high[1];

# Add scan filters
plot scanFilter = upsideGap or downsideGap or breakAboveEMA1 or breakAboveEMA2 or breakAboveEMA3 or breakAboveEMA4 or breakAboveEMA5 or demandBreak or supplyBreak;
 
Last edited:

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
223 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