Add Bullmania Money Line indicator - SuperTrend based trend detector with buy/sell signals
This commit is contained in:
49
Bullmania_Money_Line.pine
Normal file
49
Bullmania_Money_Line.pine
Normal file
@@ -0,0 +1,49 @@
|
||||
//@version=5
|
||||
indicator("Bullmania Money Line", overlay=true)
|
||||
|
||||
atrPeriod = input.int(10, "ATR Period", minval=1)
|
||||
multiplier = input.float(3.0, "Multiplier", minval=0.1, step=0.1)
|
||||
|
||||
atr = ta.atr(atrPeriod)
|
||||
src = (high + low) / 2
|
||||
|
||||
up = src - (multiplier * atr)
|
||||
dn = src + (multiplier * atr)
|
||||
|
||||
var float up1 = na
|
||||
var float dn1 = na
|
||||
|
||||
up1 := nz(up1[1], up)
|
||||
dn1 := nz(dn1[1], dn)
|
||||
|
||||
up1 := close[1] > up1 ? math.max(up, up1) : up
|
||||
dn1 := close[1] < dn1 ? math.min(dn, dn1) : dn
|
||||
|
||||
var int trend = 1
|
||||
var float tsl = na
|
||||
|
||||
tsl := nz(tsl[1], up1)
|
||||
|
||||
if trend == 1
|
||||
tsl := math.max(up1, tsl)
|
||||
trend := close < tsl ? -1 : 1
|
||||
else
|
||||
tsl := math.min(dn1, tsl)
|
||||
trend := close > tsl ? 1 : -1
|
||||
|
||||
supertrend = tsl
|
||||
|
||||
// Plot the Money Line
|
||||
upTrend = trend == 1 ? supertrend : na
|
||||
downTrend = trend == -1 ? supertrend : na
|
||||
|
||||
plot(upTrend, "Up Trend", color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)
|
||||
plot(downTrend, "Down Trend", color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)
|
||||
|
||||
// Plot buy/sell signals
|
||||
plotshape(trend == 1 and trend[1] == -1, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.circle, size=size.small)
|
||||
plotshape(trend == -1 and trend[1] == 1, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.circle, size=size.small)
|
||||
|
||||
// Fill area between price and Money Line
|
||||
fill(plot(close, display=display.none), plot(upTrend, display=display.none), color=color.new(color.green, 90))
|
||||
fill(plot(close, display=display.none), plot(downTrend, display=display.none), color=color.new(color.red, 90))
|
||||
Reference in New Issue
Block a user