Asset Bender Algo Indicator
Asset Bender Algo Indicator
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(autolines and trend == 1 ? up : na, title="Up Trend",
style=plot.style_linebr, linewidth=2, color=color.white)
buySignal = trend == 1 and trend[1] == -1
long = buySignal
short= sellSignal
pos = 0.0
pos:= long? 1 : short? -1 : pos[1]
// Position Adjustment
long_sl = low <sl_long and pos[1]==1
short_sl = high>sl_short and pos[1]==-1
if longCond
alert(json_data_long, alert.freq_once_per_bar_close)
// alert('{"content": "' +tostring(long_entry)+ '"}')
if shortCond
alert(json_data_short, alert.freq_once_per_bar_close)
// alert('{"content": "' +tostring(long_entry) + '"}')
// MACD Cloud
cloud_val = 10 // input(title = "Cloud SMA", defval = 100, minval = 5, maxval =
500, type = input.integer)
sma_high = ema(high,cloud_val)
sma_low = ema(low, cloud_val)
plot_high = plot(show_cloud? sma_high : na, color = na, transp = 1, editable =
false)
plot_low = plot(show_cloud? sma_low : na, color = na, transp = 1, editable =
false)
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
//// MA CROSS
//shortx = sma(close, 9)
//longx = sma(close, 21)
//plot(show_macross?shortx :na, color = #f27979)
//plot(show_macross?longx :na, color = #03cdff)
//plot(show_macross and cross(shortx, longx) ? shortx : na, style =
plot.style_cross, linewidth = 4)
// S/R
show_sr = input(true, title='Show S/R')
line_width = 1 // input(4, type = input.integer, title="SR Level line Width")
level_min_lengh = input(4, type = input.integer, title="Set minimum number of bars
from level start to qualify a level")
y = "Orange" // input("Orange", "Line Color", options=["Red", "Lime", "Orange",
"Teal", "Yellow", "White", "Black"])
line_extend = input(false, type = input.bool, title = "Extend Level line Right") ?
extend.right : extend.none
sr_tf = input("", type = input.resolution, title="SR Timeframe")
//color function
colour(z) => z=="Red"?color.red:z=="Lime"?color.lime:z=="Orange"?
color.orange:z=="Teal"?
color.teal:z=="Yellow"?color.yellow:z=="Black"?color.black:color.white
//Calc Values
rsi_new = rsi(close,9)
lpivot_new = lpivot // use legacy pivots calculation as integrated
pivotlow/pivothigh functions give very different result
hpivot_new = hpivot
// TENDLINES
lb = input(30, title="Trendline Left Bars", minval=1)
rb = input(30, title="Trendline Right Bars", minval=1)
showpivot = false //input(true, title="Trendline - Show Pivot Points")
chdashed = input(true, title="Show Old Trend Line as Dashed")
mb = lb + rb + 1
float top = na
float bot = na
top := iff(not na(high[mb]), iff(highestbars(high, mb) == -rb, high[rb], na),
na) // Pivot High
bot := iff(not na(low[mb]), iff(lowestbars(low, mb) == -rb, low[rb], na), na) //
Pivot Low
plotshape(top and showpivot, text="[PH]", style=shape.labeldown, color=color.white,
textcolor=color.black, location=location.abovebar, transp=0, offset = -rb)
plotshape(bot and showpivot, text="[PL]", style=shape.labeldown, color=color.white,
textcolor=color.black, location=location.belowbar, transp=0, offset = -rb)
ltop = valuewhen(top, top, 1)
bst = 0
bst := top ? 1 : nz(bst[1]) + 1