OPEN-SOURCE SCRIPT
Best Indicators for Day Trading

//version=5
indicator("Best Indicators for Day Trading", shorttitle="Day Trading Indicators", overlay= true)
//---------------------------- MA's ----------------------------//
priceSource = input.source(close, title='Price Source For The Moving Averages', group='Moving Average')
IgnoreExtendedHours = input.bool(true, title='Ignore Extended Hours', group='Moving Average')
resolution = timeframe.period
price = request.security(syminfo.tickerid, resolution, priceSource)
shortMAPeriod = input.int(8, title='MA 1', group='Moving Average', inline='short')
shortMAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='short')
longMAPeriod = input.int(21, title='MA 2', group='Moving Average', inline='long')
longMAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='long')
i_timeframe_signal = input.timeframe(title='Crossover MAs Timeframe', defval='', group='Moving Average')
useTextLabels = input.bool(true, title='Use Text-Based Crossover Labels?', group='Moving Average')
showBonusMA1 = input.bool(true, title='Bonus MA', group='Moving Average', inline='bma1')
bonusMA1Period = input.int(34, title='',group='Moving Average', inline='bma1')
bonus1MAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='bma1')
i_timeframe_bma1 = input.timeframe(title='', defval='', group='Moving Average', inline='bma1')
ZLMASmooth = 3
f_security(_sym, _res, _src) =>
request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0], barmerge.gaps_off, lookahead=barmerge.lookahead_off)[barstate.isrealtime ? 0 : 1]
ticker = ticker.new(syminfo.prefix, syminfo.ticker, IgnoreExtendedHours ? session.regular : syminfo.session)
// MA calculation
short = shortMAType == 'SMA' ? f_security(ticker, i_timeframe_signal, ta.sma(price, shortMAPeriod)) : shortMAType == 'EMA' ? f_security(ticker, i_timeframe_signal, ta.ema(price, shortMAPeriod)) : shortMAType == 'WMA' ? f_security(ticker, i_timeframe_signal, ta.wma(price, shortMAPeriod)) : shortMAType == 'HMA' ? f_security(ticker, i_timeframe_signal, ta.hma(price, shortMAPeriod)) : shortMAType == 'ALMA' ? f_security(ticker, i_timeframe_signal, ta.alma(price, shortMAPeriod, 0.85, 6)) : shortMAType == 'LIN' ? f_security(ticker, i_timeframe_signal, ta.linreg(price, shortMAPeriod, 0)) : shortMAType == 'ZLMA' ? f_security(ticker, i_timeframe_signal, 2 * ta.wma(ta.wma(price, shortMAPeriod), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, shortMAPeriod), ZLMASmooth), shortMAPeriod)) : na
long = longMAType == 'SMA' ? f_security(ticker, i_timeframe_signal, ta.sma(price, longMAPeriod)) : longMAType == 'EMA' ? f_security(ticker, i_timeframe_signal, ta.ema(price, longMAPeriod)) : longMAType == 'WMA' ? f_security(ticker, i_timeframe_signal, ta.wma(price, longMAPeriod)) : longMAType == 'HMA' ? f_security(ticker, i_timeframe_signal, ta.hma(price, longMAPeriod)) : longMAType == 'ALMA' ? f_security(ticker, i_timeframe_signal, ta.alma(price, longMAPeriod, 0.85, 6)) : longMAType == 'LIN' ? f_security(ticker, i_timeframe_signal, ta.linreg(price, longMAPeriod, 0)) : longMAType == 'ZLMA' ? f_security(ticker, i_timeframe_signal, 2 * ta.wma(ta.wma(price, longMAPeriod), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, longMAPeriod), ZLMASmooth), longMAPeriod)) : na
bonus1 = bonus1MAType == 'SMA' ? f_security(ticker, i_timeframe_bma1, ta.sma(price, bonusMA1Period)) : bonus1MAType == 'EMA' ? f_security(ticker, i_timeframe_bma1, ta.ema(price, bonusMA1Period)) : bonus1MAType == 'WMA' ? f_security(ticker, i_timeframe_bma1, ta.wma(price, bonusMA1Period)) : bonus1MAType == 'HMA' ? f_security(ticker, i_timeframe_bma1, ta.hma(price, bonusMA1Period)) : bonus1MAType == 'ALMA' ? f_security(ticker, i_timeframe_bma1, ta.alma(price, bonusMA1Period, 0.85, 6)) : bonus1MAType == 'LIN' ? f_security(ticker, i_timeframe_bma1, ta.linreg(price, bonusMA1Period, 0)) : bonus1MAType == 'ZLMA' ? f_security(ticker, i_timeframe_bma1, 2 * ta.wma(ta.wma(price, bonusMA1Period), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, bonusMA1Period), ZLMASmooth), bonusMA1Period)) : na
// trend direction/color
TrendingUp() =>
short > long
TrendingDown() =>
short < long
Uptrend() =>
TrendingUp() and TrendingDown()[1]
Downtrend() =>
TrendingDown() and TrendingUp()[1]
trendColor = TrendingUp() ? color.new(color.green, 85) : TrendingDown() ? color.new(color.red, 85) : color.new(color.blue, 85)
MA1 = plot(short, title='Short Period Moving Average', color=color.fuchsia, linewidth=2, style=plot.style_line)
MA2 = plot(long, title='Long Period Moving Average', color=color.navy, linewidth=1, style=plot.style_line)
fill(MA1, MA2, color=trendColor, title='Short/Long Divergence Fill')
plot(showBonusMA1 ? bonus1 : na, title='MA 3', color=color.white, linewidth=1, style=plot.style_line)
// Short & Long Moving Averages cross alert
MAcrossing = ta.cross(short, long) ? short : na
plot(MAcrossing[0], title='Calls/Puts Crossing Icon', style=plot.style_cross, linewidth=3, color=trendColor)
// Bull and Bear Alerts
Bull = ta.crossover(short, long)
Bear = ta.crossunder(short, long)
plotshape(Bull, title='Calls Label', color=color.new(color.green, 25), textcolor=useTextLabels ? color.white : color.new(color.white, 100), style=useTextLabels ? shape.labelup : shape.triangleup, text='Calls', location=location.belowbar)
plotshape(Bear, title='Puts Label', color=color.new(color.red, 25), textcolor=useTextLabels ? color.white : color.new(color.white, 100), style=useTextLabels ? shape.labeldown : shape.triangledown, text='Puts', location=location.abovebar)
if Bull
alert('Calls Alert: 8ema crossed over 21ema', alert.freq_once_per_bar_close)
if Bear
alert('Puts Alert: 8ema crossed under 21ema', alert.freq_once_per_bar_close)
//---------------------------- VWAP ----------------------------//
vwapprice = input(defval=hlc3, title="VWAP Source", group='VWAP')
enable_vwap = input(true, title="Enable VWAP", group='VWAP')
vwapResolution = input.timeframe(title = "VWAP Resolution", defval = "", group='VWAP')
vwapFunction = ta.vwap(vwapprice)
vwapSecurity = request.security(syminfo.tickerid, vwapResolution, vwapFunction)
plot(enable_vwap ? vwapSecurity : na, title="VWAP", color=color.yellow, linewidth=2, editable=true)
//---------------------------- FVG ----------------------------//
showFractals = input(false,title="Show Fractals?", group="Fair Value Gap")
showBrekout = input(false,title="Show Market Structure Breakouts?", group="Fair Value Gap")
breakType = input.string("Body",title="Fractal Break Type:",options=["Wick+Body","Body"], group="Fair Value Gap")
n = input.int(title="Periods", defval=2, minval=2, group="Fair Value Gap")
showImbalance = input(true,title="Show Breakout Imbalances", group="Fair Value Gap")
showOtherImbalance = input(true,title="Show Other Imbalances", group="Fair Value Gap")
imbGreenClr = input.color(color.new(color.green,65),title="Up:",inline="i_1", group="Fair Value Gap")
imbRedClr = input.color(color.new(color.red,65),title="Down:",inline="i_1", group="Fair Value Gap")
imbRestClr = input.color(color.new(color.yellow,65), title="Other:",inline="i_1", group="Fair Value Gap")
showBoxes = input(false,title="Show OrderBlocks?", group="Fair Value Gap")
changeColor = input(false,title="Change OrderBlock Colors?", group="Fair Value Gap")
transGreenClr = input.color(color.new(color.green,80),title="Bg:",inline="a_1", group="Fair Value Gap")
greenClr = input.color(color.new(color.green,0),title="Border:",inline="a_1", group="Fair Value Gap")
transRedClr = input.color(color.new(color.red,80),title="Bg:",inline="b_1", group="Fair Value Gap")
redClr = input.color(color.new(color.red,0),title="Border:",inline="b_1", group="Fair Value Gap")
//Fractals{
// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true
for i = 1 to n
upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])
upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])
upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n])
upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n])
upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])
upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4
upFractal = (upflagDownFrontier and flagUpFrontier)
//DownFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true
for i = 1 to n
downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])
downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])
downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n])
downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n])
downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])
downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4
downFractal = (downflagDownFrontier and flagDownFrontier)
//}
var float topValue = na, var float bottomValue = na
var int lastRedIndex = na, var float lastRedLow = na, var float lastRedHigh = na
var int lastGreenIndex = na, var float lastGreenLow = na, var float lastGreenHigh = na
var line topLine = na, var line bottomLine = na
var box demandBox = na, var box supplyBox = na
var box imbalanceBox = na
var bool checkUpImbalance = false
var bool checkDownImbalance = false
var topBreakBlock = false, var bottomBreakBlock = false
var isLongBreak = false, var isShortBreak = false
var arrBoxes = array.new_box(0)
topBreakCheckSource = breakType == "Wick+Body" ? high : close
bottomBreakCheckSource = breakType == "Wick+Body" ? low : close
//IMBALANCE
//Data
L1 = low
H3 = high[2]
H1 = high
L3 = low[2]
FVGUp = H3 < L1 ? 1 : 0
plotFVGU = FVGUp ? H3 : na
plotFVGUL = FVGUp ? L1 : na
FVGDown = L3 > H1 ? 1 : 0
plotFVGD = FVGDown ? L3 : na
plotFVGH = FVGDown ? H1 : na
if FVGUp and showOtherImbalance and checkUpImbalance == false
imbalanceBox := box.new(bar_index-2, plotFVGU,bar_index,plotFVGUL, bgcolor=imbRestClr, border_color=imbRestClr)
if FVGDown and showOtherImbalance and checkDownImbalance == false
imbalanceBox := box.new(bar_index-2, plotFVGH,bar_index,plotFVGD, bgcolor=imbRestClr, border_color=imbRestClr)
//Last red check
if close < open
lastRedIndex := bar_index
lastRedLow := low
lastRedHigh := high
//Last green check
if close > open
lastGreenIndex := bar_index
lastGreenLow := low
lastGreenHigh := high
//Check Imbalance
if checkUpImbalance
checkUpImbalance := false
imbTop = low
imbBottom = high[2]
if imbTop > imbBottom and showImbalance
imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbGreenClr, border_color=imbGreenClr)
if checkDownImbalance
checkDownImbalance := false
imbTop = low[2]
imbBottom = high
if imbTop > imbBottom and showImbalance
imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbRedClr, border_color=imbRedClr)
//Top break
if ta.crossover(topBreakCheckSource,topValue) and topBreakBlock == false
topBreakBlock := true
isLongBreak := true
checkUpImbalance := true
if showBrekout
line.set_x2(topLine,bar_index)
if showBoxes
demandBox := box.new(lastRedIndex-1, lastRedHigh,lastRedIndex+1,lastRedLow, bgcolor=transGreenClr, border_color=greenClr)
array.push(arrBoxes,demandBox)
//Bottom break
if ta.crossunder(bottomBreakCheckSource,bottomValue) and bottomBreakBlock == false
bottomBreakBlock := true
isShortBreak := true
checkDownImbalance := true
if showBrekout
line.set_x2(bottomLine,bar_index)
if showBoxes
supplyBox := box.new(lastGreenIndex-1, lastGreenHigh,lastGreenIndex+1,lastGreenLow, bgcolor=transRedClr, border_color=redClr)
array.push(arrBoxes,supplyBox)
//New up fractal
if upFractal
topBreakBlock := false
isLongBreak := false
topValue := high[n]
if showBrekout
topLine := line.new(bar_index[n],topValue,bar_index,topValue, color=color.teal, style=line.style_dotted, width=2)
if isLongBreak[1] == false
line.delete(topLine[1])
//New down fractal
if downFractal
bottomBreakBlock := false
isShortBreak := false
bottomValue := low[n]
if showBrekout
bottomLine := line.new(bar_index[n],bottomValue,bar_index,bottomValue, color=color.maroon, style=line.style_dotted, width=2)
if isShortBreak[1] == false
line.delete(bottomLine[1])
//Box state update
//activeBoxes = box.all
activeBoxes = arrBoxes
if array.size(activeBoxes) > 0 and changeColor
for i = 0 to array.size(activeBoxes) - 1
bVal = box.get_bottom(array.get(activeBoxes, i))
tVal = box.get_top(array.get(activeBoxes, i))
if close < bVal
box.set_bgcolor(array.get(activeBoxes, i),transRedClr)
box.set_border_color(array.get(activeBoxes, i),redClr)
if close > tVal
box.set_bgcolor(array.get(activeBoxes, i),transGreenClr)
box.set_border_color(array.get(activeBoxes, i),greenClr)
//PLOTS
plotshape(showFractals ? downFractal : na,style=shape.triangleup, location=location.belowbar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
plotshape(showFractals ? upFractal : na, style=shape.triangledown, location=location.abovebar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
//---------------------------- Bollinger Bands ----------------------------//
bbshow = input.bool(true, "Show Bollinger Bands?", group="Bollinger Bands")
bblength = input.int(20, minval=1, group="Bollinger Bands")
bbsrc = input(close, title="Source", group="Bollinger Bands")
bbmult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group="Bollinger Bands")
bbbasis = ta.sma(bbsrc, bblength)
bbdev = bbmult * ta.stdev(bbsrc, bblength)
bbupper = bbbasis + bbdev
bblower = bbbasis - bbdev
//Input Checkbox
basis_checkbok = input.bool(title="Basis", defval = true)
bboffset = input.int(0, "Offset", minval = -499, maxval = 500)
//Plot
plot(basis_checkbok ? bbbasis : na, "Basis", color=#872323, offset = bboffset)
p1 = plot(bbshow ? bbupper : na, "Upper", color=color.teal, offset = bboffset)
p2 = plot(bbshow ? bblower : na, color = color.teal)
fill(p1, p2, title = "Background", color=#198787)
//---------------------------- Support and Resistance ----------------------------//
prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30, group="S&R")
ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low', 'Close/Open'], group="S&R")
maxnumpp = input.int(defval=20, title=' Maximum Number of Pivot', minval=5, maxval=100, group="S&R")
ChannelW = input.int(defval=10, title='Maximum Channel Width %', minval=1, group="S&R")
maxnumsr = input.int(defval=5, title=' Maximum Number of S/R', minval=1, maxval=10, group="S&R")
min_strength = input.int(defval=2, title=' Minimum Strength', minval=1, maxval=10, group="S&R")
labelloc = input.int(defval=20, title='Label Location', group="S&R", tooltip='Positive numbers reference future bars, negative numbers reference histical bars')
linestyle = input.string(defval='Dashed', title='Line Style', options=['Solid', 'Dotted', 'Dashed'], group="S&R")
linewidth = input.int(defval=2, title='Line Width', minval=1, maxval=4, group="S&R")
resistancecolor = input.color(defval=color.red, title='Resistance Color', group="S&R")
supportcolor = input.color(defval=color.lime, title='Support Color', group="S&R")
showpp = input(false, title='Show Point Points')
float src1 = ppsrc == 'High/Low' ? high : math.max(close, open)
float src2 = ppsrc == 'High/Low' ? low : math.min(close, open)
float ph = ta.pivothigh(src1, prd, prd)
float pl = ta.pivotlow(src2, prd, prd)
plotshape(ph and showpp, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd)
plotshape(pl and showpp, text='L', style=shape.labelup, color=na, textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd)
Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted
//calculate maximum S/R channel zone width
prdhighest = ta.highest(300)
prdlowest = ta.lowest(300)
cwidth = (prdhighest - prdlowest) * ChannelW / 100
var pivotvals = array.new_float(0)
if ph or pl
array.unshift(pivotvals, ph ? ph : pl)
if array.size(pivotvals) > maxnumpp // limit the array size
array.pop(pivotvals)
get_sr_vals(ind) =>
float lo = array.get(pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to array.size(pivotvals) - 1 by 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= lo ? hi - cpp : cpp - lo
if wdth <= cwidth // fits the max channel width?
lo := cpp <= lo ? cpp : lo
hi := cpp > lo ? cpp : hi
numpp += 1
numpp
[hi, lo, numpp]
var sr_up_level = array.new_float(0)
var sr_dn_level = array.new_float(0)
sr_strength = array.new_float(0)
find_loc(strength) =>
ret = array.size(sr_strength)
for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1
if strength <= array.get(sr_strength, i)
break
ret := i
ret
ret
check_sr(hi, lo, strength) =>
ret = true
for i = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
//included?
if array.get(sr_up_level, i) >= lo and array.get(sr_up_level, i) <= hi or array.get(sr_dn_level, i) >= lo and array.get(sr_dn_level, i) <= hi
if strength >= array.get(sr_strength, i)
array.remove(sr_strength, i)
array.remove(sr_up_level, i)
array.remove(sr_dn_level, i)
ret
else
ret := false
ret
break
ret
var sr_lines = array.new_line(11, na)
var sr_labels = array.new_label(11, na)
for x = 1 to 10 by 1
rate = 100 * (label.get_y(array.get(sr_labels, x)) - close) / close
label.set_text(array.get(sr_labels, x), text=str.tostring(label.get_y(array.get(sr_labels, x))) + '(' + str.tostring(rate, '#.##') + '%)')
label.set_x(array.get(sr_labels, x), x=bar_index + labelloc)
label.set_color(array.get(sr_labels, x), color=label.get_y(array.get(sr_labels, x)) >= close ? color.red : color.lime)
label.set_textcolor(array.get(sr_labels, x), textcolor=label.get_y(array.get(sr_labels, x)) >= close ? color.white : color.black)
label.set_style(array.get(sr_labels, x), style=label.get_y(array.get(sr_labels, x)) >= close ? label.style_label_down : label.style_label_up)
line.set_color(array.get(sr_lines, x), color=line.get_y1(array.get(sr_lines, x)) >= close ? resistancecolor : supportcolor)
if ph or pl
//because of new calculation, remove old S/R levels
array.clear(sr_up_level)
array.clear(sr_dn_level)
array.clear(sr_strength)
//find S/R zones
for x = 0 to array.size(pivotvals) - 1 by 1
[hi, lo, strength] = get_sr_vals(x)
if check_sr(hi, lo, strength)
loc = find_loc(strength)
// if strength is in first maxnumsr sr then insert it to the arrays
if loc < maxnumsr and strength >= min_strength
array.insert(sr_strength, loc, strength)
array.insert(sr_up_level, loc, hi)
array.insert(sr_dn_level, loc, lo)
// keep size of the arrays = 5
if array.size(sr_strength) > maxnumsr
array.pop(sr_strength)
array.pop(sr_up_level)
array.pop(sr_dn_level)
for x = 1 to 10 by 1
line.delete(array.get(sr_lines, x))
label.delete(array.get(sr_labels, x))
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
rate = 100 * (mid - close) / close
array.set(sr_labels, x + 1, label.new(x=bar_index + labelloc, y=mid, text=str.tostring(mid) + '(' + str.tostring(rate, '#.##') + '%)', color=mid >= close ? color.red : color.lime, textcolor=mid >= close ? color.white : color.black, style=mid >= close ? label.style_label_down : label.style_label_up))
array.set(sr_lines, x + 1, line.new(x1=bar_index, y1=mid, x2=bar_index - 1, y2=mid, extend=extend.both, color=mid >= close ? resistancecolor : supportcolor, style=Lstyle, width=linewidth))
f_crossed_over() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
if close[1] <= mid and close > mid
ret := true
ret
ret
f_crossed_under() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
if close[1] >= mid and close < mid
ret := true
ret
ret
alertcondition(f_crossed_over(), title='Resistance Broken', message='Resistance Broken')
alertcondition(f_crossed_under(), title='Support Broken', message='Support Broken')
indicator("Best Indicators for Day Trading", shorttitle="Day Trading Indicators", overlay= true)
//---------------------------- MA's ----------------------------//
priceSource = input.source(close, title='Price Source For The Moving Averages', group='Moving Average')
IgnoreExtendedHours = input.bool(true, title='Ignore Extended Hours', group='Moving Average')
resolution = timeframe.period
price = request.security(syminfo.tickerid, resolution, priceSource)
shortMAPeriod = input.int(8, title='MA 1', group='Moving Average', inline='short')
shortMAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='short')
longMAPeriod = input.int(21, title='MA 2', group='Moving Average', inline='long')
longMAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='long')
i_timeframe_signal = input.timeframe(title='Crossover MAs Timeframe', defval='', group='Moving Average')
useTextLabels = input.bool(true, title='Use Text-Based Crossover Labels?', group='Moving Average')
showBonusMA1 = input.bool(true, title='Bonus MA', group='Moving Average', inline='bma1')
bonusMA1Period = input.int(34, title='',group='Moving Average', inline='bma1')
bonus1MAType = input.string(defval='EMA', title='', confirm=false, options=['EMA', 'SMA', 'WMA', 'HMA', 'ALMA', 'LIN', 'ZLMA'], group='Moving Average', inline='bma1')
i_timeframe_bma1 = input.timeframe(title='', defval='', group='Moving Average', inline='bma1')
ZLMASmooth = 3
f_security(_sym, _res, _src) =>
request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0], barmerge.gaps_off, lookahead=barmerge.lookahead_off)[barstate.isrealtime ? 0 : 1]
ticker = ticker.new(syminfo.prefix, syminfo.ticker, IgnoreExtendedHours ? session.regular : syminfo.session)
// MA calculation
short = shortMAType == 'SMA' ? f_security(ticker, i_timeframe_signal, ta.sma(price, shortMAPeriod)) : shortMAType == 'EMA' ? f_security(ticker, i_timeframe_signal, ta.ema(price, shortMAPeriod)) : shortMAType == 'WMA' ? f_security(ticker, i_timeframe_signal, ta.wma(price, shortMAPeriod)) : shortMAType == 'HMA' ? f_security(ticker, i_timeframe_signal, ta.hma(price, shortMAPeriod)) : shortMAType == 'ALMA' ? f_security(ticker, i_timeframe_signal, ta.alma(price, shortMAPeriod, 0.85, 6)) : shortMAType == 'LIN' ? f_security(ticker, i_timeframe_signal, ta.linreg(price, shortMAPeriod, 0)) : shortMAType == 'ZLMA' ? f_security(ticker, i_timeframe_signal, 2 * ta.wma(ta.wma(price, shortMAPeriod), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, shortMAPeriod), ZLMASmooth), shortMAPeriod)) : na
long = longMAType == 'SMA' ? f_security(ticker, i_timeframe_signal, ta.sma(price, longMAPeriod)) : longMAType == 'EMA' ? f_security(ticker, i_timeframe_signal, ta.ema(price, longMAPeriod)) : longMAType == 'WMA' ? f_security(ticker, i_timeframe_signal, ta.wma(price, longMAPeriod)) : longMAType == 'HMA' ? f_security(ticker, i_timeframe_signal, ta.hma(price, longMAPeriod)) : longMAType == 'ALMA' ? f_security(ticker, i_timeframe_signal, ta.alma(price, longMAPeriod, 0.85, 6)) : longMAType == 'LIN' ? f_security(ticker, i_timeframe_signal, ta.linreg(price, longMAPeriod, 0)) : longMAType == 'ZLMA' ? f_security(ticker, i_timeframe_signal, 2 * ta.wma(ta.wma(price, longMAPeriod), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, longMAPeriod), ZLMASmooth), longMAPeriod)) : na
bonus1 = bonus1MAType == 'SMA' ? f_security(ticker, i_timeframe_bma1, ta.sma(price, bonusMA1Period)) : bonus1MAType == 'EMA' ? f_security(ticker, i_timeframe_bma1, ta.ema(price, bonusMA1Period)) : bonus1MAType == 'WMA' ? f_security(ticker, i_timeframe_bma1, ta.wma(price, bonusMA1Period)) : bonus1MAType == 'HMA' ? f_security(ticker, i_timeframe_bma1, ta.hma(price, bonusMA1Period)) : bonus1MAType == 'ALMA' ? f_security(ticker, i_timeframe_bma1, ta.alma(price, bonusMA1Period, 0.85, 6)) : bonus1MAType == 'LIN' ? f_security(ticker, i_timeframe_bma1, ta.linreg(price, bonusMA1Period, 0)) : bonus1MAType == 'ZLMA' ? f_security(ticker, i_timeframe_bma1, 2 * ta.wma(ta.wma(price, bonusMA1Period), ZLMASmooth) - ta.wma(ta.wma(ta.wma(price, bonusMA1Period), ZLMASmooth), bonusMA1Period)) : na
// trend direction/color
TrendingUp() =>
short > long
TrendingDown() =>
short < long
Uptrend() =>
TrendingUp() and TrendingDown()[1]
Downtrend() =>
TrendingDown() and TrendingUp()[1]
trendColor = TrendingUp() ? color.new(color.green, 85) : TrendingDown() ? color.new(color.red, 85) : color.new(color.blue, 85)
MA1 = plot(short, title='Short Period Moving Average', color=color.fuchsia, linewidth=2, style=plot.style_line)
MA2 = plot(long, title='Long Period Moving Average', color=color.navy, linewidth=1, style=plot.style_line)
fill(MA1, MA2, color=trendColor, title='Short/Long Divergence Fill')
plot(showBonusMA1 ? bonus1 : na, title='MA 3', color=color.white, linewidth=1, style=plot.style_line)
// Short & Long Moving Averages cross alert
MAcrossing = ta.cross(short, long) ? short : na
plot(MAcrossing[0], title='Calls/Puts Crossing Icon', style=plot.style_cross, linewidth=3, color=trendColor)
// Bull and Bear Alerts
Bull = ta.crossover(short, long)
Bear = ta.crossunder(short, long)
plotshape(Bull, title='Calls Label', color=color.new(color.green, 25), textcolor=useTextLabels ? color.white : color.new(color.white, 100), style=useTextLabels ? shape.labelup : shape.triangleup, text='Calls', location=location.belowbar)
plotshape(Bear, title='Puts Label', color=color.new(color.red, 25), textcolor=useTextLabels ? color.white : color.new(color.white, 100), style=useTextLabels ? shape.labeldown : shape.triangledown, text='Puts', location=location.abovebar)
if Bull
alert('Calls Alert: 8ema crossed over 21ema', alert.freq_once_per_bar_close)
if Bear
alert('Puts Alert: 8ema crossed under 21ema', alert.freq_once_per_bar_close)
//---------------------------- VWAP ----------------------------//
vwapprice = input(defval=hlc3, title="VWAP Source", group='VWAP')
enable_vwap = input(true, title="Enable VWAP", group='VWAP')
vwapResolution = input.timeframe(title = "VWAP Resolution", defval = "", group='VWAP')
vwapFunction = ta.vwap(vwapprice)
vwapSecurity = request.security(syminfo.tickerid, vwapResolution, vwapFunction)
plot(enable_vwap ? vwapSecurity : na, title="VWAP", color=color.yellow, linewidth=2, editable=true)
//---------------------------- FVG ----------------------------//
showFractals = input(false,title="Show Fractals?", group="Fair Value Gap")
showBrekout = input(false,title="Show Market Structure Breakouts?", group="Fair Value Gap")
breakType = input.string("Body",title="Fractal Break Type:",options=["Wick+Body","Body"], group="Fair Value Gap")
n = input.int(title="Periods", defval=2, minval=2, group="Fair Value Gap")
showImbalance = input(true,title="Show Breakout Imbalances", group="Fair Value Gap")
showOtherImbalance = input(true,title="Show Other Imbalances", group="Fair Value Gap")
imbGreenClr = input.color(color.new(color.green,65),title="Up:",inline="i_1", group="Fair Value Gap")
imbRedClr = input.color(color.new(color.red,65),title="Down:",inline="i_1", group="Fair Value Gap")
imbRestClr = input.color(color.new(color.yellow,65), title="Other:",inline="i_1", group="Fair Value Gap")
showBoxes = input(false,title="Show OrderBlocks?", group="Fair Value Gap")
changeColor = input(false,title="Change OrderBlock Colors?", group="Fair Value Gap")
transGreenClr = input.color(color.new(color.green,80),title="Bg:",inline="a_1", group="Fair Value Gap")
greenClr = input.color(color.new(color.green,0),title="Border:",inline="a_1", group="Fair Value Gap")
transRedClr = input.color(color.new(color.red,80),title="Bg:",inline="b_1", group="Fair Value Gap")
redClr = input.color(color.new(color.red,0),title="Border:",inline="b_1", group="Fair Value Gap")
//Fractals{
// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true
for i = 1 to n
upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])
upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])
upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n])
upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n])
upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])
upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n])
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4
upFractal = (upflagDownFrontier and flagUpFrontier)
//DownFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true
for i = 1 to n
downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])
downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])
downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n])
downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n])
downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])
downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n])
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4
downFractal = (downflagDownFrontier and flagDownFrontier)
//}
var float topValue = na, var float bottomValue = na
var int lastRedIndex = na, var float lastRedLow = na, var float lastRedHigh = na
var int lastGreenIndex = na, var float lastGreenLow = na, var float lastGreenHigh = na
var line topLine = na, var line bottomLine = na
var box demandBox = na, var box supplyBox = na
var box imbalanceBox = na
var bool checkUpImbalance = false
var bool checkDownImbalance = false
var topBreakBlock = false, var bottomBreakBlock = false
var isLongBreak = false, var isShortBreak = false
var arrBoxes = array.new_box(0)
topBreakCheckSource = breakType == "Wick+Body" ? high : close
bottomBreakCheckSource = breakType == "Wick+Body" ? low : close
//IMBALANCE
//Data
L1 = low
H3 = high[2]
H1 = high
L3 = low[2]
FVGUp = H3 < L1 ? 1 : 0
plotFVGU = FVGUp ? H3 : na
plotFVGUL = FVGUp ? L1 : na
FVGDown = L3 > H1 ? 1 : 0
plotFVGD = FVGDown ? L3 : na
plotFVGH = FVGDown ? H1 : na
if FVGUp and showOtherImbalance and checkUpImbalance == false
imbalanceBox := box.new(bar_index-2, plotFVGU,bar_index,plotFVGUL, bgcolor=imbRestClr, border_color=imbRestClr)
if FVGDown and showOtherImbalance and checkDownImbalance == false
imbalanceBox := box.new(bar_index-2, plotFVGH,bar_index,plotFVGD, bgcolor=imbRestClr, border_color=imbRestClr)
//Last red check
if close < open
lastRedIndex := bar_index
lastRedLow := low
lastRedHigh := high
//Last green check
if close > open
lastGreenIndex := bar_index
lastGreenLow := low
lastGreenHigh := high
//Check Imbalance
if checkUpImbalance
checkUpImbalance := false
imbTop = low
imbBottom = high[2]
if imbTop > imbBottom and showImbalance
imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbGreenClr, border_color=imbGreenClr)
if checkDownImbalance
checkDownImbalance := false
imbTop = low[2]
imbBottom = high
if imbTop > imbBottom and showImbalance
imbalanceBox := box.new(bar_index-2, imbTop,bar_index,imbBottom, bgcolor=imbRedClr, border_color=imbRedClr)
//Top break
if ta.crossover(topBreakCheckSource,topValue) and topBreakBlock == false
topBreakBlock := true
isLongBreak := true
checkUpImbalance := true
if showBrekout
line.set_x2(topLine,bar_index)
if showBoxes
demandBox := box.new(lastRedIndex-1, lastRedHigh,lastRedIndex+1,lastRedLow, bgcolor=transGreenClr, border_color=greenClr)
array.push(arrBoxes,demandBox)
//Bottom break
if ta.crossunder(bottomBreakCheckSource,bottomValue) and bottomBreakBlock == false
bottomBreakBlock := true
isShortBreak := true
checkDownImbalance := true
if showBrekout
line.set_x2(bottomLine,bar_index)
if showBoxes
supplyBox := box.new(lastGreenIndex-1, lastGreenHigh,lastGreenIndex+1,lastGreenLow, bgcolor=transRedClr, border_color=redClr)
array.push(arrBoxes,supplyBox)
//New up fractal
if upFractal
topBreakBlock := false
isLongBreak := false
topValue := high[n]
if showBrekout
topLine := line.new(bar_index[n],topValue,bar_index,topValue, color=color.teal, style=line.style_dotted, width=2)
if isLongBreak[1] == false
line.delete(topLine[1])
//New down fractal
if downFractal
bottomBreakBlock := false
isShortBreak := false
bottomValue := low[n]
if showBrekout
bottomLine := line.new(bar_index[n],bottomValue,bar_index,bottomValue, color=color.maroon, style=line.style_dotted, width=2)
if isShortBreak[1] == false
line.delete(bottomLine[1])
//Box state update
//activeBoxes = box.all
activeBoxes = arrBoxes
if array.size(activeBoxes) > 0 and changeColor
for i = 0 to array.size(activeBoxes) - 1
bVal = box.get_bottom(array.get(activeBoxes, i))
tVal = box.get_top(array.get(activeBoxes, i))
if close < bVal
box.set_bgcolor(array.get(activeBoxes, i),transRedClr)
box.set_border_color(array.get(activeBoxes, i),redClr)
if close > tVal
box.set_bgcolor(array.get(activeBoxes, i),transGreenClr)
box.set_border_color(array.get(activeBoxes, i),greenClr)
//PLOTS
plotshape(showFractals ? downFractal : na,style=shape.triangleup, location=location.belowbar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
plotshape(showFractals ? upFractal : na, style=shape.triangledown, location=location.abovebar, offset=-n, color=color.new(color.gray,80), size = size.tiny)
//---------------------------- Bollinger Bands ----------------------------//
bbshow = input.bool(true, "Show Bollinger Bands?", group="Bollinger Bands")
bblength = input.int(20, minval=1, group="Bollinger Bands")
bbsrc = input(close, title="Source", group="Bollinger Bands")
bbmult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", group="Bollinger Bands")
bbbasis = ta.sma(bbsrc, bblength)
bbdev = bbmult * ta.stdev(bbsrc, bblength)
bbupper = bbbasis + bbdev
bblower = bbbasis - bbdev
//Input Checkbox
basis_checkbok = input.bool(title="Basis", defval = true)
bboffset = input.int(0, "Offset", minval = -499, maxval = 500)
//Plot
plot(basis_checkbok ? bbbasis : na, "Basis", color=#872323, offset = bboffset)
p1 = plot(bbshow ? bbupper : na, "Upper", color=color.teal, offset = bboffset)
p2 = plot(bbshow ? bblower : na, color = color.teal)
fill(p1, p2, title = "Background", color=#198787)
//---------------------------- Support and Resistance ----------------------------//
prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30, group="S&R")
ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low', 'Close/Open'], group="S&R")
maxnumpp = input.int(defval=20, title=' Maximum Number of Pivot', minval=5, maxval=100, group="S&R")
ChannelW = input.int(defval=10, title='Maximum Channel Width %', minval=1, group="S&R")
maxnumsr = input.int(defval=5, title=' Maximum Number of S/R', minval=1, maxval=10, group="S&R")
min_strength = input.int(defval=2, title=' Minimum Strength', minval=1, maxval=10, group="S&R")
labelloc = input.int(defval=20, title='Label Location', group="S&R", tooltip='Positive numbers reference future bars, negative numbers reference histical bars')
linestyle = input.string(defval='Dashed', title='Line Style', options=['Solid', 'Dotted', 'Dashed'], group="S&R")
linewidth = input.int(defval=2, title='Line Width', minval=1, maxval=4, group="S&R")
resistancecolor = input.color(defval=color.red, title='Resistance Color', group="S&R")
supportcolor = input.color(defval=color.lime, title='Support Color', group="S&R")
showpp = input(false, title='Show Point Points')
float src1 = ppsrc == 'High/Low' ? high : math.max(close, open)
float src2 = ppsrc == 'High/Low' ? low : math.min(close, open)
float ph = ta.pivothigh(src1, prd, prd)
float pl = ta.pivotlow(src2, prd, prd)
plotshape(ph and showpp, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd)
plotshape(pl and showpp, text='L', style=shape.labelup, color=na, textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd)
Lstyle = linestyle == 'Dashed' ? line.style_dashed : linestyle == 'Solid' ? line.style_solid : line.style_dotted
//calculate maximum S/R channel zone width
prdhighest = ta.highest(300)
prdlowest = ta.lowest(300)
cwidth = (prdhighest - prdlowest) * ChannelW / 100
var pivotvals = array.new_float(0)
if ph or pl
array.unshift(pivotvals, ph ? ph : pl)
if array.size(pivotvals) > maxnumpp // limit the array size
array.pop(pivotvals)
get_sr_vals(ind) =>
float lo = array.get(pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to array.size(pivotvals) - 1 by 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= lo ? hi - cpp : cpp - lo
if wdth <= cwidth // fits the max channel width?
lo := cpp <= lo ? cpp : lo
hi := cpp > lo ? cpp : hi
numpp += 1
numpp
[hi, lo, numpp]
var sr_up_level = array.new_float(0)
var sr_dn_level = array.new_float(0)
sr_strength = array.new_float(0)
find_loc(strength) =>
ret = array.size(sr_strength)
for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1
if strength <= array.get(sr_strength, i)
break
ret := i
ret
ret
check_sr(hi, lo, strength) =>
ret = true
for i = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
//included?
if array.get(sr_up_level, i) >= lo and array.get(sr_up_level, i) <= hi or array.get(sr_dn_level, i) >= lo and array.get(sr_dn_level, i) <= hi
if strength >= array.get(sr_strength, i)
array.remove(sr_strength, i)
array.remove(sr_up_level, i)
array.remove(sr_dn_level, i)
ret
else
ret := false
ret
break
ret
var sr_lines = array.new_line(11, na)
var sr_labels = array.new_label(11, na)
for x = 1 to 10 by 1
rate = 100 * (label.get_y(array.get(sr_labels, x)) - close) / close
label.set_text(array.get(sr_labels, x), text=str.tostring(label.get_y(array.get(sr_labels, x))) + '(' + str.tostring(rate, '#.##') + '%)')
label.set_x(array.get(sr_labels, x), x=bar_index + labelloc)
label.set_color(array.get(sr_labels, x), color=label.get_y(array.get(sr_labels, x)) >= close ? color.red : color.lime)
label.set_textcolor(array.get(sr_labels, x), textcolor=label.get_y(array.get(sr_labels, x)) >= close ? color.white : color.black)
label.set_style(array.get(sr_labels, x), style=label.get_y(array.get(sr_labels, x)) >= close ? label.style_label_down : label.style_label_up)
line.set_color(array.get(sr_lines, x), color=line.get_y1(array.get(sr_lines, x)) >= close ? resistancecolor : supportcolor)
if ph or pl
//because of new calculation, remove old S/R levels
array.clear(sr_up_level)
array.clear(sr_dn_level)
array.clear(sr_strength)
//find S/R zones
for x = 0 to array.size(pivotvals) - 1 by 1
[hi, lo, strength] = get_sr_vals(x)
if check_sr(hi, lo, strength)
loc = find_loc(strength)
// if strength is in first maxnumsr sr then insert it to the arrays
if loc < maxnumsr and strength >= min_strength
array.insert(sr_strength, loc, strength)
array.insert(sr_up_level, loc, hi)
array.insert(sr_dn_level, loc, lo)
// keep size of the arrays = 5
if array.size(sr_strength) > maxnumsr
array.pop(sr_strength)
array.pop(sr_up_level)
array.pop(sr_dn_level)
for x = 1 to 10 by 1
line.delete(array.get(sr_lines, x))
label.delete(array.get(sr_labels, x))
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
rate = 100 * (mid - close) / close
array.set(sr_labels, x + 1, label.new(x=bar_index + labelloc, y=mid, text=str.tostring(mid) + '(' + str.tostring(rate, '#.##') + '%)', color=mid >= close ? color.red : color.lime, textcolor=mid >= close ? color.white : color.black, style=mid >= close ? label.style_label_down : label.style_label_up))
array.set(sr_lines, x + 1, line.new(x1=bar_index, y1=mid, x2=bar_index - 1, y2=mid, extend=extend.both, color=mid >= close ? resistancecolor : supportcolor, style=Lstyle, width=linewidth))
f_crossed_over() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
if close[1] <= mid and close > mid
ret := true
ret
ret
f_crossed_under() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1
float mid = math.round_to_mintick((array.get(sr_up_level, x) + array.get(sr_dn_level, x)) / 2)
if close[1] >= mid and close < mid
ret := true
ret
ret
alertcondition(f_crossed_over(), title='Resistance Broken', message='Resistance Broken')
alertcondition(f_crossed_under(), title='Support Broken', message='Support Broken')
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.