Can someone please code a MTF version?
Thank youThis script is recommended for daily only
@samer800 any way to add a scanner for SSL Hybrid Indicator when Arrow Is UP / down?added as requested.
CSS:#//By Mihkel00 #// This script is designed for the NNFX Method, so it is recommended for Daily charts only. #// This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation #trades and a third SSL for exit trades. #// Alerts added for Baseline entries, SSL2 continuations, Exits. #// Baseline has a Keltner Channel setting for "in zone" Gray Candles #// Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range. #// Strategy causecelebre https://www.tradingview.com/u/causecelebre/ #// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/ #// Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/ #// Moving Averages everget https://www.tradingview.com/u/everget/ #// "Many Moving Averages" script Fractured https://www.tradingview.com/u/Fractured/ #// study("SSL Hybrid") ### Converted by SAM4COK - 07/2022 ## 09/2022 Added THMA as requested by usethinkscript.com memeber. input show_Baseline = yes; #"Show Baseline" input SSL1_Line = no; #"Show SSL1" input SSL2_Line = no; input ATR_Bands = no; #"Show ATR bands" input CandleMore_1xATR = no; input SSL_Channel = no; input Show_Arrow = no; input Show_Cloud = no; #//ATR input ATR_Period = 14; #"ATR Period" input ATR_mult = 1; #"ATR Multi" input ATR_smoothing = {default WMA, RMA, SMA, EMA}; #"ATR Smoothing" #////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES input ssl1_BaselineType = {"SMA", "EMA", "DEMA", "TEMA", "LSMA", "WMA", "MF", "VAMA", "TMA", default "HMA", "THMA", "JMA", "Kijun_v2", "EDSMA", "McGinley"}; #"SSL1 / Baseline Type" input SSL1_Length = 60; #"SSL1 / Baseline Length" input SSL2ContinuType = {"SMA", "EMA", "DEMA", "TEMA", "WMA", "MF", "VAMA", "TMA", "THMA", "HMA", default "JMA", "McGinley"}; input SSL2_Length = 5; #"SSL 2 Length" input ExitType = {"DEMA", "TEMA", "LSMA", "VAMA", "TMA", default "HMA", "THMA", "JMA", "Kijun v2", "McGinley", "MF"}; #"EXIT Type" input EXIT_Length = 15; #"EXIT Length" input src = close; ######## input Kijun_MOD_Divider = 1; #"Kijun MOD Divider" input jurik_phase = 3; #"* Jurik (JMA) Only - Phase" input jurik_power = 1; #"* Jurik (JMA) Only - Power" input volatility_lookback = 10; #"* Volatility Adjusted (VAMA) Only - Volatility lookback length" input FilterBeta = 0.8; #"Modular Filter, General Filter Only - Beta" input FilterFeedback = no ; #"Modular Filter Only - Feedback" input FeedbackWeighting = 0.5; #"Modular Filter Only - Feedback Weighting" #//EDSMA input EDSMaLength = 20; #"EDSMA - Super Smoother Filter Length" input EDSMaPoles = {default "2", "3"}; #"EDSMA - Super Smoother Filter Poles" input useTrueRange = yes; input Channel_Mult = 0.2; #"Base Channel Multiplier" input Continu_ATR = 0.9; #"Continuation ATR Criteria" input show_color_bar = no; input sound = {"Ding", "Bell", "Chimes",default "NoSound", "Ring"}; def na = Double.NaN; def tr = TrueRange (high, close, low); #################### COLORS ################################ DefineGlobalColor("lowerk", CreateColor(255, 0, 98)); # red DefineGlobalColor("upperk", CreateColor(0, 195, 255)); # blue DefineGlobalColor("upbar", CreateColor(38, 166, 154)); # green DefineGlobalColor("dnbar", CreateColor(239, 83, 80)); # red ################################################################## def ma_function; switch (ATR_smoothing) { case SMA: ma_function = SimpleMovingAvg(tr, ATR_Period); case EMA: ma_function = ExpAverage(tr, ATR_Period); case WMA: ma_function = WMA(tr, ATR_Period); case RMA: ma_function = WildersAverage(tr, ATR_Period); } #atr_slen = ma_function(tr(true), atrlen) def atr_slen = ma_function; #////ATR Up/Low Bands def upper_band = atr_slen * ATR_mult + close; def lower_band = close - atr_slen * ATR_mult; ############ Scripts############### script nz { input data = 0; input replacement = 0; def ret_val = if IsNaN(data) then replacement else data; plot return = ret_val; } #get2PoleSSF(src, length) => script get2PoleSSF { input src = close; input length = 0; def PI = 2 * ASin(1); def arg = Sqrt(2) * PI / length; def a1 = Exp(-arg); def b1 = 2 * a1 * Cos(arg); def c2 = b1; def c3 = -Power(a1, 2); def c1 = 1 - c2 - c3; def ssf = c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2]); plot return = ssf; } #get3PoleSSF(src, length) => script get3PoleSSF { input src = close; input length = 0; def PI = 2 * ASin(1); def arg = PI / length; def a1 = Exp(-arg); def b1 = 2 * a1 * Cos(1.738 * arg); def c1 = Power(a1, 2); def coef2 = b1 + c1; def coef3 = -(c1 + b1 * c1); def coef4 = Power(c1, 2); def coef1 = 1 - coef2 - coef3 - coef4; def ssf = coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3]); plot Return = ssf; } ### #tema(src, len) => script TEMA { input src = close; input len = 0; def ema1 = ExpAverage(src, len); def ema2 = ExpAverage(ema1, len); def ema3 = ExpAverage(ema2, len); def tema = (3 * ema1) - (3 * ema2) + ema3; plot return = tema; } #THMA(_src, _length) => script THMA { input _src = close; input _length = 0; def THMA = WMA(WMA(_src, _length / 3) * 3 - WMA(_src, _length / 2) - WMA(_src, _length), _length); plot return = THMA; } #DEMA(src, len) => script DEMA { input src = close; input len = 0; def e = ExpAverage(src, len); def DEMA = 2 * e - ExpAverage(e, len); plot result = DEMA; } #VAMA(src, len, volatility_lookback) => script VAMA { input src = close; input len = 0; input volatility_lookback = 10; def mid; def dev; def vol_up; def vol_down; mid = ExpAverage(src, len); dev = src - mid; vol_up = Highest(dev, volatility_lookback); vol_down = Lowest(dev, volatility_lookback); def VAMA = mid + (vol_up + vol_down) / 2; plot result = VAMA; } #mf(src, len, z, beta, feedback) script MF { input src = close; input len = 0; input z = 0; input beta = 0.8; input feedback = no; def ts; def alpha = 2 / (len + 1); def a = if feedback then z * src + (1 - z) * nz(ts[1], src) else src; def b = if a > alpha * a + (1 - alpha) * nz(b[1], a) then a else alpha * a + (1 - alpha) * nz(b[1], a); def c = if a < alpha * a + (1 - alpha) * nz(c[1], a) then a else alpha * a + (1 - alpha) * nz(c[1], a); def os = if a == b then 1 else if a == c then 0 else os[1]; def upper = beta * b + (1 - beta) * c; def lower = beta * c + (1 - beta) * b; ts = os * upper + (1 - os) * lower; plot result = ts; } #JMA(src, len, jurik_phase, jurik_power) script JMA { input src = close; input len = 0; input jurik_phase = 3; input jurik_power = 1; def jma; def phaseRatio = if jurik_phase < -100 then 0.5 else if jurik_phase > 100 then 2.5 else jurik_phase / 100 + 1.5; def beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2); def alpha = Power(beta, jurik_power); def e0 = (1 - alpha) * src + alpha * nz(e0[1]); def e1 = (src - e0) * (1 - beta) + beta * nz(e1[1]); def e2 = (e0 + phaseRatio * e1 - nz(jma[1])) * Power(1 - alpha, 2) + Power(alpha, 2) * nz(e2[1]); jma = e2 + nz(jma[1]); plot result = jma; } #Kijun_v2(src, len, kidiv) script Kijun_v2 { input src = close; input len = 0; input kidiv = 1; def kijun = (Lowest(src, len) + Highest(src, len)) / 2; def conversionLine = (Lowest(src, len / kidiv) + Highest(src, len / kidiv)) / 2; def delta = (kijun + conversionLine) / 2; plot result = delta; } #McGinley(src, len) script mg { input src = close; input len = 0; # def McGinley = McGinley[1] + (src - McGinley[1]) / (len * Power(src / McGinley[1], 4)); # def MDI = ExpAverage(src, len)[1]; def Mcg = if IsNaN(Mcg[1]) then ExpAverage(src, len) else CompoundValue(1, Mcg[1] + ((src - Mcg[1]) / (len * Power(src / Mcg[1], 4))), src); # def mg = if IsNaN(MDI) then ExpAverage(src, len) else # MDI[1] + (src - MDI[1]) / (len * Power(src / MDI[1], 4)); plot result = Mcg; } #EDSMA(src, len,ssfLength, ssfPoles) script EDSMA { input src = close; input len = 0; input ssfLength = 20; input ssfPoles = 2; def zeros = src - nz(src[2]); def avgZeros = (zeros + zeros[1]) / 2; def ssf = if ssfPoles == 2 then get2PoleSSF(avgZeros, ssfLength) else get3PoleSSF(avgZeros, ssfLength); def stdev = StDev(ssf, len); def scaledFilter = if stdev != 0 then ssf / stdev else 0; def alpha = 5 * AbsValue(scaledFilter) / len; def edsma = alpha * src + (1 - alpha) * nz(edsma[1]); plot result = edsma; } #mama(type, src, len, z, beta, feedback, jurik_phase, jurik_power, kidiv, ssfLength, ssfPoles, volatility_lookback) script ma { input type = "SMA"; input src = close; input len = 0; input z = 0.5; input beta = 0.8; input feedback = no; input jurik_phase = 3; input jurik_power = 1; input kidiv = 1; input ssfLength = 20; input ssfPoles = 2; input volatility_lookback = 10; def ma = if type == "TMA" then SimpleMovingAvg(SimpleMovingAvg(src, Ceil(len / 2)), Floor(len / 2) + 1) else if type == "MF" then mf(src, len, z, beta, feedback) else if type == "THMA" then THMA(src, len) else if type == "LSMA" then Inertia(src, len) else if type == "SMA" then SimpleMovingAvg(src, len) else if type == "EMA" then ExpAverage(src, len) else if type == "DEMA" then DEMA(src, len) else if type == "TEMA" then TEMA(src, len) else if type == "WMA" then WMA(src, len) else if type == "VAMA" then VAMA(src, len, volatility_lookback) else if type == "HMA" then WMA(2 * WMA(src, len / 2) - WMA(src, len), Round(Sqrt(len))) else if type == "JMA" then JMA(src, len, jurik_phase, jurik_power) else if type == "Kijun_v2" then Kijun_v2(src, len, kidiv) else if type == "McGinley" then mg(src, len) else EDSMA(src, len, ssfLength, ssfPoles); plot result = ma; } #///SSL 1 and SSL2 #ma(type, src, len, z, beta, feedback, jurik_phase, jurik_power, kidiv, ssfLength, ssfPoles, volatility_lookback) def emaHigh = ma(type = ssl1_BaselineType, src = high, len = SSL1_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def emaLow = ma(type = ssl1_BaselineType, src = low, len = SSL1_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def maHigh = ma(type = SSL2ContinuType, src = high, len = SSL2_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def maLow = ma(type = SSL2ContinuType, src = low, len = SSL2_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); #///EXIT def ExitHigh = ma(type = ExitType, src = high, len = EXIT_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def ExitLow = ma(type = ExitType, src = low, len = EXIT_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); #///Keltner Baseline Channel def BBMC = ma(type = ssl1_BaselineType, src = close, len = SSL1_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def Keltma = ma(type = ssl1_BaselineType, src = src, len = SSL1_Length, z = FeedbackWeighting, beta = FilterBeta, feedback = FilterFeedback, jurik_phase = jurik_phase, jurik_power = jurik_power, kidiv = Kijun_MOD_Divider, ssfLength = EDSMaLength, ssfPoles = EDSMaPoles, volatility_lookback = volatility_lookback); def range = if useTrueRange then tr else high - low; def rangema = ExpAverage(range, SSL1_Length); def upperk = Keltma + rangema * Channel_Mult; def lowerk = Keltma - rangema * Channel_Mult; #//Baseline Violation Candle def open_pos = open; def close_pos = close; def difference = AbsValue(close - open); def atr_violation = difference > atr_slen; def InRange = upper_band > BBMC and lower_band < BBMC; def candlesize_violation = atr_violation and InRange; plot candlesize = if CandleMore_1xATR then if candlesize_violation then high else na else na; #"Candle Size > 1xATR" candlesize.SetDefaultColor(Color.YELLOW); candlesize.SetPaintingStrategy(PaintingStrategy.TRIANGLES); candlesize.SetLineWeight(3); #//SSL1 VALUES def Hlv = if close > emaHigh then 1 else if close < emaLow then -1 else Hlv[1]; def sslDown = if Hlv < 0 then emaHigh else emaLow; #//SSL2 VALUES def Hlv2 = if close > maHigh then 1 else if close < maLow then -1 else Hlv2[1]; def sslDown2 = if Hlv2 < 0 then maHigh else maLow; #//EXIT VALUES def Hlv3 = if close > ExitHigh then 1 else if close < ExitLow then -1 else Hlv3[1]; def sslExit = if Hlv3 < 0 then ExitHigh else ExitLow; def base_cross_Long = close crosses above sslExit; def base_cross_Short = sslExit crosses above close; def codiff = if base_cross_Long then 1 else if base_cross_Short then -1 else na; #//COLORS AssignPriceColor( if show_color_bar then if close > upperk then GlobalColor("upbar") else if close < lowerk then GlobalColor("dnbar") else Color.GRAY else Color.CURRENT); #//PLOTS plot ArUp = if Show_Arrow and codiff > 0 then low else na; plot ArDN = if Show_Arrow and codiff < 0 then high else na; ArUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP); ArUp.SetDefaultColor(GlobalColor("upperk")); ArUp.SetLineWeight(2); ArDN.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); ArDN.SetDefaultColor(GlobalColor("lowerk")); ArDN.SetLineWeight(2); def color_bar = if close > upperk then 1 else if close < lowerk then -1 else 0; plot p1 = if show_Baseline then BBMC else na; #MA Baseline p1.SetStyle(Curve.FIRM); p1.AssignValueColor(if color_bar > 0 then GlobalColor("upperk") else if color_bar < 0 then GlobalColor("lowerk") else Color.GRAY); p1.SetLineWeight(4); plot DownPlot = if SSL1_Line then sslDown else na; #"SSL1" DownPlot.SetStyle(Curve.FIRM); DownPlot.AssignValueColor(if close > sslDown then GlobalColor("upperk") else if close < sslDown then GlobalColor("lowerk") else Color.CURRENT); DownPlot.SetLineWeight(3); plot up_channel = if SSL_Channel then upperk else na; #"Baseline Upper Channel") up_channel.SetStyle(Curve.FIRM); up_channel.AssignValueColor(if color_bar > 0 then GlobalColor("upperk") else if color_bar < 0 then GlobalColor("lowerk") else Color.GRAY); up_channel.SetLineWeight(1); plot low_channel = if SSL_Channel then lowerk else na; #"Basiline Lower Channel") low_channel.SetStyle(Curve.FIRM); low_channel.AssignValueColor(if color_bar > 0 then GlobalColor("upperk") else if color_bar < 0 then GlobalColor("lowerk") else Color.GRAY); low_channel.SetLineWeight(1); AddCloud (if Show_Cloud and color_bar > 0 then upperk else na, lowerk, GlobalColor("upperk")); AddCloud (if Show_Cloud and color_bar < 0 then upperk else na, lowerk, GlobalColor("lowerk")); AddCloud (if Show_Cloud and !color_bar then upperk else na, lowerk, Color.GRAY); #////SSL2 Continiuation from ATR def upper_half = atr_slen * Continu_ATR + close; def lower_half = close - atr_slen * Continu_ATR; def buy_inatr = lower_half < sslDown2; def sell_inatr = upper_half > sslDown2; def sell_cont = close < BBMC and close < sslDown2; def buy_cont = close > BBMC and close > sslDown2; def sell_atr = sell_inatr and sell_cont; def buy_atr = buy_inatr and buy_cont; def atr_fill = if buy_atr then 1 else if sell_atr then -1 else 0; plot LongPlot = if SSL2_Line then sslDown2 else na; LongPlot.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS); LongPlot.AssignValueColor(if atr_fill > 0 then Color.GREEN else if atr_fill < 0 then Color.MAGENTA else Color.WHITE); LongPlot.SetLineWeight(1); plot u = if ATR_Bands then upper_band else na; # "+ATR", color=color.white, transp=80) u.SetDefaultColor(Color.GRAY); plot l = if ATR_Bands then lower_band else na; # "-ATR", color=color.white, transp=80) l.SetDefaultColor(Color.GRAY); #//ALERTS alert(close crosses above sslDown, "SSL1 has crossed", Alert.Bar, sound); alert(close crosses below sslDown2, "SSL2 has crossed", Alert.Bar, sound); alert(sell_atr, "Sell Continuation", Alert.Bar, sound); alert(buy_atr, "Buy Continuation", Alert.Bar, sound); alert(close crosses above sslExit, "Exit Sell Alert", Alert.Bar, sound); alert(sslExit crosses below close, "Exit Buy Alert", Alert.Bar, sound); alert(close crosses above upperk, "Base Buy Alert", Alert.Bar, sound); alert(lowerk crosses below close, "Base Sell Alert", Alert.Bar, sound); #####END #########
https://usethinkscript.com/threads/ssl-hybrid-for-thinkorswim.11792/#post-137974@samer800 any way to add a scanner for SSL Hybrid Indicator when Arrow Is UP / down?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
Blue Magik SSL Indicator for ThinkorSwim | Indicators | 26 | |
S | SSL Indicator For ThinkorSwim | Indicators | 23 | |
![]() |
Dynamic Supply and Demand Zones [AlgoAlpha] for ThinkOrSwim | Indicators | 20 | |
![]() |
Market Sentiment Technicals [LuxAlgo] for ThinkOrSwim | Indicators | 24 | |
D | Trend Trader Buy/Sell Signals For ThinkOrSwim | Indicators | 9 |
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.