add some new indicator/oscillators ...
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
//@version=4
|
||||
study(title="UT Bot Alerts", overlay = true)
|
||||
|
||||
// Inputs
|
||||
a = input(1, title = "Key Vaule. 'This changes the sensitivity'")
|
||||
c = input(10, title = "ATR Period")
|
||||
h = input(false, title = "Signals from Heikin Ashi Candles")
|
||||
|
||||
xATR = atr(c)
|
||||
nLoss = a * xATR
|
||||
|
||||
src = h ? security(heikinashi(syminfo.tickerid), timeframe.period, close, lookahead = false) : close
|
||||
|
||||
xATRTrailingStop = 0.0
|
||||
xATRTrailingStop := iff(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
|
||||
iff(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
|
||||
iff(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss)))
|
||||
|
||||
pos = 0
|
||||
pos := iff(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
|
||||
iff(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
|
||||
|
||||
xcolor = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
|
||||
|
||||
ema = ema(src,1)
|
||||
above = crossover(ema, xATRTrailingStop)
|
||||
below = crossover(xATRTrailingStop, ema)
|
||||
|
||||
buy = src > xATRTrailingStop and above
|
||||
sell = src < xATRTrailingStop and below
|
||||
|
||||
barbuy = src > xATRTrailingStop
|
||||
barsell = src < xATRTrailingStop
|
||||
|
||||
plotshape(buy, title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
|
||||
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red, textcolor = color.white, transp = 0, size = size.tiny)
|
||||
|
||||
barcolor(barbuy ? color.green : na)
|
||||
barcolor(barsell ? color.red : na)
|
||||
|
||||
alertcondition(buy, "UT Long", "UT Long")
|
||||
alertcondition(sell, "UT Short", "UT Short")
|
||||
@@ -0,0 +1,21 @@
|
||||
//@version=5
|
||||
indicator(title="Moving Average Simple", shorttitle="SMA", overlay=true, timeframe="", timeframe_gaps=true)
|
||||
len = input.int(9, minval=1, title="Length")
|
||||
src = input(close, title="Source")
|
||||
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500, display = display.data_window)
|
||||
out = ta.sma(src, len)
|
||||
plot(out, color=color.blue, title="MA", offset=offset)
|
||||
|
||||
ma(source, length, type) =>
|
||||
switch type
|
||||
"SMA" => ta.sma(source, length)
|
||||
"EMA" => ta.ema(source, length)
|
||||
"SMMA (RMA)" => ta.rma(source, length)
|
||||
"WMA" => ta.wma(source, length)
|
||||
"VWMA" => ta.vwma(source, length)
|
||||
|
||||
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing", display = display.data_window)
|
||||
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing", display = display.data_window)
|
||||
|
||||
smoothingLine = ma(out, smoothingLength, typeMA)
|
||||
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
|
||||
Reference in New Issue
Block a user