Day Trading / Scalping - Entry and Exit For ThinkOrSwim

UpTwoBucks

EDUCATOR
This indicator measures the rate of change of a stock's price over a given period. It does this by calculating the difference between the current high price and the previous high price, as well as the difference between the previous low price and the current low price. It then takes the average of these differences over an 8-period time frame, and computes the ratio of the average high difference to the sum of the average high and average low differences, which is multiplied by 100 to give the final Line value. The resulting Line value is plotted on the chart and can be used as a technical indicator to help identify potential trend reversals or price breakouts. Works great when used with support and resistance lines.

Ruby:
#Works best on a 5 minute chart.

declare lower;

#This line creates a new variable high_diff which measures the difference between the current high price and the previous high price. The Max(0, ...) function ensures that high_diff is always positive or zero.
def high_diff = Max(0, high - high[1]);

#This line creates a new variable low_diff which measures the difference between the previous low price and the current low price. The Max(0, ...) function ensures that low_diff is always positive or zero.
def low_diff = Max(0, low[1] - low);

# This line creates a new variable high_avg which computes the 8-period simple moving average of high_diff.
def high_avg = Average(high_diff,8);

#This line creates a new variable low_avg which computes the 8-period simple moving average of low_diff.
def low_avg = Average(low_diff,8);

#This line creates a new plot called Line. The if statement checks if both high_avg and low_avg are zero, and sets the value of Line to 0 in this case. Otherwise, it computes the ratio of high_avg to the sum of high_avg and low_avg, multiplies by 100, and sets the result as the value of the Line.
plot Line = if high_avg == 0 && low_avg == 0 then 0 else high_avg / (high_avg + low_avg) * 100;

#This line sets the default color.

Line.SetDefaultColor(GetColor(9));
 
Last edited:

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

I made a couple of changes. Let me know what you think. It would be great if a coder could add code to turn line yellow when still in trend as this may make you get out when still in trend.

Code:
declare lower;

#This line creates a new variable high_diff which measures the difference between the current high price and the previous high price. The Max(0, ...) function ensures that high_diff is always positive or zero.
def high_diff = Max(0, high - high[1]);

#This line creates a new variable low_diff which measures the difference between the previous low price and the current low price. The Max(0, ...) function ensures that low_diff is always positive or zero.
def low_diff = Max(0, low[1] - low);

# This line creates a new variable high_avg which computes the 8-period simple moving average of high_diff.
input period = 8;
def high_avg = Average(high_diff, period);
def low_avg = Average(low_diff, period);
#def high_avg = Average(high_diff,8);

#This line creates a new variable low_avg which computes the 8-period simple moving average of low_diff.
#def low_avg = Average(low_diff,8);

#This line creates a new plot called Line. The if statement checks if both high_avg and low_avg are zero, and sets the value of Line to 0 in this case. Otherwise, it computes the ratio of high_avg to the sum of high_avg and low_avg, multiplies by 100, and sets the result as the value of the Line.
plot Line = if high_avg == 0 && low_avg == 0 then 0 else high_avg / (high_avg + low_avg) * 100;

# This line sets the color of the line to red when it goes down.
Line.AssignValueColor(if Line < Line[1] then Color.RED else GetColor(9));

@uptwobucks , You may want to try this indicator by @samer800 . It is similar but gives more accurate info at first glance. When the line changes from red/blue to white, that is a good exit almost every time. If line changes from red to blue or blue to red, I have noticed a quick reversal.
https://usethinkscript.com/threads/redk-chop-breakout-scout-v2-0-for-thinkorswim.12359/#post-106308
 
Last edited by a moderator:
I made a couple of changes. Let me know what you think. It would be great if a coder could add code to turn line yellow when still in trend as this may make you get out when still in trend.

Code:
declare lower;

#This line creates a new variable high_diff which measures the difference between the current high price and the previous high price. The Max(0, ...) function ensures that high_diff is always positive or zero.
def high_diff = Max(0, high - high[1]);

#This line creates a new variable low_diff which measures the difference between the previous low price and the current low price. The Max(0, ...) function ensures that low_diff is always positive or zero.
def low_diff = Max(0, low[1] - low);

# This line creates a new variable high_avg which computes the 8-period simple moving average of high_diff.
input period = 8;
def high_avg = Average(high_diff, period);
def low_avg = Average(low_diff, period);
#def high_avg = Average(high_diff,8);

#This line creates a new variable low_avg which computes the 8-period simple moving average of low_diff.
#def low_avg = Average(low_diff,8);

#This line creates a new plot called Line. The if statement checks if both high_avg and low_avg are zero, and sets the value of Line to 0 in this case. Otherwise, it computes the ratio of high_avg to the sum of high_avg and low_avg, multiplies by 100, and sets the result as the value of the Line.
plot Line = if high_avg == 0 && low_avg == 0 then 0 else high_avg / (high_avg + low_avg) * 100;

# This line sets the color of the line to red when it goes down.
Line.AssignValueColor(if Line < Line[1] then Color.RED else GetColor(9));

@uptwobucks , You may want to try this indicator by @samer800 . It is similar but gives more accurate info at first glance. When the line changes from red/blue to white, that is a good exit almost every time. If line changes from red to blue or blue to red, I have noticed a quick reversal.
https://usethinkscript.com/threads/redk-chop-breakout-scout-v2-0-for-thinkorswim.12359/#post-106308
Feel free to change as you wish. I'm partially blind so white works for me. Thanks
 
Last edited by a moderator:
A good scalping indicator for entry and exit is the TOS indicator "VossPredictiveFilter" with default settings. Signals for entry and exit is when the Voss filter crosses the Bandpass filter.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
477 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