//@version=6 indicator("RSI TMA", overlay=true) // Arrows on the main chart (overlay=true) // Input parameters rsiLength = input.int(2, title="RSI Length") rsiPrice = input.source(close, title="RSI Price") halfLength = input.int(2, title="Half Length") devPeriod = input.int(100, title="Deviation Period") deviations = input.float(0.7, title="Deviations") noDellArr = input.bool(false, title="No Delete Arrows") arrOtstup = input.int(0, title="Arrow Offset") arrUpColor = input.color(color.lime, title="Arrow Up Color") arrDnColor = input.color(color.red, title="Arrow Down Color") alertsMessage = input.bool(false, title="Alerts Message") alertsSound = input.bool(false, title="Alerts Sound") alertsEmail = input.bool(false, title="Alerts Email") alertsMobile = input.bool(false, title="Alerts Mobile") signalBar = input.int(0, title="Signal Bar") ...
//@version=5
indicator(title="Master Smart BUY/ SELL & TP", shorttitle="MASTER BUY/ SELL & TP", overlay=true)
// Color variables
upTrendColor = color.rgb(1, 42, 226, 5)
neutralColor = #0e0e0e
downTrendColor = color.rgb(255, 38, 0)
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = #0248e0
redColor = color.rgb(249, 47, 6)
// Source
source = input(defval=close, title="Source")
// Sampling Period
period = input.int(defval=100, minval=1, title="Sampling Period")
// Range Multiplier
multiplier = input.float(defval=3.0, minval=0.1, title="Range Multiplier")
// Take Profit Settings
takeProfitPips = input.float(defval=600.0, title="Take Profit (in pips)")
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? (x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r) :
(x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r)
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
lineOffset = smoothedRange * 0.1
upperLinePlot = plot(filter + lineOffset, color=filterColor, linewidth=3, title="Upper Trend Line")
lowerLinePlot = plot(filter - lineOffset, color=filterColor, linewidth=3, title="Lower Trend Line")
fill(upperLinePlot, lowerLinePlot, color=fillColor, title="Trend Fill")
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := (source > filter and source > source[1] and upCount > 0) or
(source > filter and source < source[1] and upCount > 0)
shortCondition := (source < filter and source < source[1] and downCount > 0) or
(source < filter and source > source[1] and downCount > 0)
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if (longSignal)
entryPriceBuy := source
if (not na(entryPriceBuy) and source >= entryPriceBuy + takeProfitPips * syminfo.mintick)
takeProfitSignalBuy := true
entryPriceBuy := na
if (shortSignal)
entryPriceSell := source
if (not na(entryPriceSell) and source <= entryPriceSell - takeProfitPips * syminfo.mintick)
takeProfitSignalSell := true
entryPriceSell := na
// Alerts and Signals
plotshape(longSignal, title="Smart Buy Signal", text="Smart Buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=greenColor)
plotshape(shortSignal, title="Smart Sell Signal", text="Smart Sell", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=redColor)
plotshape(takeProfitSignalBuy, title="Book Profit Buy", text="Book Profit", textcolor=blackTextColor, style=shape.labeldown, size=size.small, location=location.abovebar, color=yellowColor)
plotshape(takeProfitSignalSell, title="Book Profit Sell", text="Book Profit", textcolor=whiteTextColor, style=shape.labelup, size=size.small, location=location.belowbar, color=blueColor)
alertcondition(longSignal, title="Smart Buy alert on Master Trend Filter", message="Smart Buy alert on Master Trend Filter")
alertcondition(shortSignal, title="Smart Sell alert on Master Trend Filter", message="Smart Sell alert on Master Trend Filter")
alertcondition(takeProfitSignalBuy, title="Take Profit Buy alert", message="Take Profit Buy reached")
alertcondition(takeProfitSignalSell, title="Take Profit Sell alert", message="Take Profit Sell reached")
Comments
Post a Comment