Secure Gift
Secure Gift
0 at
https://mozilla.org/MPL/2.0/
// � Secure lab
//@version=5
///////////////////////////////////////////////////////////////////////////////////
////////////////
//// STUDY
///////////////////////////////////////////////////////////////////////////////////
////////////////
indicator(title='Multiple indicators + TL Alerts [SECURE LAB}',
shorttitle='Multiple Indicators [SECURE LAB]', max_bars_back=5000,
max_lines_count=500, overlay=true, linktoseries=true,max_labels_count=500,
max_boxes_count = 500)
// EMAS
show_Emas = input(true, title='--------- Show EMAS ---------')
st = input(false, title='ShowTrend')
upTrend = ma(type3, close, MA3) >= ma(type4, close, MA4)
downTrend = ma(type3, close, MA3) < ma(type4, close, MA4)
t1 = ma(type1, close, MA1)
t2 = ma(type2, close, MA2)
t3 = ma(type3, close, MA3)
t4 = ma(type4, close, MA4)
t11 = plot(show_Emas ? t1 : na, color=color.new(#3b78eb, 0), linewidth=1,
title='MA1')
t22 = plot(show_Emas ? t2 : na, color=color.new(#B45F04, 0), linewidth=2,
title='MA2')
t33 = plot(show_Emas ? t3 : na, color=st and upTrend ? color.lime : st and
downTrend ? color.red : #b83d27, linewidth=1, title='MA3')
t44 = plot(show_Emas ? t4 : na, color=st and upTrend ? color.lime : st and
downTrend ? color.red : #b83d27, linewidth=3, title='MA4')
///////////////////////////
////////////
////////////////////////
showhbs = input(false, title='------ Show heikin BuySell -----')
EMAlength = input(55, 'EMA LENGTH?')
srch = ohlc4
haOpen = 0.0
haOpen := (srch + nz(haOpen[1])) / 2
haC = (ohlc4 + nz(haOpen) + math.max(high, nz(haOpen)) + math.min(low, nz(haOpen)))
/ 4
EMA1 = ta.ema(haC, EMAlength)
EMA2 = ta.ema(EMA1, EMAlength)
EMA3 = ta.ema(EMA2, EMAlength)
TMA1 = 3 * EMA1 - 3 * EMA2 + EMA3
EMA4 = ta.ema(TMA1, EMAlength)
EMA5 = ta.ema(EMA4, EMAlength)
EMA6 = ta.ema(EMA5, EMAlength)
TMA2 = 3 * EMA4 - 3 * EMA5 + EMA6
IPEK = TMA1 - TMA2
YASIN = TMA1 + IPEK
EMA7 = ta.ema(hlc3, EMAlength)
EMA8 = ta.ema(EMA7, EMAlength)
EMA9 = ta.ema(EMA8, EMAlength)
TMA3 = 3 * EMA7 - 3 * EMA8 + EMA9
EMA10 = ta.ema(TMA3, EMAlength)
EMA11 = ta.ema(EMA10, EMAlength)
EMA12 = ta.ema(EMA11, EMAlength)
TMA4 = 3 * EMA10 - 3 * EMA11 + EMA12
IPEK1 = TMA3 - TMA4
YASIN1 = TMA3 + IPEK1
mavi = YASIN1
kirmizi = YASIN
last_signal = 0
long_final = longCond and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == -1)
short_final = shortCond and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1)
//////////////////////////////////////////////////////
/////////VWAP
/////////////////////////////////////////////////////
//////////////
///// END VWAP
////////////
//////////////////////////////////////////////////////
/////////PARABOLIC SAR
/////////////////////////////////////////////////////
show_ps = input(false, title='----------Show Parabolic SAR---------')
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, 'Max Value')
out = ta.sar(start, increment, maximum)
plot(show_ps ? out : na, 'ParabolicSAR', style=plot.style_cross,
color=color.new(#2962FF, 0))
//////////////
///// END PARABOLIC SAR
////////////
//////////////////
// KONCORDE
///////////////////
srcTprice = input(ohlc4, title='Fuente para Precio Total')
srcMfi = input.source(hlc3, title='Fuente MFI', group='Money Flow Index')
tprice = srcTprice
nvim = ta.ema(ta.nvi, m)
nvimax = ta.highest(nvim, longitudNVI)
nvimin = ta.lowest(nvim, longitudNVI)
azul = (ta.nvi - nvim) * 100 / (nvimax - nvimin)
// Bands Calculation
basisK = ta.sma(tprice, boLength) //Find the 20-day moving average average (n1 +
n2 ... + n20)/20
devK = mult * ta.stdev(tprice, boLength) //Find the standard deviation of the 20-
days
upperK = basisK + devK //Upper Band = 20-day Moving Average + (2 x standard
deviation of the 20-days)
lowerK = basisK - devK //Lower Band = 20-day Moving Average - (2 x standard
deviation of the 20-days)
OB1 = (upperK + lowerK) / 2.0
OB2 = upperK - lowerK
//////////////////
// KONCORDE
///////////////////
//////////////////////////
////BOLLINGER BANDS
////////////////////
show_BB = input(false, title='--------- Show Bollinger ---------')
lengthB = input.int(20, minval=1)
srcB = input(close, title='Source')
//mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(srcB, lengthB)
dev = mult * ta.stdev(srcB, lengthB)
upper = basis + dev
lower = basis - dev
offsetB = input.int(0, 'Offset', minval=-500, maxval=500)
plot(show_BB ? basis : na, 'Basis', color=color.new(#919191, 0), offset=offsetB)
p1 = plot(show_BB ? upper : na, 'Upper', color=color.new(#ff0059, 0),
offset=offsetB)
p2 = plot(show_BB ? lower : na, 'Lower', color=color.new(#ff0059, 0),
offset=offsetB)
fill(p1, p2, title='Background', color=color.rgb(255, 205, 222, 95))
//////
///
///////
/////////////
////ATR
//////////////
//////////////////
//// ICHIMOKU
///////////////////////////
//Input
show_ich = input(false, title='--------Show Ichimoku---------')
tenkanIN = input.int(9, minval=1, title='Tenkan')
kijunIN = input.int(26, minval=1, title='Kijun')
spanBIN = input.int(52, minval=1, title='Span B')
chikouIN = input.int(26, minval=1, title='Chikou')
srcI = input(close, title='Source')
//Setting
donchian(len) =>
math.avg(ta.lowest(len), ta.highest(len))
tenkan = donchian(tenkanIN)
kijun = donchian(kijunIN)
spanA = math.avg(tenkan, kijun)
spanB = donchian(spanBIN)
chikou = srcI
offset = -chikouIN
//Drawing
plot(show_ich ? tenkan : na, title='Tenkan', color=color.new(Color10, 0))
plot(show_ich ? kijun : na, title='Kijun', color=color.new(Color20, 0))
plot(show_ich ? srcI : na, offset=-chikouIN + 1, title='Chikou',
color=color.new(Color00, 0), linewidth=2)
kumoA = plot(show_ich ? spanA : na, offset=chikouIN - 1, title='Span A', color=na)
kumoB = plot(show_ich ? spanB : na, offset=chikouIN - 1, title='Span B', color=na)
fill(kumoA, kumoB, title='Kumo', color=show_ich ? colorKumo : na, transp=75)
//////////////////
///// END ICHIMOKU
///////////////////////////
//////////////////
/////BUYSELLSIGNALS
///////////////////////////
//Momentum
sz = ta.linreg(close - math.avg(math.avg(ta.highest(high, 20), ta.lowest(low, 20)),
ta.sma(close, 20)), 20, 0)
//ADX
adxlen = 14 //input(14, title = "ADX Smoothing")
dilen = 14 //input(14, title = "DI Length")
keyLevel = 23 //input(23, title = "Key level for ADX")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) /
truerange)
[plus, minus]
//FUNCTIONS
plFound(osc) =>
na(ta.pivotlow(osc, lbL, lbR)) ? false : true
phFound(osc) =>
na(ta.pivothigh(osc, lbL, lbR)) ? false : true
///ALERTAS
plotshape(ShowBuySellArrows and buy_c, 'Buy', shape.square, location.belowbar,
color.new(color.green, 0), text='Buy', textcolor=color.new(color.green, 0))
plotshape(ShowBuySellArrows and sell_c, 'Sell', shape.square, location.abovebar,
color.new(color.red, 0), text='Sell', textcolor=color.new(color.red, 0))
/////////////////////////////////////////////
//////////////Whale detector by blackcat
////////////////////////////////////
emawhale = input(title='Whale value', defval=30)
//functions
xrf(values, length) =>
r_val = float(na)
if length >= 1
for i = 0 to length by 1
if na(r_val) or not na(values[i])
r_val := values[i]
r_val
r_val
///////////
var21 = xrf(high, 1)
var31 = xsa(math.abs(high - var21), 3, 1) / xsa(math.max(high - var21, 0), 3, 1) *
100
var41 = ta.ema(close * 1.2 ? var31 * 10 : var31 / 10, 3)
var51 = ta.highest(high, emawhale)
var61 = ta.lowest(var41, emawhale)
highest_1 = ta.highest(high, 58)
var71 = highest_1 ? 1 : 0
var81 = ta.ema(high >= var51 ? (var41 + var61 * 2) / 2 : 0, 3) / 618 * var71
//////////////////////////
///////// DIVERGENCIAS
/////////////////////
bearColor = #ff0000
bullColor = #1bff00
hiddenBullColor = #a4ff99
hiddenBearColor = #ff9e9e
textColor = color.white
noneColor = color.new(color.white, 100)
//FUNCTIONS
_inRange(cond) =>
bars = ta.barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
_findDivRB(osc) =>
// Osc: Higher Low
oscHL = osc[lbR] > ta.valuewhen(plFound(osc), osc[lbR], 1) and
_inRange(plFound(osc)[1])
//-----------------------------------------------------------------------------
-
// Hidden Bullish
//-----------------------------------------------------------------------------
-
// Regular Bearish
//-----------------------------------------------------------------------------
-
// Hidden Bearish
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////NADARAYA
///////////////////////////////////////////////////////////
show_nadaraya = input(false, title='---------------Show
NADARAYA-------------------')
up_col = input.color(#39ff14,'Colors',inline='col')
dn_col = input.color(#ff1100,'',inline='col')
//----
n = bar_index
var k = 2
var uppern = array.new_line(0)
var lowern = array.new_line(0)
lset(l,x1,y1,x2,y2,col)=>
line.set_xy1(l,x1,y1)
line.set_xy2(l,x2,y2)
line.set_color(l,col)
line.set_width(l,2)
if barstate.isfirst
for i = 0 to lengthN/k-1
array.push(uppern,line.new(na,na,na,na))
array.push(lowern,line.new(na,na,na,na))
//----
line up = na
line dn = na
//----
cross_up = 0.
cross_dn = 0.
if barstate.islast
y = array.new_float(0)
sum_e = 0.
for i = 0 to lengthN-1
sum = 0.
sumw = 0.
for j = 0 to lengthN-1
w = math.exp(-(math.pow(i-j,2)/(h*h*2)))
sum += src[j]*w
sumw += w
y2 = sum/sumw
sum_e += math.abs(src[i] - y2)
array.push(y,y2)
mae = sum_e/lengthN*multn
for i = 1 to lengthN-1
y2 = array.get(y,i)
y1 = array.get(y,i-1)
up := array.get(uppern,i/k)
dn := array.get(lowern,i/k)
if show_nadaraya
lset(up,n-i+1,y1 + mae,n-i,y2 + mae,up_col)
lset(dn,n-i+1,y1 - mae,n-i,y2 - mae,dn_col)
///////////////////////////////////////////////////////////
///////////////////////////
////////////
////////////////////////
if sell_c or buy_c or whale or foundDiv
alert = sell_c ? 'Sell alert ' : buy_c ? 'Buy alert ' : ''
whaleT = whale ? ' ?? ' : ''
alert(whaleT + alert + textoDivBear + textoDivBull + str.tostring(close),
freq=alert.freq_once_per_bar_close)
/////////////////////////////////
///////////
/////////////////////////
/////////
///// END SIGNALS
/////
/////////
///// LUPOWN
/////
// Sommi Flag
// Sommi Diamond
// WaveTrend
f_wavetrend(src, chlen, avg, malen, tf) =>
tfsrc = request.security(syminfo.tickerid, tf, src)
esa = ta.ema(tfsrc, chlen)
de = ta.ema(math.abs(tfsrc - esa), chlen)
ci = (tfsrc - esa) / (0.015 * de)
wt1 = request.security(syminfo.tickerid, tf, ta.ema(ci, avg))
wt2 = request.security(syminfo.tickerid, tf, ta.sma(wt1, malen))
wtVwap = wt1 - wt2
wtOversold = wt2 <= osLevel
wtOverbought = wt2 >= obLevel
wtCross = ta.cross(wt1, wt2)
wtCrossUp = wt2 - wt1 <= 0
wtCrossDown = wt2 - wt1 >= 0
wtCrosslast = ta.cross(wt1[2], wt2[2])
wtCrossUplast = wt2[2] - wt1[2] <= 0
wtCrossDownlast = wt2[2] - wt1[2] >= 0
[wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown,
wtCrosslast, wtCrossUplast, wtCrossDownlast, wtVwap]
// RSI+MFI
f_rsimfi(_period, _multiplier, _tf) =>
request.security(syminfo.tickerid, _tf, ta.sma((close - open) / (high - low) *
_multiplier, _period) - rsiMFIPosY)
// Sommi flag
f_findSommiFlag(tf, wt1, wt2, rsimfi, wtCross, wtCrossUp, wtCrossDown) =>
[hwt1, hwt2, hwtOversold, hwtOverbought, hwtCross, hwtCrossUp, hwtCrossDown,
hwtCrosslast, hwtCrossUplast, hwtCrossDownlast, hwtVwap] = f_wavetrend(wtMASource,
wtChannelLen, wtAverageLen, wtMALen, tf)
// Calculates WaveTrend
[wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown,
wtCross_last, wtCrossUp_last, wtCrossDown_last, wtVwap] = f_wavetrend(wtMASource,
wtChannelLen, wtAverageLen, wtMALen, timeframe.period)
// Sommi flag
[sommiBearish1, sommiBullish1, hvwap] = f_findSommiFlag(sommiVwapTF, wt1, wt2,
rsiMFI, wtCross, wtCrossUp, wtCrossDown)
//Sommi diamond
[sommiBearishDiamond1, sommiBullishDiamond1] = f_findSommiDiamond(sommiHTCRes,
sommiHTCRes2, wt1, wt2, wtCross, wtCrossUp, wtCrossDown)
sommiBullish := sommiBullish1 , sommiBullishDiamond := sommiBullishDiamond1 ,
sommiBearish := sommiBearish1 , sommiBearishDiamond := sommiBearishDiamond1
//
-----------------------------------------------------------------------------------
----------- //
// Consecutively Increasing Volume / Price
----------------------------------------------------- //
//
-----------------------------------------------------------------------------------
----------- //
// Definitions
----------------------------------------------------------------------------------
//
nzVolume = nz(volume)
risingVol = nzVolume >= nzVolume[1]
x2 = timenow + 7 * math.round(ta.change(time))
var startBarIndexX = 0
if time == chart.left_visible_bar_time and vpLookbackRange == 'Visible Range'
startBarIndexX := bar_index
f_drawLineX(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
var id = line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width)
line.set_xy1(id, _x1, _y1)
line.set_xy2(id, _x2, _y2)
line.set_color(id, _color)
f_getHighLow() =>
var htf_h = 0., var htf_l = 0.
[htf_h, htf_l]
[priceHighest, priceLowest] = f_getHighLow()
priceStep = (priceHighest - priceLowest) / profileLevels
barPriceLow = low
barPriceHigh = high
var levelAbovePoc = 0
var levelBelowPoc = 0
var pocLevel = 0
if bullCandle[barIndex]
array.set(volumeStorageB, level, array.get(volumeStorageB,
level) + nzVolume[barIndex] * ((barPriceHigh[barIndex] - barPriceLow[barIndex]) ==
0 ? 1 : priceStep / (barPriceHigh[barIndex] - barPriceLow[barIndex])) )
level += 1
levelAbovePoc := pocLevel
levelBelowPoc := pocLevel
volumeAbovePoc = 0.
if levelAbovePoc < profileLevels - 1
volumeAbovePoc := array.get(volumeStorage, levelAbovePoc + 1)
volumeBelowPoc = 0.
if levelBelowPoc > 0
volumeBelowPoc := array.get(volumeStorage, levelBelowPoc - 1)
if priceLevels
f_drawLabelX(volumeProfile ? bar_index + horizontalOffset + 50 : bar_index
+ 7, priceHighest, str.tostring(priceHighest, format.mintick), xloc.bar_index,
yloc.price, labelColor, label.style_label_down, labelColor, size.normal,
text.align_left, 'Profile High - during last ' + str.tostring(lookbackLength) + '
bars\n %' + str.tostring((priceHighest - priceLowest) / priceLowest * 100, '#.##')
+ ' higher than the Profile Low')
f_drawLabelX(volumeProfile ? bar_index + horizontalOffset + 50 : bar_index
+ 7, priceLowest , str.tostring(priceLowest , format.mintick), xloc.bar_index,
yloc.price, labelColor, label.style_label_up , labelColor, size.normal,
text.align_left, 'Profile Low - during last ' + str.tostring(lookbackLength) + '
bars\n %' + str.tostring((priceHighest - priceLowest) / priceHighest * 100, '#.##')
+ ' lower than the Profile High')
f_drawLabelX(volumeProfile ? bar_index + horizontalOffset + 57 : bar_index
+ 13, priceLowest + (levelAbovePoc + 1.00) * priceStep, str.tostring(priceLowest +
(levelAbovePoc + 1.00) * priceStep, format.mintick), xloc.bar_index, yloc.price,
valueAreaHigh ? labelColor : #00000000, label.style_label_left, valueAreaHigh ?
labelColor : #00000000, size.normal, text.align_left, 'Value Area High Price')
f_drawLabelX(volumeProfile ? bar_index + horizontalOffset + 57 : bar_index
+ 13, priceLowest + (pocLevel + 0.50) * priceStep, str.tostring(priceLowest +
(pocLevel + 0.50) * priceStep, format.mintick), xloc.bar_index, yloc.price,
pointOfControl ? labelColor : #00000000, label.style_label_left, pointOfControl ?
labelColor : #00000000, size.normal, text.align_left, 'Point Of Control Price')
f_drawLabelX(volumeProfile ? bar_index + horizontalOffset + 57 : bar_index
+ 13, priceLowest + (levelBelowPoc + 0.00) * priceStep, str.tostring(priceLowest +
(levelBelowPoc + 0.00) * priceStep, format.mintick), xloc.bar_index, yloc.price,
valueAreaLow ? labelColor : #00000000, label.style_label_left, valueAreaLow ?
labelColor : #00000000, size.normal, text.align_left, 'Value Area Low Price')
if supplyDemand
if array.get(volumeStorage, level) / array.max(volumeStorage) <
lowVolNodesVal
array.push(a_profile, box.new(bar_index - lookbackLength + 1,
priceLowest + (level + 0.00) * priceStep, bar_index + 7, priceLowest + (level +
1.00) * priceStep, #00000000, bgcolor = supplyDemandCol ))
if volumeProfile
array.push(a_profile, box.new(bar_index - lookbackLength + 1, priceLowest,
bar_index + horizontalOffset + 50, priceHighest, color.new(color.gray, 37), 1,
line.style_dotted, bgcolor=#00000000 ))
/////////////////////////////////
////////////fvg
/////////////////////////////////
// Mark FVGs is marking FVG (stands for Fair Value Gap, other name is Imbalance or
IMB) on your chart so that you can instantly detect them
// It supports:
// - marking bullish and bearish partly filled or unfilled FVGs of the current
timeframe
// - marking bullish and bearish already filled FVGs of the current timeframe
// - marking bullish and bearish FVGs of the any 4 timeframes on your current
timeframe
// technically it re-builds them on the last bar or as soon as new realtime bar is
updated. it looks with 1k bars back to find the nearest specific number of FGVs
// Adjustments:
// - changing the maximum number of FVGs to display.
// - changing the color of FVG area
// - displaying already filled FVG of the current time frame
// - changing the mode of displaying area it can either extended or fixed width
// - displaying labels of other time frame FVGs
version = 'v3.0'
int mbp = 1000
//indicator("Mark FVGs", overlay = true, max_lines_count = 500, max_bars_back =
mbp, max_labels_count = 500)
// Settings
//{
FvgCat = 'Release ' + version
colorTip = ':\n ' + beName + ' - bearish FVG color\n ' + buName + ' - bullish
FVG color'
fvg_be_shared = input.color(color.new(#ff2525, 80), 'Shared Colors: ' + beName +
'/' + buName, group = FvgCat, inline = '0')
fvg_bu_shared = input.color(color.new(color.green, 80), '/', group = FvgCat, inline
= '0', tooltip = 'Shared Colors' + colorTip)
eo_None = 'None'
eo_ByFilledBar = 'Filling Candle'
custColorName = 'Cust Colors'
onTip = 'Shows/Hides chosen TF'
custColorTip = custColorName + colorTip
extendTip = extendName + ':\n ' + eo_Unextended + ' - shows fixed FVG area\n '
+ eo_BySceen + ' - extends FVG area all the way to the right\n ' + eo_ByLastBar +
' - extends FVG area to the last bar\n\nEnables/Disables custom colors\n\n' +
custColorTip
filledName = 'Filled'
fvg_f = input.bool(false, filledName, group = CurrentCat, inline = '0')
fvg_cc = input.bool(false, customColorName, group = CurrentCat, inline = '0')
fvg_f_bec = chooseColor2(fvg_cc, fvg_bec, input.color(defFvgColor, '', group =
CurrentCat, inline = '0'))
fvg_f_buc = chooseColor2(fvg_cc, fvg_buc, input.color(defFvgColor2, '/', group =
CurrentCat, inline = '0', tooltip = filledName + ' - shows/hides filled area\n\n' +
custColorTip))
//fvg_f = input.bool(false, 'filled', group = CurrentCat, inline = '0')
ff_FilledFVGsBack = 'Max Fills'
ff_FVGsBack = 'Last Unfilled'
fTip = 'From:\n ' + ff_FVGsBack + ' - shows filled FVGs by the first unfilled
FVG\n ' + ff_FilledFVGsBack + ' - sets max filled FVGs to show\n\nMax fills, used
when ' + ff_FilledFVGsBack+ ' option is chosen\n\nTo:\n ' + eo_ByFilledBar + '-
filled area is clipped by filling bar\n ' + eo_Unextended + ' - show fixed FVG
area\n\n'
fvg_ff = input.string(ff_FVGsBack, 'From', options = [ff_FVGsBack,
ff_FilledFVGsBack], group = CurrentCat, inline = '2')
fvg_fmax = input.int(10, '', minval = 1, maxval = 250, group = CurrentCat, inline =
'2')
fvg_ft = input.string(eo_ByFilledBar, 'To', options = [eo_ByFilledBar,
eo_Unextended], group = CurrentCat, inline = '2', tooltip = fTip)
labelName = 'Name'
timeframeTip = onTip + '\n\nTimeframe to display'
labelsTip = UWName + ' - additonal bars for the unextended area\n\n' + labelName +
' - displays the time frame name\n\nAdds extra text data to the label'
maxBars = mbp - 1
if maxBars >= bar_index
maxBars := bar_index - 1
//}
createTextLabel(tf) =>
r = tf
if str.contains(tf, 'M') or str.contains(tf, 'D') or str.contains(tf, 'Y') or
str.contains(tf, 'W') or str.contains(tf, 's')
r := tf
else
s = timeframe.in_seconds(tf)
s /= 60
if s / 60 >= 1
r := str.tostring(s / 60) + 'H'
else
r := tf + 'm'
r
FindLtfImb(tf, on, be_col, bu_col, max, extend, uw, showlabel, labeltxt) =>
wrongltf = not on or timeframe.in_seconds(tf) >=
timeframe.in_seconds(timeframe.period)
ts = request.security_lower_tf(syminfo.tickerid, wrongltf ? timeframe.period :
tf, time)
hs = request.security_lower_tf(syminfo.tickerid, wrongltf ? timeframe.period :
tf, high)
ls = request.security_lower_tf(syminfo.tickerid, wrongltf ? timeframe.period :
tf, low)
for j = 0 to max - 1
s = array.size(ts[j])
if (maxHighs == 0 and maxLows == 0) or s == 0
break
for i = 0 to s - 1
if not na(nl)
l := nl
h := nh
t := nt
nl := array.get(ls[j], s - 1 - i)
nh := array.get(hs[j], s - 1 - i)
nt := array.get(ts[j], s - 1 - i)
if na(t0)
t0 := nt
FindHtfImb(tf, on, be_col, bu_col, max, extend, uw, showlabel, labeltxt) =>
wronghtf = not on or timeframe.in_seconds(tf) <=
timeframe.in_seconds(timeframe.period)
[ts, hs, ls] = request.security(syminfo.tickerid, wronghtf ? timeframe.period :
tf, [time, high, low], barmerge.gaps_off, barmerge.lookahead_on)
left = bar_index - nj + 1
right = extend == eo_ByLastBar ? bar_index + uw : bar_index - cj + uw
if maxLows > 0
if nh < ml
lowImb = box.new(left, ml, right, nh, border_color =
fvg_borders ? bu_col : na, bgcolor = bu_col, extend = extend == eo_BySceen ?
extend.right : extend.none)
array.push(imbLows, lowImb)
if showlabel
array.push(labels, createLabel(right, (ml + nh) / 2, txt,
color.new(bu_col, color.t(bu_col) / 2), extend))
maxLows -= 1
if ml > nh and nh < l//for the gap
ml := nh
if l < ml
ml := l
if maxHighs > 0
if nl > mh
highImb = box.new(left, nl, right, mh, border_color =
fvg_borders ? be_col : na, bgcolor = be_col, extend = extend == eo_BySceen ?
extend.right : extend.none)
array.push(imbHighs, highImb)
if showlabel
array.push(labels, createLabel(right, (nl + mh) / 2, txt,
color.new(be_col, color.t(be_col) / 2), extend))
maxHighs -= 1
if mh < nl and nl > h
mh := nl
if mh < h
mh := h
if barstate.islast
while array.size(imbLows) > 0
box.delete(array.pop(imbLows))
while array.size(imbHighs) > 0
box.delete(array.pop(imbHighs))
while array.size(labels) > 0
label.delete(array.pop(labels))
////////////////////////////////////////////////////////////////////////////////
// //
// ====== OPTION LIST VARS ====== //
// //
// * Setting up option list variables outside of the actual input can //
// make them much easier to work with if any comparison checks are //
// required, and can help keep subsequent code clean and readable. //
// //
////////////////////////////////////////////////////////////////////////////////
// -- pivot options
i_piv0 = 'Traditional'
i_piv1 = 'Fibonacci'
i_piv2 = 'Woodie'
i_piv3 = 'Classic'
i_piv4 = 'Demark'
i_piv5 = 'Camarilla'
i_piv6 = 'Fibonacci Extended'
////////////////////////////////////////////////////////////////////////////////
// //
// ====== VAR and ARRAY PRESET ====== //
// //
////////////////////////////////////////////////////////////////////////////////
// -- Preset INT for maximum amount of S|R levels for any single pivot type.
// NOTE - this variable should only be changed if:
// � you extend a pivot to have more than 5 levels of S|R
// � you add a new pivot type wiith more than 5 levels of S|R
var int i_maxLevels = 5
// -- Preset INT for max length of pivot arrays [PP + S max + R max]
// * NOTE: should not be changed.
var int i_maxLength = 1 + i_maxLevels * 2
////////////////////////////////////////////////////////////////////////////////
// //
// ====== INPUTS ====== //
// //
// * Using the new 'inline' feature * //
// //
////////////////////////////////////////////////////////////////////////////////
// -- price labels
// -- styling options
////////////////////////////////////////////////////////////////////////////////
// //
// ====== FUNCTIONS ====== //
// //
////////////////////////////////////////////////////////////////////////////////
f_getResolution(_inputResolution) =>
// string _inputResolution : user selected resolution input
// () Description:
// - Resolver for custom resolution input selection, converts input to
// compatible return string for security, output is also used for less
// verbose label text options.
// Dependencies:
// - i_res1, i_res2, i_res3, i_res4, i_res5, i_res6
// - i_res7, i_res8, i_res9, i_res10, i_res11, i_res12
// Notes:
// - i_res0 excluded as it's a token placeholder for default "60".
f_getLineStyle(_inputStyle) =>
// string _inputStyle : user selected style input
// () resolver for custom line style input selection, returns a usable
// line style type.
// Dependencies:
// - i_line1, i_line2
// Notes:
// * i_line0 omitted as we default to 'line.style_solid' anyway
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
_return = _array
_return
// set up some temp vars for creating our lines and labels
var line _line = na
var label _labelLeft = na
var label _labelRight = na
var label _labelPrice = na
// clean up old lines and labels before drawing our new set
for i = 1 to array.size(_lines) by 1 // loop and delete 1 by 1
line.delete(array.get(_lines, i - 1))
////////////////////////////////////////////////////////////////////////////////
// //
// ====== SERIES, LINES and LABELS ====== //
// //
////////////////////////////////////////////////////////////////////////////////
// -- selected resolutions
string _resolutionA = f_getResolution(INP_resolutionA)
//string _resolutionB = f_getResolution( INP_resolutionB )
//string _resolutionC = f_getResolution( INP_resolutionC )
////////////////////////////////////////////////////////////////////////////////
// //
// ====== DRAWING and PLOTTING ====== //
// //
////////////////////////////////////////////////////////////////////////////////
// -- feed in our settings and data to the render function for set A
f_renderPivotArray(_resolutionA, i_settingsA, _pivotFloatsA, _pivotLinesA,
_pivotLabelsA)
//ORDERBLOCKS
// Color Scheme
bullcolor = colors == 'DARK' ? color.white : color.green
bearcolor = colors == 'DARK' ? color.blue : color.red
int upcandles = 0
for i = 1 to periods by 1
upcandles += (close[i] > open[i] ? 1 : 0) // Determine color of subsequent
candles (must all be green to identify a valid Bearish OB)
upcandles
int downcandles = 0
for i = 1 to periods by 1
downcandles += (close[i] < open[i] ? 1 : 0) // Determine color of subsequent
candles (must all be red to identify a valid Bearish OB)
downcandles
// Plotting
line.delete(linebull2)
linebull2 := line.new(x1=bar_index, y1=OB_bull_high, x2=bar_index - 1,
y2=OB_bull_high, extend=extend.left, color=bullcolor, style=line.style_dashed,
width=1)
line.delete(linebull3)
linebull3 := line.new(x1=bar_index, y1=OB_bull_low, x2=bar_index - 1,
y2=OB_bull_low, extend=extend.left, color=bullcolor, style=line.style_dashed,
width=1)
linebull3
line.delete(linebear2)
linebear2 := line.new(x1=bar_index, y1=OB_bear_high, x2=bar_index - 1,
y2=OB_bear_high, extend=extend.left, color=bearcolor, style=line.style_dashed,
width=1)
line.delete(linebear3)
linebear3 := line.new(x1=bar_index, y1=OB_bear_low, x2=bar_index - 1,
y2=OB_bear_low, extend=extend.left, color=bearcolor, style=line.style_dashed,
width=1)
linebear3
if OB_bull_avg > 0
latest_bull_avg := OB_bull_avg
latest_bull_avg
if OB_bull_low > 0
latest_bull_low := OB_bull_low
latest_bull_low
if OB_bear_high > 0
latest_bear_high := OB_bear_high
latest_bear_high
if OB_bear_avg > 0
latest_bear_avg := OB_bear_avg
latest_bear_avg
if OB_bear_low > 0
latest_bear_low := OB_bear_low
latest_bear_low