You can adjust the time frame in the setting of the watchlist.Regarding the Watchlist and the 60 - 80 What time frame is that on?
Okay, thanks I'll see if I can find that and adjust it.You can adjust the time frame in the setting of the watchlist.
please help develop this trading view indicator into tos..
https://www.tradingview.com/script/Rvl0takd-SharkWaveTrend/
@chewie76, would you care to share shareable link for TOS for this study.Yes. I created one. See below.
Code:#study(title = 'SharkWaveTrend', shorttitle = 'SharkWaveTrend') # Converted by Sam4Cok@Samer800 - 12/2023 input colorBars = no; input vwapShow = no;#(true, title = 'Show Fast WT', type = input.bool) input wtChannelLen = 5;#, title = 'WT Channel Length', type = input.integer) input wtAverageLen = 5;#, title = 'WT Average Length', type = input.integer) input wtMASource = hlc3;#, title = 'WT MA Source', type = input.source) input wtMaLen = 2;#, title = 'WT MA Length', type = input.integer) input obLevel = 53;#, title = 'WT Overbought Level 1', type = input.integer) input osLevel = -53;#, title = 'WT Oversold Level 1', type = input.integer) input wtShowDiv = yes;#(true, title = 'Show WT Regular Divergences', type = input.bool) input wtShowHiddenDiv = no;#(false, title = 'Show WT Hidden Divergences', type = input.bool) input showHiddenDiv_nl = yes;#(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool) input wtDivOBLevel = 45;#, title = 'WT Bearish Divergence min', type = input.integer) input wtDivOSLevel = -65;#, title = 'WT Bullish Divergence min', type = input.integer) input wtDivOBLevel_addshow = yes;#(true, title = 'Show 2nd WT Regular Divergences', type = input.bool) input wtDivOBLevel_add = 15;#, title = 'WT 2nd Bearish Divergence', type = input.integer) input wtDivOSLevel_add = -40;#, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer) input rsiMFIShow = no;#(true, title = 'Show MFI', type = input.bool) input rsiMFIperiod = 60;#,title = 'MFI Period', type = input.integer) input rsiMFIMultiplier = 150;#, title = 'MFI Area multiplier', type = input.float) input rsiMFIPosY = 2.5;#, title = 'MFI Area Y Pos', type = input.float) input showRsiLine = no; #(false, title = 'Show RSI', type = input.bool) input rsiSRC = close;#(close, title = 'RSI Source', type = input.source) input rsiLen = 12;#, title = 'RSI Length', type = input.integer) #input rsiOversold = 30;#, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer) #input rsiOverbought = 60;#, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer) input rsiShowDiv = yes;#(false, title = 'Show RSI Regular Divergences', type = input.bool) input rsiShowHiddenDiv = no;#(false, title = 'Show RSI Hidden Divergences', type = input.bool) input rsiDivOBLevel = 60;#, title = 'RSI Bearish Divergence min', type = input.integer) input rsiDivOSLevel = 30;#, title = 'RSI Bullish Divergence min', type = input.integer) input stochShow = no;#(true, title = 'Show Stochastic RSI', type = input.bool) input stochUseLog = yes;#(true, title=' Use Log?', type = input.bool) input stochAvg = no;#(false, title='Use Average of both K & D', type = input.bool) input stochSRC = close;#(close, title = 'Stochastic RSI Source', type = input.source) input stochLen = 14;#, title = 'Stochastic RSI Length', type = input.integer) input stochRsiLen = 14;#, title = 'RSI Length ', type = input.integer) input stochKSmooth = 3;#, title = 'Stochastic RSI K Smooth', type = input.integer) input stochDSmooth = 3;#, title = 'Stochastic RSI D Smooth', type = input.integer) input stochShowDiv = yes;#(false, title = 'Show Stoch Regular Divergences', type = input.bool) input stochShowHiddenDiv = no;#(false, title = 'Show Stoch Hidden Divergences', type = input.bool) input rsiLengthInput = 12;#, minval=1, title="RSI Length", group="Shark") input rsiSourceInput = close;#, "Source", group="Shark") input length2 = 30;#, minval=1, group="Shark") input src = close;#, title="Source", group="Shark") input mult = 2.0;#, minval=0.001, maxval=50, title="StdDev", group="Shark") input offset = 0;#, "Offset", minval = -500, maxval = 500, group="Shark") input HighlightBreaches = yes;#, title="Highlight Oversold/Overbought", group="Shark") input bApply25and75 = no;#, title="Apply 25/75 RSI rule", group="Shark") def na = Double.NaN; def last = IsNaN(close); def pos = Double.POSITIVE_INFINITY; def neg = Double.NEGATIVE_INFINITY; DefineGlobalColor("intense_red", Color.RED);#CreateColor(255, 35, 35)); DefineGlobalColor("regular_red", Color.DARK_RED);#CreateColor(255, 82, 82)); DefineGlobalColor("intense_green", Color.GREEN);#CreateColor(0, 230, 118)); DefineGlobalColor("regular_green", Color.DARK_GREEN);#CreateColor(76, 175, 80)); #DefineGlobalColor("wt1", CreateColor(217,205,205)); DefineGlobalColor("wt1", Color.WHITE); DefineGlobalColor("wt2", CreateColor(51, 102, 255)); #DefineGlobalColor("wt2", CreateColor(29, 63, 97)); #// } FUNCTIONS #f_findDivs(src, topLimit, botLimit, useLimits) => script f_findDivs { input src = close; input topLimit = 70; input botLimit = 30; input useLimits = yes; def na = Double.NaN; def topfractal = src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]; def botfractal = src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]; def top_fractal = if IsNaN(topfractal) then 0 else topfractal; def bot_fractal = if IsNaN(botfractal) then 0 else botfractal; def fractalize = if top_fractal then 1 else if bot_fractal then -1 else 0; def fractalTop = if fractalize > 0 and (if useLimits then src[2] >= topLimit else yes) then src[2] else na; def fractalBot = if fractalize < 0 and (if useLimits then src[2] <= botLimit else yes) then src[2] else na; def TopCond = if !IsNaN(fractalTop) and fractalTop then fractalTop else 0; def BotCond = if !IsNaN(fractalBot) and fractalBot then fractalBot else 0; def highPrev0; def highPrev1; def highPrice0; def highPrice1; if TopCond { highPrev1 = highPrev0[1]; highPrev0 = src[2]; highPrice1 = highPrice0[1]; highPrice0 = high[2]; } else { highPrev1 = highPrev1[1]; highPrev0 = highPrev0[1]; highPrice1 = highPrice1[1]; highPrice0 = highPrice0[1]; } def highPrev = highPrev1[2];#if highPrev1 != highPrev1[1] then highPrev1[1] else highPrev[1]; def highPrice = highPrice1[2];#if highPrice1 != highPrice1[1] then highPrice1[1] else highPrice[1]; def lowPrev0; def lowPrev1; def lowPrice0; def lowPrice1; if BotCond { lowPrev1 = lowPrev0[1]; lowPrev0 = src[2]; lowPrice1 = lowPrice0[1]; lowPrice0 = low[2]; } else { lowPrev1 = lowPrev1[1]; lowPrev0 = lowPrev0[1]; lowPrice1 = lowPrice1[1]; lowPrice0 = lowPrice0[1]; } def lowPrev = lowPrev1[2];#if lowPrev1 != lowPrev1[1] then lowPrev1[1] else lowPrev[1]; def lowPrice = lowPrice1[2];#if lowPrice1 != lowPrice1[1] then lowPrice1[1] else lowPrice[1]; def bearSignal = TopCond and high[2] > highPrice and src[2] < highPrev; def bullSignal = BotCond and low[2] < lowPrice and src[2] > lowPrev; def bearDivHidden = TopCond and high[2] < highPrice and src[2] > highPrev; def bullDivHidden = BotCond and low[2] > lowPrice and src[2] < lowPrev; plot top = if IsNaN(TopCond) then 0 else TopCond;#fractalTop; plot bot = if IsNaN(BotCond) then 0 else BotCond;#fractalBot; plot lowP = lowPrev; plot sigBear = if IsNaN(bearSignal) then 0 else bearSignal; plot sigBull = if IsNaN(bullSignal) then 0 else bullSignal; plot hidBear = if IsNaN(bearDivHidden) then 0 else bearDivHidden; plot hidBull = if IsNaN(bullDivHidden) then 0 else bullDivHidden; } #// Stochastic RSI script f_stochrsi { input _src = close; input _stochlen = 14; input _rsilen = 14; input _smoothk = 3; input _smoothd = 3; input _log = yes; input _avg = no; def src = if _log then Log(_src) else _src; def rsi = RSI(Price = src, Length = _rsilen); def stoch = 100 * (rsi - Lowest(rsi, _stochlen)) / (Highest(rsi, _stochlen) - Lowest(rsi, _stochlen)); def kk = Average(stoch, _smoothk); def d1 = Average(kk, _smoothd); def avg_1 = (kk + d1) / 2; def k = if _avg then avg_1 else kk; plot stochK = k; plot stochD = d1; } #/ RSI+MFI script f_rsimfi { input _period = 60; input _multiplier = 150; input rsiMFIPosY = 2.5; def c = close; def o = open; def h = high; def l = low; def dif = (c - o) / (h - l); def diff = if !IsNaN(dif) then dif else 0; def rsimfi = Average(diff * _multiplier, _period) - rsiMFIPosY; plot f_rsimfi = rsimfi; } #// WaveTrend script f_wavetrend { #def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1; input wtMASource = close; input wtChannelLen = 9; input wtAverageLen = 12; input wtMALen = 3; input obLevel = 53; input osLevel = -53; def tfsrc = wtMASource; def esa = ExpAverage(tfsrc, wtChannelLen); def de = ExpAverage(AbsValue(tfsrc - esa), wtChannelLen); def ci = (tfsrc - esa) / (0.015 * de); def wt1 = ExpAverage(ci, wtAverageLen); def wt2 = Average(wt1, wtMALen); def wtVwap = wt1 - wt2; def wtOversold = wt2 <= osLevel; def wtOverbought = wt2 >= obLevel; def wtCross = Crosses(wt1, wt2, CrossingDirection.ANY); def wtCrossUp = (wt2 - wt1) <= 0; def wtCrossDown = (wt2 - wt1) >= 0; def wtCrosslast = Crosses(wt1[2], wt2[2], CrossingDirection.ANY); def wtCrossUplast = (wt2[2] - wt1[2]) <= 0; def wtCrossDownlast = (wt2[2] - wt1[2]) >= 0; plot wt_1 = wt1; def wt_2 = wt2; def wt_OS = wtOversold; def wt_OB = wtOverbought; def wt_cross = wtCross; def wt_CrossUp = wtCrossUp; def wt_CrossDn = wtCrossDown; def wt_Vwap = wtVwap; } #// CALCULATE INDICATORS { #// RSI def rsi = RSI(Price = rsiSRC, Length = rsiLen); #// RSI + MFI Area def rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, rsiMFIPosY); #// Calculates WaveTrend def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1; def wt2 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_2; def wtOversold = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OS; def wtOverbought = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OB; def wtCross = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_cross; def wtCrossUp = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossUp; def wtCrossDown = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossDn; def wtVwap = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_Vwap; def shark0 = wt1 > 45 and wt1 <60; def nshark0 = wt1 < -45 and wt1 > -60; def shark1 = wt1 > 60 and wt1 < 80; def shark2 = wt1 > 80; def nshark1 = wt1 < -60 and wt1 > -80; def nshark2 = wt1 < -80; def crossup = wt1 crosses above wt2 and wt1 < -20; def crossdn = wt1 crosses below wt2 and wt1 > 20; #//KDJ indicator def Length = 14; def ll = Lowest(low, Length); def hh = Highest(high, Length); def rsv = (close - ll) / (hh - ll) * 100; script xsa { input src = close; input len = 0; input wei = 0; def sumf; def ma; def out; sumf = CompoundValue(1, sumf[1] - src[len] + src, src); ma = if IsNaN(src[len]) then Double.NaN else sumf / len; out = if IsNaN(out[1]) then ma else (src * wei + out[1] * (len - wei)) / len; plot return = out; } def k_ = xsa(rsv, 3, 1); def d_ = xsa(k_, 3, 1); def k = if k_ then k_ else na; def d = if d_ then d_ else na; def crossUp1 = Crosses(k, d, CrossingDirection.ABOVE); def crossDn1 = Crosses(d, k, CrossingDirection.BELOW); def buysig = if d < 25 and crossUp1 then -103 else na; def selsig = if d > 75 and crossDn1 then 103 else na; #//plot buy and sell signal def ple = buysig;#,color=color.green, linewidth=1,style=plot.style_area, transp=0) def pse = selsig;#,color=color.red, linewidth=2,style=plot.style_line, transp=0) #ple.SetDefaultColor(Color.cyan); #ple.SetPaintingStrategy(PaintingStrategy.POINTS); #ple.setlineWeight(5); #pse.SetDefaultColor(Color.magenta); #pse.SetPaintingStrategy(PaintingStrategy.POINTS); #pse.setlineWeight(5); AddLabel(yes, if buysig then "LB" else if crossup then "UP" else if selsig then "LS" else if crossdn then "DOWN" else if shark1 then "sell" else if shark2 then "XSELL" else if nshark1 then "buy" else if nshark2 then "XBUY" else " ", if shark1 or crossdn then color.white else if NSHARK1 or shark2 or crossup then color.blue else Color.BLACK); AssignBACKGROUNDColor( if shark0 then color.dark_red else if shark1 then color.red else if nshark0 then color.dark_green else if nshark1 then color.green else if nshark2 then color.cyan else if shark2 then color.magenta else color.black);
@chewie76, would you care to share shareable link for TOS for this study.
When i copied the code and created new study in TOS it doesn't work. I am probably doing something wrong but i shareable link always works. Big thanks.
#study(title = 'SharkWaveTrend', shorttitle = 'SharkWaveTrend')
# Converted by Sam4Cok@Samer800 - 12/2023
declare lower;
input colorBars = yes;
input vwapShow = no;#(true, title = 'Show Fast WT', type = input.bool)
input wtChannelLen = 9;#, title = 'WT Channel Length', type = input.integer)
input wtAverageLen = 12;#, title = 'WT Average Length', type = input.integer)
input wtMASource = hlc3;#, title = 'WT MA Source', type = input.source)
input wtMaLen = 3;#, title = 'WT MA Length', type = input.integer)
input obLevel = 53;#, title = 'WT Overbought Level 1', type = input.integer)
input osLevel = -53;#, title = 'WT Oversold Level 1', type = input.integer)
input wtShowDiv = yes;#(true, title = 'Show WT Regular Divergences', type = input.bool)
input wtShowHiddenDiv = no;#(false, title = 'Show WT Hidden Divergences', type = input.bool)
input showHiddenDiv_nl = yes;#(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool)
input wtDivOBLevel = 45;#, title = 'WT Bearish Divergence min', type = input.integer)
input wtDivOSLevel = -65;#, title = 'WT Bullish Divergence min', type = input.integer)
input wtDivOBLevel_addshow = yes;#(true, title = 'Show 2nd WT Regular Divergences', type = input.bool)
input wtDivOBLevel_add = 15;#, title = 'WT 2nd Bearish Divergence', type = input.integer)
input wtDivOSLevel_add = -40;#, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer)
input rsiMFIShow = no;#(true, title = 'Show MFI', type = input.bool)
input rsiMFIperiod = 60;#,title = 'MFI Period', type = input.integer)
input rsiMFIMultiplier = 150;#, title = 'MFI Area multiplier', type = input.float)
input rsiMFIPosY = 2.5;#, title = 'MFI Area Y Pos', type = input.float)
input showRsiLine = no; #(false, title = 'Show RSI', type = input.bool)
input rsiSRC = close;#(close, title = 'RSI Source', type = input.source)
input rsiLen = 14;#, title = 'RSI Length', type = input.integer)
#input rsiOversold = 30;#, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer)
#input rsiOverbought = 60;#, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer)
input rsiShowDiv = no;#(false, title = 'Show RSI Regular Divergences', type = input.bool)
input rsiShowHiddenDiv = no;#(false, title = 'Show RSI Hidden Divergences', type = input.bool)
input rsiDivOBLevel = 60;#, title = 'RSI Bearish Divergence min', type = input.integer)
input rsiDivOSLevel = 30;#, title = 'RSI Bullish Divergence min', type = input.integer)
input stochShow = no;#(true, title = 'Show Stochastic RSI', type = input.bool)
input stochUseLog = yes;#(true, title=' Use Log?', type = input.bool)
input stochAvg = no;#(false, title='Use Average of both K & D', type = input.bool)
input stochSRC = close;#(close, title = 'Stochastic RSI Source', type = input.source)
input stochLen = 14;#, title = 'Stochastic RSI Length', type = input.integer)
input stochRsiLen = 14;#, title = 'RSI Length ', type = input.integer)
input stochKSmooth = 3;#, title = 'Stochastic RSI K Smooth', type = input.integer)
input stochDSmooth = 3;#, title = 'Stochastic RSI D Smooth', type = input.integer)
input stochShowDiv = no;#(false, title = 'Show Stoch Regular Divergences', type = input.bool)
input stochShowHiddenDiv = no;#(false, title = 'Show Stoch Hidden Divergences', type = input.bool)
input rsiLengthInput = 14;#, minval=1, title="RSI Length", group="Shark")
input rsiSourceInput = close;#, "Source", group="Shark")
input length2 = 30;#, minval=1, group="Shark")
input src = close;#, title="Source", group="Shark")
input mult = 2.0;#, minval=0.001, maxval=50, title="StdDev", group="Shark")
input offset = 0;#, "Offset", minval = -500, maxval = 500, group="Shark")
input HighlightBreaches = yes;#, title="Highlight Oversold/Overbought", group="Shark")
input bApply25and75 = no;#, title="Apply 25/75 RSI rule", group="Shark")
def na = Double.NaN;
def last = IsNaN(close);
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
DefineGlobalColor("intense_red", Color.RED);#CreateColor(255, 35, 35));
DefineGlobalColor("regular_red", Color.DARK_RED);#CreateColor(255, 82, 82));
DefineGlobalColor("intense_green", Color.GREEN);#CreateColor(0, 230, 118));
DefineGlobalColor("regular_green", Color.DARK_GREEN);#CreateColor(76, 175, 80));
DefineGlobalColor("wt1", CreateColor(217,205,205));
DefineGlobalColor("wt2", CreateColor(29, 63, 97));
#// } FUNCTIONS
#f_findDivs(src, topLimit, botLimit, useLimits) =>
script f_findDivs {
input src = close;
input topLimit = 70;
input botLimit = 30;
input useLimits = yes;
def na = Double.NaN;
def topfractal = src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0];
def botfractal = src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0];
def top_fractal = if isNaN(topfractal) then 0 else topfractal;
def bot_fractal = if isNaN(botfractal) then 0 else botfractal;
def fractalize = if top_fractal then 1 else if bot_fractal then -1 else 0;
def fractalTop = if fractalize > 0 and (if useLimits then src[2] >= topLimit else yes) then src[2] else na;
def fractalBot = if fractalize < 0 and (if useLimits then src[2] <= botLimit else yes) then src[2] else na;
def TopCond = if !IsNaN(fractalTop) and fractalTop then fractalTop else 0;
def BotCond = if !IsNaN(fractalBot) and fractalBot then fractalBot else 0;
def highPrev0;
def highPrev1;
def highPrice0;
def highPrice1;
if TopCond {
highPrev1 = highPrev0[1];
highPrev0 = src[2];
highPrice1 = highPrice0[1];
highPrice0 = high[2];
} else {
highPrev1 = highPrev1[1];
highPrev0 = highPrev0[1];
highPrice1 = highPrice1[1];
highPrice0 = highPrice0[1];
}
def highPrev = highPrev1[2];#if highPrev1 != highPrev1[1] then highPrev1[1] else highPrev[1];
def highPrice = highPrice1[2];#if highPrice1 != highPrice1[1] then highPrice1[1] else highPrice[1];
def lowPrev0;
def lowPrev1;
def lowPrice0;
def lowPrice1;
if BotCond {
lowPrev1 = lowPrev0[1];
lowPrev0 = src[2];
lowPrice1 = lowPrice0[1];
lowPrice0 = low[2];
} else {
lowPrev1 = lowPrev1[1];
lowPrev0 = lowPrev0[1];
lowPrice1 = lowPrice1[1];
lowPrice0 = lowPrice0[1];
}
def lowPrev = lowPrev1[2];#if lowPrev1 != lowPrev1[1] then lowPrev1[1] else lowPrev[1];
def lowPrice = lowPrice1[2];#if lowPrice1 != lowPrice1[1] then lowPrice1[1] else lowPrice[1];
def bearSignal = TopCond and high[2] > highPrice and src[2] < highPrev;
def bullSignal = BotCond and low[2] < lowPrice and src[2] > lowPrev;
def bearDivHidden = TopCond and high[2] < highPrice and src[2] > highPrev;
def bullDivHidden = BotCond and low[2] > lowPrice and src[2] < lowPrev;
plot top = if isNaN(TopCond) then 0 else TopCond;#fractalTop;
plot bot = if isNaN(BotCond) then 0 else BotCond;#fractalBot;
plot lowP = lowPrev;
plot sigBear = if isNaN(bearSignal) then 0 else bearSignal;
plot sigBull = if isNaN(bullSignal) then 0 else bullSignal;
plot hidBear = if isNaN(bearDivHidden) then 0 else bearDivHidden;
plot hidBull = if isNaN(bullDivHidden) then 0 else bullDivHidden;
}
#// Stochastic RSI
script f_stochrsi {
input _src = close;
input _stochlen = 14;
input _rsilen = 14;
input _smoothk = 3;
input _smoothd = 3;
input _log = yes;
input _avg = no;
def src = if _log then Log(_src) else _src;
def rsi = RSI(Price = src, Length = _rsilen);
def stoch = 100 * (rsi - Lowest(rsi, _stochlen)) / (Highest(rsi, _stochlen) - Lowest(rsi, _stochlen));
def kk = Average(stoch, _smoothk);
def d1 = Average(kk, _smoothd);
def avg_1 = (kk + d1) / 2;
def k = if _avg then avg_1 else kk;
plot stochK = k;
plot stochD = d1;
}
#/ RSI+MFI
script f_rsimfi {
input _period = 60;
input _multiplier = 150;
input rsiMFIPosY = 2.5;
def c = close;
def o = open;
def h = high;
def l = low;
def dif = (c - o) / (h - l);
def diff = if !isNaN(dif) then dif else 0;
def rsimfi = Average(diff * _multiplier, _period) - rsiMFIPosY;
plot f_rsimfi = rsimfi;
}
#// WaveTrend
script f_wavetrend {
#def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1;
input wtMASource = close;
input wtChannelLen = 9;
input wtAverageLen = 12;
input wtMALen = 3;
input obLevel = 53;
input osLevel = -53;
def tfsrc = wtMASource;
def esa = ExpAverage(tfsrc, wtChannelLen);
def de = ExpAverage(AbsValue(tfsrc - esa), wtChannelLen);
def ci = (tfsrc - esa) / (0.015 * de);
def wt1 = ExpAverage(ci, wtAverageLen);
def wt2 = Average(wt1, wtMALen);
def wtVwap = wt1 - wt2;
def wtOversold = wt2 <= osLevel;
def wtOverbought = wt2 >= obLevel;
def wtCross = Crosses(wt1, wt2, CrossingDirection.ANY);
def wtCrossUp = (wt2 - wt1) <= 0;
def wtCrossDown = (wt2 - wt1) >= 0;
def wtCrosslast = Crosses(wt1[2], wt2[2], CrossingDirection.ANY);
def wtCrossUplast = (wt2[2] - wt1[2]) <= 0;
def wtCrossDownlast = (wt2[2] - wt1[2]) >= 0;
plot wt_1 = wt1;
plot wt_2 = wt2;
plot wt_OS = wtOversold;
plot wt_OB = wtOverbought;
plot wt_cross = wtCross;
plot wt_CrossUp = wtCrossUp;
plot wt_CrossDn = wtCrossDown;
plot wt_Vwap = wtVwap;
}
#// CALCULATE INDICATORS {
#// RSI
def rsi = RSI(Price = rsiSRC, Length = rsiLen);
#// RSI + MFI Area
def rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, rsiMFIPosY);
#// Calculates WaveTrend
def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1;
def wt2 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_2;
def wtOversold = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OS;
def wtOverbought = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OB;
def wtCross = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_cross;
def wtCrossUp = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossUp;
def wtCrossDown = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossDn;
def wtVwap = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_Vwap;
#// Stochastic RSI
def stochK = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg).stochK;
def stochD = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg).stochD;
#// WT Divergences
def wtBearDiv = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).sigBear;
def wtBullDiv = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).sigBull;
def wtBearDivHidden = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).hidBear;
def wtBullDivHidden = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).hidBull;
def wtBearDiv_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).sigBear;
def wtBullDiv_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).sigBull;
def wtBearDivHidden_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).hidBear;
def wtBullDivHidden_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).hidBull;
def wtBearDivHidden_nl = f_findDivs(wt2, 0, 0, no).hidBear;
def wtBullDivHidden_nl = f_findDivs(wt2, 0, 0, no).hidBull;
def wtBearDivHidden_ = if showHiddenDiv_nl then wtBearDivHidden_nl else wtBearDivHidden;
def wtBullDivHidden_ = if showHiddenDiv_nl then wtBullDivHidden_nl else wtBullDivHidden;
def wtBearDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBearDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBearDivHidden_add));# ? RED #9a0202 : na
def wtBullDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBullDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBullDivHidden_add));# ? GREEN #1b5e20 : na
plot wtBearAdd = if wtBearDivColor_add then 103 else na;
plot wtBullAdd = if wtBullDivColor_add then -103 else na;
wtBearAdd.SetDefaultColor(Color.DARK_RED);
wtBullAdd.SetDefaultColor(Color.DARK_GREEN);
wtBearAdd.SetPaintingStrategy(PaintingStrategy.POINTS);
wtBullAdd.SetPaintingStrategy(PaintingStrategy.POINTS);
plot wtBearHid = if wtBearDivHidden_ then 103 else na;
plot wtBullHid = if wtBullDivHidden_ then -103 else na;
wtBearHid.SetDefaultColor(Color.DARK_RED);
wtBullHid.SetDefaultColor(Color.DARK_GREEN);
wtBearHid.SetPaintingStrategy(PaintingStrategy.POINTS);
wtBullHid.SetPaintingStrategy(PaintingStrategy.POINTS);
#// RSI Divergences
def rsiBearDiv = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, yes).sigBear;
def rsiBullDiv = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, yes).sigBull;
#// Stoch Divergences
def stochBearDiv = f_findDivs(stochK, 0, 0, no).sigBear;
def stochBullDiv = f_findDivs(stochK, 0, 0, no).sigBull;
def stochBearDivHidden = f_findDivs(stochK, 0, 0, no).hidBear;
def stochBullDivHidden = f_findDivs(stochK, 0, 0, no).hidBull;
def stochBearDivColor = (stochShowDiv and stochBearDiv) or (stochShowHiddenDiv and stochBearDivHidden);#red
def stochBullDivColor = (stochShowDiv and stochBullDiv) or (stochShowHiddenDiv and stochBullDivHidden);#green
plot StBearHid = if stochBearDivColor then 103 else na;
plot StBullHid = if stochBullDivColor then -103 else na;
StBearHid.SetDefaultColor(Color.DARK_RED);
StBullHid.SetDefaultColor(Color.DARK_GREEN);
stBearHid.SetPaintingStrategy(PaintingStrategy.POINTS);
stBullHid.SetPaintingStrategy(PaintingStrategy.POINTS);
#// Buy signal.
def buySignal = wtCross and wtCrossUp and wtOversold;
def buySignalDiv = (wtShowDiv and wtBullDiv) or
(wtShowDiv and wtBullDiv_add) or
(stochShowDiv and stochBullDiv) or
(rsiShowDiv and rsiBullDiv);
#// Sell signal
def sellSignal = wtCross and wtCrossDown and wtOverbought;
def sellSignalDiv = (wtShowDiv and wtBearDiv) or
(wtShowDiv and wtBearDiv_add) or
(stochShowDiv and stochBearDiv) or
(rsiShowDiv and rsiBearDiv);
#// } CALCULATE INDICATORS
#// WT Areas
plot wtWave1 = wt1; # 'WT Wave 1'
plot wtWave2 = wt2; # 'WT Wave 2'
wtWave1.SetDefaultColor(GlobalColor("wt1"));
wtWave2.SetDefaultColor(GlobalColor("wt2"));
AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1"));
AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1"));
AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1"));
AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2"));
AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2"));
AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2"));
# RSI
plot rsiLine = if showRsiLine then rsi - 50 else na;
rsiLine.SetDefaultColor(Color.YELLOW);
#/ VWAP
def vwapArea = if vwapShow then wtVwap else na; # 'VWAP'
AddCloud(vwapArea, 0, Color.YELLOW, Color.YELLOW);
#// MFI AREA
def rsiMFIArea = if rsiMFIShow and !last then rsiMFI else na;#, style=plot.style_area, title='rsiMFI'
AddCloud(rsiMFIArea, 0, Color.GREEN, Color.RED);
# // Stoch RSI
plot stocKline = if stochShow then stochK - 50 else na;
plot stocDline = if stochShow then stochD - 50 else na;
stocKline.SetDefaultColor(Color.CYAN);
stocDline.SetDefaultColor(Color.DARK_ORANGE);
#--Sig
plot bSig = if buySignal then wt1 else na; # 'Buy circle'
plot sSig = if sellSignal then wt1 else na; # 'Sell circle'
bSig.SetPaintingStrategy(PaintingStrategy.SQUARES);
sSig.SetPaintingStrategy(PaintingStrategy.SQUARES);
bSig.SetDefaultColor(Color.GREEN);
sSig.SetDefaultColor(Color.RED);
def bSigDiv = buySignalDiv[-2];#, title = 'Divergence buy circle'
def sSigDiv = sellSignalDiv[-2];#, title = 'Divergence sell circle'
plot wbSigDiv = if sSigDiv then 103 else na;
plot wsSigDiv = if bSigDiv then -103 else na;
wbSigDiv.SetDefaultColor(Color.RED);
wsSigDiv.SetDefaultColor(Color.GREEN);
wbSigDiv.SetPaintingStrategy(PaintingStrategy.POINTS);
wsSigDiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#-- Shark
def ema50 = ExpAverage(src, 50);
def ema200 = ExpAverage(src, 200);
def ema400 = ExpAverage(src, 400);
def ema800 = ExpAverage(src, 800);
def wapwap = Reference vwap().VWAP;
def bTouchedLine = (ema50<high and ema50>low) or (ema200<high and ema200>low) or (ema400<high and ema400>low) or (ema800<high and ema800>low) or (wapwap<high and wapwap>low);
#// RSI
def changRsiSrc = rsiSourceInput - rsiSourceInput[1];
def upTR = WildersAverage(max(changRsiSrc, 0), rsiLengthInput);
def downTR = WildersAverage(-min(changRsiSrc, 0), rsiLengthInput);
#def rsiM = if downTR == 0 then 100 else if upTR == 0 then 0 else 100 - (100 / (1 + upTR / downTR));
def rsiM = RSI(Price = rsiSourceInput, Length = rsiLengthInput);
def basis = Average(rsiM[offset], length2);
def dev = mult * stdev(rsiM[offset], length2);
def upper = basis + dev;
def lower = basis - dev;
def bBelow = rsiM < 26;
def bAbove = rsiM > 74;
def bBelow25;def bAbove75;
if !bApply25and75 {
bBelow25 = yes;
bAbove75 = yes;
} else {
bBelow25 = bBelow;
bAbove75 = bAbove;
}
def b_color = if (rsiM > upper and bAbove75) then -1 else
if (rsiM < lower and bBelow25) then 1 else 0;
def barCol;
if bTouchedLine and b_color == -1 {
barCol = -2;
} else
if bTouchedLine and b_color == 1 {
barCol = 2;
} else {
barCol = b_color;
}
def sigSharkUp1 = if barCol > 1 then pos else neg;
def sigSharkUp2 = if barCol > 0 then pos else neg;
def sigSharkDn1 = if barCol <-1 then pos else neg;
def sigSharkDn2 = if barCol < 0 then pos else neg;
AddCloud(sigSharkUp1, neg, Color.GREEN);
AddCloud(sigSharkUp2, neg, Color.DARK_GREEN);
AddCloud(sigSharkDn1, neg, Color.RED);
AddCloud(sigSharkDn2, neg, Color.DARK_RED);
AssignPriceColor(if !colorBars then Color.CURRENT else
if barCol == 2 then GlobalColor("intense_green") else
if barCol == 1 then GlobalColor("regular_green") else
if barCol == -1 then GlobalColor("regular_red") else
if barCol == -2 then GlobalColor("intense_red") else Color.GRAY);
#-- END of CODE
I tried to scan for a "sell" signal but the system came back and said formula too complex for real time so scan could not be set up. Any ideas on what signal to use for this script that would work for real time for Sharks? I really appreciate your assistanceLooking for Shark Wave Scan that can be run on real time
https://usethinkscript.com/threads/sharkwavetrend-for-thinkorswim.17331/
Code:#study(title = 'SharkWaveTrend', shorttitle = 'SharkWaveTrend') # Converted by Sam4Cok@Samer800 - 12/2023 declare lower; input colorBars = yes; input vwapShow = no;#(true, title = 'Show Fast WT', type = input.bool) input wtChannelLen = 9;#, title = 'WT Channel Length', type = input.integer) input wtAverageLen = 12;#, title = 'WT Average Length', type = input.integer) input wtMASource = hlc3;#, title = 'WT MA Source', type = input.source) input wtMaLen = 3;#, title = 'WT MA Length', type = input.integer) input obLevel = 53;#, title = 'WT Overbought Level 1', type = input.integer) input osLevel = -53;#, title = 'WT Oversold Level 1', type = input.integer) input wtShowDiv = yes;#(true, title = 'Show WT Regular Divergences', type = input.bool) input wtShowHiddenDiv = no;#(false, title = 'Show WT Hidden Divergences', type = input.bool) input showHiddenDiv_nl = yes;#(true, title = 'Not apply OB/OS Limits on Hidden Divergences', type = input.bool) input wtDivOBLevel = 45;#, title = 'WT Bearish Divergence min', type = input.integer) input wtDivOSLevel = -65;#, title = 'WT Bullish Divergence min', type = input.integer) input wtDivOBLevel_addshow = yes;#(true, title = 'Show 2nd WT Regular Divergences', type = input.bool) input wtDivOBLevel_add = 15;#, title = 'WT 2nd Bearish Divergence', type = input.integer) input wtDivOSLevel_add = -40;#, title = 'WT 2nd Bullish Divergence 15 min', type = input.integer) input rsiMFIShow = no;#(true, title = 'Show MFI', type = input.bool) input rsiMFIperiod = 60;#,title = 'MFI Period', type = input.integer) input rsiMFIMultiplier = 150;#, title = 'MFI Area multiplier', type = input.float) input rsiMFIPosY = 2.5;#, title = 'MFI Area Y Pos', type = input.float) input showRsiLine = no; #(false, title = 'Show RSI', type = input.bool) input rsiSRC = close;#(close, title = 'RSI Source', type = input.source) input rsiLen = 14;#, title = 'RSI Length', type = input.integer) #input rsiOversold = 30;#, title = 'RSI Oversold', minval = 50, maxval = 100, type = input.integer) #input rsiOverbought = 60;#, title = 'RSI Overbought', minval = 0, maxval = 50, type = input.integer) input rsiShowDiv = no;#(false, title = 'Show RSI Regular Divergences', type = input.bool) input rsiShowHiddenDiv = no;#(false, title = 'Show RSI Hidden Divergences', type = input.bool) input rsiDivOBLevel = 60;#, title = 'RSI Bearish Divergence min', type = input.integer) input rsiDivOSLevel = 30;#, title = 'RSI Bullish Divergence min', type = input.integer) input stochShow = no;#(true, title = 'Show Stochastic RSI', type = input.bool) input stochUseLog = yes;#(true, title=' Use Log?', type = input.bool) input stochAvg = no;#(false, title='Use Average of both K & D', type = input.bool) input stochSRC = close;#(close, title = 'Stochastic RSI Source', type = input.source) input stochLen = 14;#, title = 'Stochastic RSI Length', type = input.integer) input stochRsiLen = 14;#, title = 'RSI Length ', type = input.integer) input stochKSmooth = 3;#, title = 'Stochastic RSI K Smooth', type = input.integer) input stochDSmooth = 3;#, title = 'Stochastic RSI D Smooth', type = input.integer) input stochShowDiv = no;#(false, title = 'Show Stoch Regular Divergences', type = input.bool) input stochShowHiddenDiv = no;#(false, title = 'Show Stoch Hidden Divergences', type = input.bool) input rsiLengthInput = 14;#, minval=1, title="RSI Length", group="Shark") input rsiSourceInput = close;#, "Source", group="Shark") input length2 = 30;#, minval=1, group="Shark") input src = close;#, title="Source", group="Shark") input mult = 2.0;#, minval=0.001, maxval=50, title="StdDev", group="Shark") input offset = 0;#, "Offset", minval = -500, maxval = 500, group="Shark") input HighlightBreaches = yes;#, title="Highlight Oversold/Overbought", group="Shark") input bApply25and75 = no;#, title="Apply 25/75 RSI rule", group="Shark") def na = Double.NaN; def last = IsNaN(close); def pos = Double.POSITIVE_INFINITY; def neg = Double.NEGATIVE_INFINITY; DefineGlobalColor("intense_red", Color.RED);#CreateColor(255, 35, 35)); DefineGlobalColor("regular_red", Color.DARK_RED);#CreateColor(255, 82, 82)); DefineGlobalColor("intense_green", Color.GREEN);#CreateColor(0, 230, 118)); DefineGlobalColor("regular_green", Color.DARK_GREEN);#CreateColor(76, 175, 80)); DefineGlobalColor("wt1", CreateColor(217,205,205)); DefineGlobalColor("wt2", CreateColor(29, 63, 97)); #// } FUNCTIONS #f_findDivs(src, topLimit, botLimit, useLimits) => script f_findDivs { input src = close; input topLimit = 70; input botLimit = 30; input useLimits = yes; def na = Double.NaN; def topfractal = src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]; def botfractal = src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]; def top_fractal = if isNaN(topfractal) then 0 else topfractal; def bot_fractal = if isNaN(botfractal) then 0 else botfractal; def fractalize = if top_fractal then 1 else if bot_fractal then -1 else 0; def fractalTop = if fractalize > 0 and (if useLimits then src[2] >= topLimit else yes) then src[2] else na; def fractalBot = if fractalize < 0 and (if useLimits then src[2] <= botLimit else yes) then src[2] else na; def TopCond = if !IsNaN(fractalTop) and fractalTop then fractalTop else 0; def BotCond = if !IsNaN(fractalBot) and fractalBot then fractalBot else 0; def highPrev0; def highPrev1; def highPrice0; def highPrice1; if TopCond { highPrev1 = highPrev0[1]; highPrev0 = src[2]; highPrice1 = highPrice0[1]; highPrice0 = high[2]; } else { highPrev1 = highPrev1[1]; highPrev0 = highPrev0[1]; highPrice1 = highPrice1[1]; highPrice0 = highPrice0[1]; } def highPrev = highPrev1[2];#if highPrev1 != highPrev1[1] then highPrev1[1] else highPrev[1]; def highPrice = highPrice1[2];#if highPrice1 != highPrice1[1] then highPrice1[1] else highPrice[1]; def lowPrev0; def lowPrev1; def lowPrice0; def lowPrice1; if BotCond { lowPrev1 = lowPrev0[1]; lowPrev0 = src[2]; lowPrice1 = lowPrice0[1]; lowPrice0 = low[2]; } else { lowPrev1 = lowPrev1[1]; lowPrev0 = lowPrev0[1]; lowPrice1 = lowPrice1[1]; lowPrice0 = lowPrice0[1]; } def lowPrev = lowPrev1[2];#if lowPrev1 != lowPrev1[1] then lowPrev1[1] else lowPrev[1]; def lowPrice = lowPrice1[2];#if lowPrice1 != lowPrice1[1] then lowPrice1[1] else lowPrice[1]; def bearSignal = TopCond and high[2] > highPrice and src[2] < highPrev; def bullSignal = BotCond and low[2] < lowPrice and src[2] > lowPrev; def bearDivHidden = TopCond and high[2] < highPrice and src[2] > highPrev; def bullDivHidden = BotCond and low[2] > lowPrice and src[2] < lowPrev; plot top = if isNaN(TopCond) then 0 else TopCond;#fractalTop; plot bot = if isNaN(BotCond) then 0 else BotCond;#fractalBot; plot lowP = lowPrev; plot sigBear = if isNaN(bearSignal) then 0 else bearSignal; plot sigBull = if isNaN(bullSignal) then 0 else bullSignal; plot hidBear = if isNaN(bearDivHidden) then 0 else bearDivHidden; plot hidBull = if isNaN(bullDivHidden) then 0 else bullDivHidden; } #// Stochastic RSI script f_stochrsi { input _src = close; input _stochlen = 14; input _rsilen = 14; input _smoothk = 3; input _smoothd = 3; input _log = yes; input _avg = no; def src = if _log then Log(_src) else _src; def rsi = RSI(Price = src, Length = _rsilen); def stoch = 100 * (rsi - Lowest(rsi, _stochlen)) / (Highest(rsi, _stochlen) - Lowest(rsi, _stochlen)); def kk = Average(stoch, _smoothk); def d1 = Average(kk, _smoothd); def avg_1 = (kk + d1) / 2; def k = if _avg then avg_1 else kk; plot stochK = k; plot stochD = d1; } #/ RSI+MFI script f_rsimfi { input _period = 60; input _multiplier = 150; input rsiMFIPosY = 2.5; def c = close; def o = open; def h = high; def l = low; def dif = (c - o) / (h - l); def diff = if !isNaN(dif) then dif else 0; def rsimfi = Average(diff * _multiplier, _period) - rsiMFIPosY; plot f_rsimfi = rsimfi; } #// WaveTrend script f_wavetrend { #def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1; input wtMASource = close; input wtChannelLen = 9; input wtAverageLen = 12; input wtMALen = 3; input obLevel = 53; input osLevel = -53; def tfsrc = wtMASource; def esa = ExpAverage(tfsrc, wtChannelLen); def de = ExpAverage(AbsValue(tfsrc - esa), wtChannelLen); def ci = (tfsrc - esa) / (0.015 * de); def wt1 = ExpAverage(ci, wtAverageLen); def wt2 = Average(wt1, wtMALen); def wtVwap = wt1 - wt2; def wtOversold = wt2 <= osLevel; def wtOverbought = wt2 >= obLevel; def wtCross = Crosses(wt1, wt2, CrossingDirection.ANY); def wtCrossUp = (wt2 - wt1) <= 0; def wtCrossDown = (wt2 - wt1) >= 0; def wtCrosslast = Crosses(wt1[2], wt2[2], CrossingDirection.ANY); def wtCrossUplast = (wt2[2] - wt1[2]) <= 0; def wtCrossDownlast = (wt2[2] - wt1[2]) >= 0; plot wt_1 = wt1; plot wt_2 = wt2; plot wt_OS = wtOversold; plot wt_OB = wtOverbought; plot wt_cross = wtCross; plot wt_CrossUp = wtCrossUp; plot wt_CrossDn = wtCrossDown; plot wt_Vwap = wtVwap; } #// CALCULATE INDICATORS { #// RSI def rsi = RSI(Price = rsiSRC, Length = rsiLen); #// RSI + MFI Area def rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, rsiMFIPosY); #// Calculates WaveTrend def wt1 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_1; def wt2 = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_2; def wtOversold = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OS; def wtOverbought = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_OB; def wtCross = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_cross; def wtCrossUp = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossUp; def wtCrossDown = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_CrossDn; def wtVwap = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, obLevel, osLevel).wt_Vwap; #// Stochastic RSI def stochK = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg).stochK; def stochD = f_stochrsi(stochSRC, stochLen, stochRsiLen, stochKSmooth, stochDSmooth, stochUseLog, stochAvg).stochD; #// WT Divergences def wtBearDiv = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).sigBear; def wtBullDiv = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).sigBull; def wtBearDivHidden = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).hidBear; def wtBullDivHidden = f_findDivs(wt2, wtDivOBLevel, wtDivOSLevel, yes).hidBull; def wtBearDiv_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).sigBear; def wtBullDiv_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).sigBull; def wtBearDivHidden_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).hidBear; def wtBullDivHidden_add = f_findDivs(wt2, wtDivOBLevel_add, wtDivOSLevel_add, yes).hidBull; def wtBearDivHidden_nl = f_findDivs(wt2, 0, 0, no).hidBear; def wtBullDivHidden_nl = f_findDivs(wt2, 0, 0, no).hidBull; def wtBearDivHidden_ = if showHiddenDiv_nl then wtBearDivHidden_nl else wtBearDivHidden; def wtBullDivHidden_ = if showHiddenDiv_nl then wtBullDivHidden_nl else wtBullDivHidden; def wtBearDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBearDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBearDivHidden_add));# ? RED #9a0202 : na def wtBullDivColor_add = (wtShowDiv and (wtDivOBLevel_addshow and wtBullDiv_add)) or (wtShowHiddenDiv and (wtDivOBLevel_addshow and wtBullDivHidden_add));# ? GREEN #1b5e20 : na plot wtBearAdd = if wtBearDivColor_add then 103 else na; plot wtBullAdd = if wtBullDivColor_add then -103 else na; wtBearAdd.SetDefaultColor(Color.DARK_RED); wtBullAdd.SetDefaultColor(Color.DARK_GREEN); wtBearAdd.SetPaintingStrategy(PaintingStrategy.POINTS); wtBullAdd.SetPaintingStrategy(PaintingStrategy.POINTS); plot wtBearHid = if wtBearDivHidden_ then 103 else na; plot wtBullHid = if wtBullDivHidden_ then -103 else na; wtBearHid.SetDefaultColor(Color.DARK_RED); wtBullHid.SetDefaultColor(Color.DARK_GREEN); wtBearHid.SetPaintingStrategy(PaintingStrategy.POINTS); wtBullHid.SetPaintingStrategy(PaintingStrategy.POINTS); #// RSI Divergences def rsiBearDiv = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, yes).sigBear; def rsiBullDiv = f_findDivs(rsi, rsiDivOBLevel, rsiDivOSLevel, yes).sigBull; #// Stoch Divergences def stochBearDiv = f_findDivs(stochK, 0, 0, no).sigBear; def stochBullDiv = f_findDivs(stochK, 0, 0, no).sigBull; def stochBearDivHidden = f_findDivs(stochK, 0, 0, no).hidBear; def stochBullDivHidden = f_findDivs(stochK, 0, 0, no).hidBull; def stochBearDivColor = (stochShowDiv and stochBearDiv) or (stochShowHiddenDiv and stochBearDivHidden);#red def stochBullDivColor = (stochShowDiv and stochBullDiv) or (stochShowHiddenDiv and stochBullDivHidden);#green plot StBearHid = if stochBearDivColor then 103 else na; plot StBullHid = if stochBullDivColor then -103 else na; StBearHid.SetDefaultColor(Color.DARK_RED); StBullHid.SetDefaultColor(Color.DARK_GREEN); stBearHid.SetPaintingStrategy(PaintingStrategy.POINTS); stBullHid.SetPaintingStrategy(PaintingStrategy.POINTS); #// Buy signal. def buySignal = wtCross and wtCrossUp and wtOversold; def buySignalDiv = (wtShowDiv and wtBullDiv) or (wtShowDiv and wtBullDiv_add) or (stochShowDiv and stochBullDiv) or (rsiShowDiv and rsiBullDiv); #// Sell signal def sellSignal = wtCross and wtCrossDown and wtOverbought; def sellSignalDiv = (wtShowDiv and wtBearDiv) or (wtShowDiv and wtBearDiv_add) or (stochShowDiv and stochBearDiv) or (rsiShowDiv and rsiBearDiv); #// } CALCULATE INDICATORS #// WT Areas plot wtWave1 = wt1; # 'WT Wave 1' plot wtWave2 = wt2; # 'WT Wave 2' wtWave1.SetDefaultColor(GlobalColor("wt1")); wtWave2.SetDefaultColor(GlobalColor("wt2")); AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1")); AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1")); AddCloud(wtWave1, 0, GlobalColor("wt1"), GlobalColor("wt1")); AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2")); AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2")); AddCloud(wtWave2, 0, GlobalColor("wt2"), GlobalColor("wt2")); # RSI plot rsiLine = if showRsiLine then rsi - 50 else na; rsiLine.SetDefaultColor(Color.YELLOW); #/ VWAP def vwapArea = if vwapShow then wtVwap else na; # 'VWAP' AddCloud(vwapArea, 0, Color.YELLOW, Color.YELLOW); #// MFI AREA def rsiMFIArea = if rsiMFIShow and !last then rsiMFI else na;#, style=plot.style_area, title='rsiMFI' AddCloud(rsiMFIArea, 0, Color.GREEN, Color.RED); # // Stoch RSI plot stocKline = if stochShow then stochK - 50 else na; plot stocDline = if stochShow then stochD - 50 else na; stocKline.SetDefaultColor(Color.CYAN); stocDline.SetDefaultColor(Color.DARK_ORANGE); #--Sig plot bSig = if buySignal then wt1 else na; # 'Buy circle' plot sSig = if sellSignal then wt1 else na; # 'Sell circle' bSig.SetPaintingStrategy(PaintingStrategy.SQUARES); sSig.SetPaintingStrategy(PaintingStrategy.SQUARES); bSig.SetDefaultColor(Color.GREEN); sSig.SetDefaultColor(Color.RED); def bSigDiv = buySignalDiv[-2];#, title = 'Divergence buy circle' def sSigDiv = sellSignalDiv[-2];#, title = 'Divergence sell circle' plot wbSigDiv = if sSigDiv then 103 else na; plot wsSigDiv = if bSigDiv then -103 else na; wbSigDiv.SetDefaultColor(Color.RED); wsSigDiv.SetDefaultColor(Color.GREEN); wbSigDiv.SetPaintingStrategy(PaintingStrategy.POINTS); wsSigDiv.SetPaintingStrategy(PaintingStrategy.POINTS); #-- Shark def ema50 = ExpAverage(src, 50); def ema200 = ExpAverage(src, 200); def ema400 = ExpAverage(src, 400); def ema800 = ExpAverage(src, 800); def wapwap = Reference vwap().VWAP; def bTouchedLine = (ema50<high and ema50>low) or (ema200<high and ema200>low) or (ema400<high and ema400>low) or (ema800<high and ema800>low) or (wapwap<high and wapwap>low); #// RSI def changRsiSrc = rsiSourceInput - rsiSourceInput[1]; def upTR = WildersAverage(max(changRsiSrc, 0), rsiLengthInput); def downTR = WildersAverage(-min(changRsiSrc, 0), rsiLengthInput); #def rsiM = if downTR == 0 then 100 else if upTR == 0 then 0 else 100 - (100 / (1 + upTR / downTR)); def rsiM = RSI(Price = rsiSourceInput, Length = rsiLengthInput); def basis = Average(rsiM[offset], length2); def dev = mult * stdev(rsiM[offset], length2); def upper = basis + dev; def lower = basis - dev; def bBelow = rsiM < 26; def bAbove = rsiM > 74; def bBelow25;def bAbove75; if !bApply25and75 { bBelow25 = yes; bAbove75 = yes; } else { bBelow25 = bBelow; bAbove75 = bAbove; } def b_color = if (rsiM > upper and bAbove75) then -1 else if (rsiM < lower and bBelow25) then 1 else 0; def barCol; if bTouchedLine and b_color == -1 { barCol = -2; } else if bTouchedLine and b_color == 1 { barCol = 2; } else { barCol = b_color; } def sigSharkUp1 = if barCol > 1 then pos else neg; def sigSharkUp2 = if barCol > 0 then pos else neg; def sigSharkDn1 = if barCol <-1 then pos else neg; def sigSharkDn2 = if barCol < 0 then pos else neg; AddCloud(sigSharkUp1, neg, Color.GREEN); AddCloud(sigSharkUp2, neg, Color.DARK_GREEN); AddCloud(sigSharkDn1, neg, Color.RED); AddCloud(sigSharkDn2, neg, Color.DARK_RED); AssignPriceColor(if !colorBars then Color.CURRENT else if barCol == 2 then GlobalColor("intense_green") else if barCol == 1 then GlobalColor("regular_green") else if barCol == -1 then GlobalColor("regular_red") else if barCol == -2 then GlobalColor("intense_red") else Color.GRAY); #-- END of CODE
I tried to scan for a "sell" signal but the system came back and said formula too complex for real time so scan could not be set up. Any ideas on what signal to use for this script that would work for real time for Sharks? I really appreciate your assistance
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.