DGC LEVELS Updated
DGC LEVELS Updated
for x = 1 to a by 1
s *= 10
s
s := math.round(s)
for x = 1 to a by 1
s /= 10
s
s := s < syminfo.mintick ? syminfo.mintick : s
s
orb_high = float(na)
orb_low = float(na)
if is_first
orb_high := high
orb_low := low
else
orb_high := orb_high[1]
orb_low := orb_low[1]
R2 = orb_high + candle_range
R1 = orb_high + half_candle_range
R2_C = plot(show15highlow ? R2: na , title='R2', color=color.red ,
style=plot.style_line , linewidth=2, trackprice=true)
R1_C = plot(show15highlow ? R1: na , title='R1', color=color.red ,
style=plot.style_line , linewidth=2, trackprice=true)
S2 = orb_low - candle_range
S1 = orb_low - half_candle_range
S1_C = plot(show15highlow ? S1: na , title='S1', color=color.green ,
style=plot.style_line , linewidth=2, trackprice=true)
S2_C = plot(show15highlow ? S2: na , title='S2', color=color.green ,
style=plot.style_line , linewidth=2, trackprice=true)
//===================labels
label_orb_high = show15highlow and show_labels ? label.new(bar_index, orb_high,
text=show_labels ? (" ORB_HIGH" + "•" +
str.tostring(Round_it(orb_high))) : "orb_high", style= label.style_none,
textcolor=color.red, size=size.normal) : na
label.delete(label_orb_high[1])
plot(dailylevelsshow ? PERC_25_BELOW_DAY_HIGH : na ,
title='PERC_25_BELOW_DAY_HIGH', color=color.red , style=plot.style_line ,
linewidth=1, trackprice=true)
PERC_25_BELOW_DAY_HIGH_l = dailylevelsshow and show_labels ? label.new(bar_index +
5, PERC_25_BELOW_DAY_HIGH, text=show_labels ? ("25% BELOW DAY HIGH" + "•" +
str.tostring(Round_it(PERC_25_BELOW_DAY_HIGH))) : "PERC_25_BELOW_DAY_HIGH",
style= label.style_label_left, color=color.red, textcolor=color.white,
size=size.small, textalign=text.align_right) : na //style= label.style_none
label.delete(PERC_25_BELOW_DAY_HIGH_l[1])
////PREVIOUS DAY LEVELS=========PREVIOUS Day high, low & close, Current Day open
levelsshow = input.bool(title='PREVIOUS DAY LEVELS ON', defval=true,
inline='levelsshow', group='PREVIOUS DAY LEVELS ॐ')
phhtf = request.security(syminfo.tickerid, 'D', high[1],
lookahead=barmerge.lookahead_on)
plhtf = request.security(syminfo.tickerid, 'D', low[1],
lookahead=barmerge.lookahead_on)
pchtf = request.security(syminfo.tickerid, 'D', close[1],
lookahead=barmerge.lookahead_on)
////////////////////////////////SWING
showswing = input.bool(title='SWING ON', defval=true, inline='showswing',
group='SWING ॐ')
prd = input.int(defval=10, title='Period', inline='Swing', group='SWING ॐ')
ColorSelector(c_) =>
c_ == 'aqua' ? color.aqua : c_ == 'black' ? color.black : c_ == 'blue' ?
color.blue : c_ == 'fuchsia' ? color.fuchsia : c_ == 'gray' ? color.gray : c_ ==
'green' ? color.green : c_ == 'lime' ? color.lime : c_ == 'maroon' ? color.maroon :
c_ == 'navy' ? color.navy : c_ == 'olive' ? color.olive : c_ == 'orange' ?
color.orange : c_ == 'purple' ? color.purple : c_ == 'red' ? color.red : c_ ==
'silver' ? color.silver : c_ == 'teal' ? color.teal : c_ == 'white' ? color.white :
c_ == 'yellow' ? color.yellow : color.black
//======================ATR Trailing SL
ATRTsl = input.bool(title='ATRTsl ON', defval=true, inline='atr', group='ATR
Trailing SL ॐ')
nATRPeriod = input.int(5, 'Period', inline='atr', group='ATR Trailing SL ॐ')
nATRMultip = input.float(2, 'Multi', inline='atr', group='ATR Trailing SL ॐ')
xATR = ta.atr(nATRPeriod)
nLoss = nATRMultip * xATR
xATRTrailingStop = 0.0
iff_1 = close > nz(xATRTrailingStop[1], 0) ? close - nLoss : close + nLoss
iff_2 = close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1],
0) ? math.min(nz(xATRTrailingStop[1]), close + nLoss) : iff_1
xATRTrailingStop := close > nz(xATRTrailingStop[1], 0) and close[1] >
nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), close - nLoss) :
iff_2
col = close < xATRTrailingStop[1] ? #f90808 : #0af71b
plot(ATRTsl ? xATRTrailingStop[1] : na, color=col, title='ATR Trailing Stop')
[v, std]
//=============================EMA OM POINT
emaplot = input.bool(title='EMA ON', defval=false, inline='emaplot', group='EMA
ॐ')
EMA5 = input.int(5, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA8 = input.int(8, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA9 = input.int(9, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA13 = input.int(13, title='EMA', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA20 = input.int(20, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA50 = input.int(50, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA100 = input.int(100, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
EMA200 = input.int(200, title=' ', inline='EMA', minval=1, maxval=500, group='EMA
ॐ')
//===========================Ompoint======================
ema5 =ta.ema(close, EMA5)
ema8 = ta.ema(close, EMA8)
ema9 = ta.ema(close, EMA9)
ema13 = ta.ema(close, EMA13)
ema20 = ta.ema(close, EMA20)
ema50 = ta.ema(close, EMA50)
ema100 = ta.ema(close, EMA100)
ema200 = ta.ema(close, EMA200)
//longCondcross = bool(na)
//shortCondcross = bool(na)
//longCondcross := ema5 > ema8 and ema8 > ema13 and ema13 > ema20 and ema20 > ema50
and ema50 > ema100
//shortCondcross := ema5 < ema8 and ema8 < ema13 and ema13 < ema20 and ema20 <
ema50 and ema50 < ema100
//CondIniema = 0
//CondIniema := longCondcross ? 1 : shortCondcross ? -1 : CondIniema[1]
//longCondcrossition = longCondcross and CondIniema[1] == -1
//shortCondcrossition = shortCondcross and CondIniema[1] == 1
////////////HULLMA13
hull_ma = input.bool(title='HMA13 ON', defval=false, inline='hull_ma',
group='HULLMA13 ॐ')
useCurrentRes = input(true, title="Use Current Chart Resolution?")
smoothe = input.int(1, minval=1, maxval=10, title="Extra Smooth [1 = None]")
res = useCurrentRes ? timeframe.period : "0"
HMA_L = input.int(title="HMA", defval= 13, minval=1, maxval=300, step =1)
//HMA = ta.hma(close, HMA_L)
HMA = ta.wma(2 * ta.wma(close, HMA_L / 2) - ta.wma(close, HMA_L),
math.round(math.sqrt(HMA_L)))
////////////HULLMA TREND
hma_trend = input.bool(true, 'HMA TREND ON', inline='hma_trend', group='HMA_TREND
ॐ')
HMA18_L = input.int(18, 'HMA 18', inline='HMA 18', group='HMA_TREND ॐ')
HMA21_L = input.int(21, 'HMA 21', inline='HMA 21', group='HMA_TREND ॐ')
/////////////////////CANDLES-PRICE Action
Doji = input.float(0.05, minval=0.01, title='Doji size', step=0.01)
data = math.abs(open - close) <= (high - low) * Doji
plotshape(data, title='Doji', style=shape.diamond, text='Doji', color= color.black,
size=size.tiny)
///////(open == low) AND (open == high)
open_low = (open == low) //and (close > open)
//plotshape(open_low, title= "open_low", location=location.belowbar,
color=color.orange, style=shape.triangleup, size=size.tiny, textcolor=color.green,
text="O=L")
open_high = (open == high)// and (close < open)
//plotshape(open_high, title= "open_high", location=location.abovebar,
color=color.orange, style=shape.triangledown, size=size.tiny, textcolor=color.red,
text="O=H")
rsi_above_upper = current_rsi > upper and current_rsi > 50 and current_rsi >
current_rsi[1] and upper > upper[1] and upper > 50// and open_low
rsi_below_lower = current_rsi < lower and current_rsi < 50 and current_rsi <
current_rsi[1] and lower < lower[1] and lower < 50// and open_high
//diadxStat = diplus > adxValue and diplus >= 20 and adxValue >= 20? 'DIplus(' +
str.tostring(math.round(diplus)) + ') > ADX(' + str.tostring(math.round(adxValue))
+ ')' : na ////'DIminus(' + str.tostring(math.round(diminus)) + ') > ADXvalue(' +
str.tostring(math.round(adxValue)) + ')'
//dmiadxStat = diminus > adxValue and diminus >= 20 and adxValue >= 20 ?
'DIminus(' + str.tostring(math.round(diminus)) + ') > ADX(' +
str.tostring(math.round(adxValue)) + ')' : na
//per_diff_diplus_adx = diplus > adxValue and diplus >= 20 and adxValue >= 20 ?
'Diff.Increasing(DIplus & ADX) %' + str.tostring(math.abs((adxValue - diplus) /
diplus) * 100, '#.##') + '' : na
//per_diff_diminus_adx = diminus > adxValue and diminus >= 20 and adxValue >= 20 ?
'Diff.Increasing(DIminus & ADX) %' + str.tostring(math.abs((adxValue - diminus) /
diminus) * 100, '#.##') + '' : na
//percentage_difference = '\n\- Diff.(DIplus & DIminus) %' +
str.tostring(math.abs((diplus - diminus) / diminus) * 100, '#.##') + ''
diplus_above_diminus = diplus > diminus and diplus > adxValue and diplus >= 20 and
adxValue >= 20 and diplus > diplus[1] and diplus[1] > diplus[2] and adxValue >
adxValue[1] //and adxValue[1] > adxValue[2]
diminus_above_diplus = diminus > diplus and diminus > adxValue and diminus >= 20
and adxValue >= 20 and diminus > diminus[1] and diminus[1] > diminus[2] and
adxValue > adxValue[1] //and adxValue[1] > adxValue[2]
////////////////////////////ALERTS
//diplus_rising = diplus > diplus[1] and diplus >= 20
//diminus_rising = diminus > diminus[1] and diminus >= 20
//adx_rising = adxValue > adxValue[1] and adxValue >= 20
CondInirsibb = 0
CondInirsibb := rsi_above_upper and diplus >= 20 ? 1 : rsi_below_lower and diminus
>= 20 ? -1 : CondInirsibb[1]
RSI_BB_UPCROSS = rsi_above_upper and diplus >= 20 and CondInirsibb[1] == -1
RSI_BB_DNCROSS = rsi_below_lower and diminus >= 20 and CondInirsibb[1] == 1
//===========================================
EEMA_plot = input.bool(title='EEMA ON', defval=false, inline='EEMA_plot',
group='EEMA ON ॐ')
srcHA=ohlc4
EEMAlength = input(65, "EEMA LENGTH")
[c1,v1] = request.security(ss1,tf,screen())
[c2,v2] = request.security(ss2,tf,screen())
[c3,v3] = request.security(ss3,tf,screen())
[c4,v4] = request.security(ss4,tf,screen())
[c5,v5] = request.security(ss5,tf,screen())
[c6,v6] = request.security(ss6,tf,screen())
[c7,v7] = request.security(ss7,tf,screen())
[c8,v8] = request.security(ss8,tf,screen())
[c9,v9] = request.security(ss9,tf,screen())
[c10,v10] = request.security(ss10,tf,screen())
[c11,v11] = request.security(ss11,tf,screen())
[c12,v12] = request.security(ss12,tf,screen())
[c13,v13] = request.security(ss13,tf,screen())
[c14,v14] = request.security(ss14,tf,screen())
[c15,v15] = request.security(ss15,tf,screen())
[c16,v16] = request.security(ss16,tf,screen())
[c17,v17] = request.security(ss17,tf,screen())
//========================================================================
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_up, textcolor = swing_type_color_green, color =
color.new(swing_type_color_green, 100), size = size.normal)
// FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING
f_check_overlapping(new_poi, box_array, atr) =>
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array,i))
// if ta.crossover(close, level_to_break)
if close >= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array,i))
// if ta.crossunder(close, level_to_break)
if close <= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
// FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT
f_extend_box_endpoint(box_array) =>
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)
//END FUNCTIONS
//CALCULATIONS
// CALCULATE ATR
atr = ta.atr(50)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
//ZIG ZAG
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]
f_drawLine() =>
_li_color = show_zigzag ? zigzag_color : color.new(#faeb46, 100)
//_li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow,
xloc.bar_index, color=_li_color, width=2)
if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li
if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li