Volume Pressure Upper For ThinkOrSwim

relative volume spike with ATR and stop loss plotting

I have been working on an indicator that can detect buying volume spikes that end in a green candle, closes above an EMA, takes the previous ATR value of that spike, and and plots a line below the low of the candle 1 previous ATR below it. The line disappears when the candle opens below that ATR stop.

I have been using this to get into MOMO stocks when the insiders/algos do before the PR is released and then I sell into the spike. It is a slight variation of this https://usethinkscript.com/threads/volume-buy-sell-pressure-with-hot-percent-for-thinkorswim.389/.

I just added some other checks to fit a swing style trader that uses spikes to detect loading.
Shout out to everyone that helped with the buy/sell pressure indicator. I have used it for years and developed a strategy based off it.

I call the below Volume_Pressure_Upper

Code:
# Original author: Unknown
# Modified by 7of9



#Inputs


input UnusualVolumePercent = 10000;
input NumberOfPlotsMax4 = 4;
input ATRLength= 14;
input ATRAvgType = AverageType.ExponentIAL;
Input EMALength = 200;
def NumberOfBarsToCheck = 200;




def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def nan=double.nan;
def LowMinusAtr = low - reference ATR (length = ATRLength, averageType = ATRAvgType)[1];

def UnusualVolumeCondition = if percentOf30Bar >= UnusualVolumePercent then 1 else 0;
def signal = if UnusualVolumeCondition == 1 then percentOf30Bar else Double.NaN;
def signal_long_only = UnusualVolumeCondition == 1 and open < close and close > MovAvgExponential(length = EMALength) ;

#def SupportLevel = if signal_long_only then low - reference ATR (length = ATRLength, averageType = ATRAvgType) else SupportLevel[1];

#plot supports=SupportLevel;



##test area
def bar = BarNumber();
def n = NumberOfBarsToCheck;

def hh = fold i = 1 to n + 1
with p = 1
while p
do signal_long_only ;

def PivotH = if (bar > n and
signal_long_only)
then LowMinusAtr
else Double.NaN;

def PHValue = if !IsNaN(PivotH)
then PivotH
else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH)
then bar
else PHBarOrigin[1];
def PHBarID = bar - PHBarOrigin;

# R2
def R2PHValue = if PHBarOrigin != PHBarOrigin[1]
then PHValue[1]
else R2PHValue[1];
def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1]
then PHBarOrigin[1]
else R2PHBarOrigin[1];
def R2PHBarID = bar - R2PHBarOrigin;
# R3
def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHValue[1]
else R3PHValue[1];
def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHBarOrigin[1]
else R3PHBarOrigin[1];
def R3PHBarID = bar - R3PHBarOrigin;
# R4
def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHValue[1]
else R4PHValue[1];
def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHBarOrigin[1]
else R4PHBarOrigin[1];
def R4PHBarID = bar - R4PHBarOrigin;


script LinePlot {
input BarID = 0;
input Value = 0;
input BarOrigin = 0;
def ThisBar = HighestAll(BarOrigin);
def ValueLine = if BarOrigin == ThisBar
then Value
else Double.NaN;
plot P = if ThisBar - BarID <= BarOrigin
then HighestAll(ValueLine)
else Double.NaN;
}

plot R1 = if NumberOfPlotsMax4 >=1 and open > PHValue and PHValue>0then LinePlot(BarID = PHBarID,
Value = PHValue,
BarOrigin = PHBarOrigin)
else nan;
R1.SetDefaultColor(Color.GREEN);
r1.SetLineWeight(5);
#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);

plot R2 = if NumberOfPlotsMax4 >=2 and open > R2PHValue and R2PHValue>0 then LinePlot(BarID = R2PHBarID,
Value = R2PHValue,
BarOrigin = R2PHBarOrigin)
else nan;
R2.SetDefaultColor(Color.GREEN);
r2.SetLineWeight(5);
#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);

plot R3 = if NumberOfPlotsMax4 >=3 and open > R3PHValue and R3PHValue>0 then LinePlot(BarID = R3PHBarID,
Value = R3PHValue,
BarOrigin = R3PHBarOrigin)
else nan;
R3.SetDefaultColor(Color.GREEN);
r3.SetLineWeight(5);
#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);

plot R4 = if NumberOfPlotsMax4 >=4 and open > R4PHValue and R4PHValue>0 then LinePlot(BarID = R4PHBarID,
Value = R4PHValue,
BarOrigin = R4PHBarOrigin)
else nan;
R4.SetDefaultColor(Color.GREEN);
r4.SetLineWeight(5);
#AddChartBubble(bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);
 
Last edited by a moderator:

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