@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!
I think if you just post it here in the thread, will be good. I don't do discord. Thanks for making it better.@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!
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.I built it to be used on the 1 min timeframe.
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 againThe 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.
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!I built it to be used on the 1 min timeframe.
I would also be interested in your code modification if you are willing to post it. Thank you.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
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.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!
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.I would also be interested in your code modification if you are willing to post it. Thank you.
#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
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 instantDon'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]);
Isn't close[-7], looking ahead 7 bars ?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 changed the line from def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[-7]);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.
Maybe you found a bug lol. I always thought negative was looking backward into the pastIsn't close[-7], looking ahead 7 bars ?
@miklosh13 is correct... Positive numbers for lookback and negative for lookahead...Maybe you found a bug lol. I always thought negative was looking backward into the past
I'll try
def overSoldRSIHeavy = RSI <= 30 and Diff < 0 and (close < close[7])
I created 2 versions and compared: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
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.