DEEPWATER_THE ONE For ThinkOrSwim

@Deepwater the code is wonderful. i made a few tweaks to make it easier to understand. if you have time id like to discuss it more and get your thoughts. PM me or find me on Discord @ImKidKid thanks!
 

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

I built it to be used on the 1 min timeframe.

gJwTALf.png
 
I built it to be used on the 1 min timeframe.

gJwTALf.png
The good part is you can use it all or parts. I tried hard to keep noise out and leave what i call signals which is hard to do. make it too tight and you miss buy and sell signals. Make the filter too big and you let a bunch of noise through.
 
The good part is you can use it all or parts. I tried hard to keep noise out and leave what i call signals which is hard to do. make it too tight and you miss buy and sell signals. Make the filter too big and you let a bunch of noise through.
yeah theres a silver lining in it that you have to find! it definitely works though! ill have to read over your instructions to get a real grasp on how to use it properly! thanks again
 
I built it to be used on the 1 min timeframe.

gJwTALf.png
Is this version of the code available? It seems easier to read than the original. I think this is an interesting take on trying to anticipate reversals. I also wanted to suggest making it an upper study using signals instead of a lower study. It seems better suited for that format. I had only one other observation so far, your signals do extremely well in an upward trending condition but not so well in a downtrend. For instance, when the price has already gone into a downtrend and you have entry signal, its actually just reverting to the mean before it continues down again(see image). This is fine, however most of the time its not giving an exit signal which can lead to big losses if you don't know what you are looking for. Its not an easy issue to solve. You have definitely put together something interesting. Keep up the good work!
zcTnAhw.png
 
yeah theres a silver lining in it that you have to find! it definitely works though! ill have to read over your instructions to get a real grasp on how to use it properly! thanks again
I would also be interested in your code modification if you are willing to post it. Thank you.
 
Is this version of the code available? It seems easier to read than the original. I think this is an interesting take on trying to anticipate reversals. I also wanted to suggest making it an upper study using signals instead of a lower study. It seems better suited for that format. I had only one other observation so far, your signals do extremely well in an upward trending condition but not so well in a downtrend. For instance, when the price has already gone into a downtrend and you have entry signal, its actually just reverting to the mean before it continues down again(see image). This is fine, however most of the time its not giving an exit signal which can lead to big losses if you don't know what you are looking for. Its not an easy issue to solve. You have definitely put together something interesting. Keep up the good work!
zcTnAhw.png
The smaller Yellow spikes from the bottom, I don't buy on them. They are oversold markers. I buy on the stricter Yellow and Green spike up (the second one on your chart) when you see a green trapazoid that is an RSI < 30 for a period and it can be a good buy signal too. And actually the first buy signal would have been profitable with a stop loss. I do not consider my code a day trader study but you can scalp with it.
 
I would also be interested in your code modification if you are willing to post it. Thank you.
Here's what I got, the code was hard to understand and I am a novice coder but I tweaked the few things that I did understand to my liking.

Code:
#DEEPWATER_THE ONE 3/17/2021 rev
#tweaked by imkidkid for 1min timeframe
declare lower;
input length = 14;

input price = close;
input averageType = AverageType.WILDERS;

input fastLength = 3;
input slowLength =6;
input MACDLength = 9;
input averageTypeMACD = AverageType.simple;

def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def RSI = 50 * (ChgRatio + 1);
def RSIAvg3 = MovingAverage(averageType, (RSI), 7);
def RSIAvg5 = MovingAverage(averageType, (RSI),7);
#--------------------5 day MA
input displace = 0;
input showBreakoutSignals = no;
def MAvgExp14 = ExpAverage(price[-displace], 7);
#--------------------oversold
def twoBarPivotMACD = Diff > Diff[1] and Diff[1] > Diff[2] and Diff[2] < Diff[3] and Diff[3] < Diff [4];

def overSoldRSI = RSI <= 40 and Diff < 0;
def overSoldRSIHeavy = RSI <= 40 and Diff < 0 and (close < close[-7]);
def TrendReversalalert = (twoBarPivotMACD and Highest(overSoldRSI, 6) > 0) / 2;
#plot TrendReversal = (twoBarPivotMACD and Highest(overSoldRSI, 6) > 0) / 2;
#Alert(TrendReversalalert, "Buy Alert");
plot TrendReversal1 = (twoBarPivotMACD and Highest(overSoldRSIHeavy, 6) > 0) / 1.2;

TrendReversal1.SetDefaultColor(GetColor(6));#green

#-----------------------Overbought
def twoBarPivotMACD1 = Diff < Diff[1] and Diff[1] < Diff[2] and Diff[2] > Diff[3] and Diff[3] > Diff [4];

def overboughtRSI = RSI >= 65 and Diff > 0;
def overboughtRSIHeavy = RSI >= 65 and Diff > 0 and (close > close[-7]);
plot TrendReversalalert20 = 1 - (twoBarPivotMACD1 and highest(overboughtRSIheavy, 6) > 0) / 1.2;
#plot TrendReversal20 = 1 - ((RSIAvg3 >= 60 and RSIAvg3 < RSIAvg3[-2]) / 4) ;

#TrendReversal20.SetDefaultColor(GetColor(5)); #Red
#plot TrendReversal50 = 1 - ((RSIAvg5 >= 70 and close < MAvgExp14) / 2) ;
#TrendReversal50.SetDefaultColor(GetColor(0)); #Red
#AddLabel(yes, if TrendReversal20 < 1 then "Sell" else "");
#Alert( TrendReversal20 < 1 , "Chart is now Overbought ", Alert.BAR, Sound.Ring);
#AddLabel(TrendReversal20 < 1, "Chart is now Overbought ", Color.LIME);
input show_label = yes;
input show_bubble = no;
#--------------------------- Large 5X and 10X Volume Alert
input AverageLength = 100;
input VolumeMultiplier = 8;
input VolumeMultiplier2 = 5;
input MinutesAfterOpen = 30;

def AvgVol = Average(volume, AverageLength);
def VolX = (volume > AvgVol * VolumeMultiplier) ;
def Vol10X = (volume > AvgVol * 10) ;

Alert(VolX, Concat(GetSymbolPart(), " has a large volume spike." ), Alert.BAR, Sound.Chimes);
AddLabel(VolX > 0, " Has 5X Volume Spike ", Color.LIGHT_GREEN);
Alert(Vol10X, Concat(GetSymbolPart(), " has a large volume spike." ), Alert.BAR, Sound.Chimes);
AddLabel(Vol10X > 0, " Has 10X Volume Spike ", Color.LIGHT_GREEN);
#-------------------------------------GAP UP Price
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def GapUp =
IsUp[1] and
IsUp[0] and
high[1] < low[0] and
high[1] < open[0] and
(volume > AvgVol * 5) ;
Alert(GapUp, Concat(GetSymbolPart(), " GAPUP" ), Alert.BAR, Sound.Ring);
AddLabel(GapUp > 0, " GAP Up ", Color.LIGHT_GREEN);

#---------------------------------Large Price change 3%
def Priceup =
IsUp[1] and
IsUp[0] and
high[1] < high[0] and
high[2] * 1.02 < high[0] and
high[3] * 1.03 < high[0] and
(volume > AvgVol * 3) ;
Alert(Priceup, Concat(GetSymbolPart(), " Price JUMP" ), Alert.BAR, Sound.Bell);
AddLabel(Priceup > 0, " Price JUMP ", Color.CYAN);

#---------------------------------HugePrice change 6%
def Priceup2 =
IsUp[1] and
IsUp[0] and
high[1] < high[0] and
high[3] * 1.04 < high[0] and
high[4] * 1.06 < high[0] and
(volume > AvgVol * 3) ;
Alert(Priceup2, Concat(GetSymbolPart(), " JUMP! JUMP! JUMP" ), Alert.BAR, Sound.Chimes);
AddLabel(Priceup2 > 0, " JUMP! JUMP! JUMP ", Color.LIGHT_RED);

#-----------------------------------------------------------------------------------------
#--------------------------RSI cumulative running total
def MAvgExp7 = ExpAverage(price[-displace], 7);
def RSICalc = 50 * (ChgRatio + 1);
def RSICalc1 = if RSI > 60 then 3 else if RSI < 40 then -3 else 0;
def RSICalc2 = if RSI[1] > 60 then 2 else if RSI[1] < 30 then -2 else 0;
def RSICalc3 = if RSI[2] > 60 then 1 else if RSI[2] < 40 then -1 else 0;
def RSICalc4 = if RSI[3] > 60 then 1 else if RSI[3] < 40 then -1 else 0;
def RSICalc5 = if RSI[4] > 60 then 1 else if RSI[4] < 40 then -1 else 0;
def RSICalc6 = if RSI[5] > 60 then 1 else if RSI[5] < 40 then -1 else 0;
def RSICalc7 = if RSI[6] > 60 then 1 else if RSI[6] < 40 then -1 else 0;
def RSICalc8 = if RSI[7] > 60 then 1 else if RSI[7] < 40 then -1 else 0;
def RSICalc9 = if RSI[8] > 60 then 1 else if RSI[8] < 40 then -1 else 0;
def RSICalc10 = if RSI[9] > 60 then 1 else if RSI[9] < 40 then -1 else 0;
def RSICalc11 = if RSI[10] > 60 then 1 else if RSI[10] < 40 then -1 else 0;
def RSICalc12 = if RSI[11] > 60 then 1 else if RSI[11] < 40 then -1 else 0;
def RSICalc13 = if RSI[12] > 60 then 1 else if RSI[12] < 40 then -1 else 0;
def RSICalc14 = if RSI[13] > 60 then 1 else if RSI[13] < 40 then -1 else 0;
def RSICalc15 = if RSI[14] > 60 then 1 else if RSI[14] < 40 then -1 else 0;
def RSICalc16 = if RSI[15] > 60 then 1 else if RSI[15] < 40 then -1 else 0;
def RSICalc17 = if RSI[16] > 60 then 1 else if RSI[16] < 40 then -1 else 0;
def RSICalc18 = if RSI[17] > 60 then 1 else if RSI[17] < 40 then -1 else 0;
def RSICalc19 = if RSI[18] > 60 then 1 else if RSI[18] < 40 then -1 else 0;
def RSICalc20 = if RSI[19] > 60 then 1 else if RSI[19] < 40 then -1 else 0;
def RSICalc21 = if RSI[20] > 60 then 1 else if RSI[20] < 40 then -1 else 0;
def RSICalc22 = if RSI[21] > 60 then 1 else if RSI[21] < 40 then -1 else 0;
def RSICalc23 = if RSI[22] > 60 then 1 else if RSI[22] < 40 then -1 else 0;
def RSICalc24 = if RSI[23] > 60 then 1 else if RSI[23] < 40 then -1 else 0;
def RSICalc25 = if RSI[24] > 60 then 1 else if RSI[24] < 40 then -1 else 0;
def RSICalc26 = if RSI[25] > 60 then 1 else if RSI[25] < 40 then -1 else 0;
def RSICalc27 = if RSI[26] > 60 then 1 else if RSI[26] < 40 then -1 else 0;
def RSICalc28 = if RSI[27] > 60 then 1 else if RSI[27] < 40 then -1 else 0;
def RSICalc29 = if RSI[28] > 60 then 1 else if RSI[28] < 40 then -1 else 0;
def RSICalc30 = if RSI[29] > 60 then 1 else if RSI[29] < 40 then -1 else 0;


def RSI30DayAvg = RSICalc1 + RSICalc2 + RSICalc3 + RSICalc4 + RSICalc5 + RSICalc6 + RSICalc7 + RSICalc8 + RSICalc9 + RSICalc10 + RSICalc11 + RSICalc12 + RSICalc13 + RSICalc14 + RSICalc15 + RSICalc16 + RSICalc17 + RSICalc18 + RSICalc19 + RSICalc20 + RSICalc21 + RSICalc22 + RSICalc23 + RSICalc24 + RSICalc25 + RSICalc26 + RSICalc27 + RSICalc28 + RSICalc29 + RSICalc30;
AddLabel(RSI30DayAvg >= 10 and RSI30DayAvg < 19, " RSI SELL: " + RSI30DayAvg + " ", Color.ORANGE);
AddLabel(RSI30DayAvg >= 20, " RSI SELL: " + RSI30DayAvg + " ", Color.RED);
AddLabel(RSI30DayAvg <= -10 and RSI30DayAvg > -19, " RSI BUY: " + RSI30DayAvg + " ", Color.LIME);
AddLabel(RSI30DayAvg <= -20, " RSI BUY: " + RSI30DayAvg + " ", Color.DARK_GREEN);
#plot TrendReversal5 = 1 - ((RSI30DayAvg >= 10 and close < MAvgExp7) / 1.2) ;
#TrendReversal5.SetDefaultColor(GetColor(0)); #magenta
#plot TrendReversal6 = ((RSI30DayAvg <= -10 and close > MAvgExp7 ) * .5) ;
#TrendReversal6.SetDefaultColor(GetColor(6)); #green
#plot TrendReversal6a = ((RSI30DayAvg <= -20 and close > MAvgExp7) * .75) ;
#TrendReversal6.SetDefaultColor(GetColor(6)); #green
 
This is the SPY chart. The Original DEEPWATER THE ONE is on top of the IMKIDKID Mod indicator (page 2). This is for comparison. Small changes can cause big effects. Also i included AHs and PM price action( grey areas ) which can be very low in volume and not accurate as to regular market hours.

AMs5bD9.jpg
 
Last edited:
Yeah I did make the changes on the RTH timeframe. Thats where i'll be using it, but there is alot i dont understand still, id be glad to hear everyones thought on making it work better. Also the sensitivity of the spikes can be changed by tweaking "RSI" in the code

ie:
def overSoldRSI = RSI <= 40 and Diff < 0;
def overSoldRSIHeavy = RSI <= 40 and Diff < 0 and (close < close[-7]);


def overboughtRSI = RSI >= 65 and Diff > 0;
def overboughtRSIHeavy = RSI >= 65 and Diff > 0 and (close > close[-7]);
 
Don't know if this has been mentioned (I didn't see it), looks like a new green spike will show up after 7 bars have passed:

def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);
 
Don't know if this has been mentioned (I didn't see it), looks like a new green spike will show up after 7 bars have passed:

def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);
Well have you seen RSI dip for a second < 30 which for most signals is a buy. by adding close < close[-7] that means it looks back 7 bars and says to get a overSoldRSIHEAVY it needs to to stay oversold for a bit longer than an instant
 
I had no idea what it meant that's why I was trying to discuss it with you before posting 😅 just trying to get a grasp on what the indicator is plotting in detail.
 
I had no idea what it meant that's why I was trying to discuss it with you before posting 😅 just trying to get a grasp on what the indicator is plotting in detail.
I changed the line from def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);
to
def overSoldRSIHeavy = RSI <= 30 and Diff < 0;

and it didn't have much effect in the plot result
 
I changed the line from def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);
to
def overSoldRSIHeavy = RSI <= 30 and Diff < 0;

and it didn't have much effect in the plot result
I created 2 versions and compared:

def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);

def overSoldRSIHeavy = RSI <= 30 and Diff < 0;

Overall, some, but not many false signals with -7. Maybe 5% false signals at most.

I created a scan with this indicator. With -7, won't find any signals early than 7 bars ago.

Still "def overSoldRSIHeavy = RSI <= 30 and Diff < 0;" may work well.

Nice indicator !! Thank you !!
 
The code gives plenty of great buy signals. It's figuring out when to sell and not sell too early. So I trade with a yellow + green spikes as buys and wait for an RSI cumulative Purple sell
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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