OPEN-SOURCE SCRIPT
SFI MAGIC

// Join our channel for more free tools: t.me/mrexpert_ai
//version=5
indicator("SFI MAGIC", overlay=true, max_labels_count=500)
//------------------------------------------------------------------------------
// Input Settings
useBody = input(false, 'Use Candle Body')
signalMode = input.string('Simple Entry + Exits', 'Signal Strategy', ['Simple Entry + Exits'], tooltip='Change Your Signal Appearance And Strategies')
sensitivity = input.float(2.3, "Sensitivity", 0.6, 15.1, step=0.1, tooltip='Change Your Signal Sensitivity And Accuracy')
strongSignalOnly = input(false, "STRONG Only", inline='BasicFilters')
noRepainting = input(false, 'No Repainting', inline='BasicFilters', tooltip='Disables all signals except strong signals \n\nDisables repainting for signals')
Multiplier = input.float(1.5, "ATR Multiplier", step=0.1)
align_with_supertrend = input.bool(false, "Align Signals with Supertrend", tooltip="Enable to align buy/sell signals with Supertrend direction")
//------------------------------------------------------------------------------
// ATR and Supertrend Calculation
atr = ta.atr(14)
st_atr_length = input.int(10, "Supertrend ATR Length", minval=1)
st_multiplier = input.float(3.0, "Supertrend Multiplier", step=0.1)
upper_band = ta.sma(close, st_atr_length) + st_multiplier * atr
lower_band = ta.sma(close, st_atr_length) - st_multiplier * atr
var float supertrend = na
supertrend := close > nz(supertrend[1]) ? math.max(lower_band, nz(supertrend[1])) : math.min(upper_band, nz(supertrend[1]))
supertrend_up = close > supertrend
supertrend_down = close < supertrend
//------------------------------------------------------------------------------
// Signal Logic
src = close
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(close, 100, sensitivity)
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
var float upward = na
var float downward = na
var int CondIni = na
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
longCond = src > filt and src > src[1] and upward > 0 or src > filt and src < src[1] and upward > 0
shortCond = src < filt and src < src[1] and downward > 0 or src < filt and src > src[1] and downward > 0
CondIni := longCond ? 1 : shortCond ? -1 : nz(CondIni[1])
buyCond = longCond and CondIni[1] == -1
strongBuyCond = buyCond and close[2] <= filt - smrng
sellCond = shortCond and CondIni[1] == 1
strongSellCond = sellCond and open[4] >= filt + smrng
if noRepainting
buyCond := buyCond and barstate.isconfirmed
strongBuyCond := strongBuyCond and barstate.isconfirmed
sellCond := sellCond and barstate.isconfirmed
strongSellCond := strongSellCond and barstate.isconfirmed
//------------------------------------------------------------------------------
// Tradingview indicators. Join ->>> t.me/tradingviewtools
// -------------------- 👆👆👆👆👆👆 ---------------
//------------------------------------------------------------------------------
// ATR-Based Book Profit and Wait for Supertrend Break
var float buy_entry_price = na
var float sell_entry_price = na
var bool buy_profit_plotted = false
var bool sell_profit_plotted = false
if (buyCond or strongBuyCond)
buy_entry_price := close
buy_profit_plotted := false
if (sellCond or strongSellCond)
sell_entry_price := close
sell_profit_plotted := false
buy_target = buy_entry_price + (atr * Multiplier)
sell_target = sell_entry_price - (atr * Multiplier)
if (not na(buy_entry_price) and close >= buy_target and not buy_profit_plotted)
label.new(bar_index, high, "Book Profit", color=#00db0a, style=label.style_label_down, textcolor=color.white, size=size.normal)
buy_profit_plotted := true
label.new(bar_index, high - atr, "Wait for Supertrend to break", color=color.orange, style=label.style_label_down, textcolor=color.white, size=size.normal)
if (not na(sell_entry_price) and close <= sell_target and not sell_profit_plotted)
label.new(bar_index, low, "Book Profit", color=#ff0000, style=label.style_label_up, textcolor=color.white, size=size.normal)
sell_profit_plotted := true
label.new(bar_index, low + atr, "Wait for Supertrend to break", color=color.orange, style=label.style_label_up, textcolor=color.white, size=size.normal)
//------------------------------------------------------------------------------
// Candle Coloring
barcolor_cond = src > filt and upward > 0 ? color.new(#00db0a, 5) : src < filt and downward > 0 ? color.new(#c90505, 5) : na
barcolor(barcolor_cond, title='Candle Colors')
// Plot Signals
plotshape(buyCond and not strongSignalOnly, 'Buy', shape.labelup, location.belowbar, color.new(#21ff30, 0), size=size.small, textcolor=color.black, text='BUY')
plotshape(strongBuyCond, 'Strong Buy', shape.labelup, location.belowbar, color.new(#09ff00, 0), size=size.small, textcolor=color.black, text='BUY')
plotshape(sellCond and not strongSignalOnly, 'Sell', shape.labeldown, location.abovebar, color.new(#ff0000, 0), size=size.small, textcolor=color.black, text='SELL')
plotshape(strongSellCond, 'Strong Sell', shape.labeldown, location.abovebar, color.new(#ff0000, 0), size=size.small, textcolor=color.black, text='SELL')
// Supertrend Plot
plot(supertrend, color=supertrend_up ? color.green : color.red, title="Supertrend", linewidth=2)
// ==========================================================================================
// === Dashboard with Telegram Link ===
var table myTable = table.new(position.top_center, 1, 1, border_width=1, frame_color=color.black, bgcolor=color.white)
// Add Telegram Message to Dashboard
table.cell(myTable, 0, 0, "Join Telegram mrexpert_ai", bgcolor=color.blue, text_color=color.white, text_size=size.normal)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.