0% found this document useful (0 votes)
11 views20 pages

Pivot Points Strategy Script

Uploaded by

mr9931238845
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views20 pages

Pivot Points Strategy Script

Uploaded by

mr9931238845
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// This source code is subject to the terms of the Mozilla Public License 2.

0 at
[Link]
// © Vednidhi Bharadwaj
// Reach me @linkedin :- [Link]/in/vedbh

//@version=5
strategy("Pivot_MA_BB_ved", overlay=true, process_orders_on_close = true)

//// Close all if view is intraday

// if(session.islastbar_regular)
// strategy.close_all(comment = "close all orders")

//// Close all if view is intraday

//------------------- Pivot Functions -----------------------------

draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
dline = [Link](x1=_x1, y1=_y1, x2=_x2, y2=_y2, xloc=_xloc, extend=_extend,
color=_color, style=_style, width=_width)
[Link](dline[1])

draw_label(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size,


_textalign, _tooltip) =>
dlabel = [Link](x=_x, y=_y, text=_text, xloc=_xloc, yloc=_yloc,
color=_color, style=_style, textcolor=_textcolor, size=_size,
textalign=_textalign, tooltip=_tooltip)
[Link](dlabel[1])

_olhc(_val) =>
[open[_val], high[_val], low[_val], close[_val]]

//----------- Pivot Start ------------------------------

pivot_type = [Link](title='Pivot Type', options=['Traditional', 'Fibonacci'],


defval='Fibonacci', tooltip='Select Pivot Type')
showPV = [Link](title='Show Pivot', defval=true, inline='pv_inline',
tooltip='Check to show/hide Pivot Points')
ohlc = [Link](title='OHLC for Pivot', options=['Past Bar', 'Current Bar'],
defval='Past Bar', inline='', group='',
tooltip='Select OHLC (Intraday charts only).')

pre_cur = ohlc == 'Past Bar' ? 1 : 0

showR1 = [Link](title='R1', defval=true, inline='R12345', group='', tooltip='')


showR2 = [Link](title='R2', defval=true, inline='R12345', group='', tooltip='')
showR3 = [Link](title='R3', defval=false, inline='R12345', group='',
tooltip='')
showR4 = [Link](title='R4', defval=false, inline='R12345', group='',
tooltip='')
showR5 = [Link](title='R5', defval=false, inline='R12345', group='',
tooltip='R1 R2 R3 R4 R5')

showS1 = [Link](title='S1', defval=true, inline='S12345', group='', tooltip='')


showS2 = [Link](title='S2', defval=true, inline='S12345', group='', tooltip='')
showS3 = [Link](title='S3', defval=false, inline='S12345', group='',
tooltip='')
showS4 = [Link](title='S4', defval=false, inline='S12345', group='',
tooltip='')
showS5 = [Link](title='S5', defval=false, inline='S12345', group='', tooltip='S
1 S2 S3 S4 S5')

leftShift = [Link](title='Pivot Line offset', defval=5, minval=1, step=1)


rightShift = [Link](title='Pivot Label offset', defval=40, minval=1, step=1)

pivot_TF = [Link](title='/ Timeframe', defval='D', options=['D', 'W',


'M'], inline='pv_inline',
tooltip='Input timeframe for calculation of Pivot points')

// Getting ohlc for given timeframe in settings hence using pivot_TF


[d_open, d_high, d_low, d_close] = [Link]([Link], pivot_TF,
_olhc(pre_cur))

// Getting chart high low on candles in chart's timeframe / resolution


[d_openC0, d_highC0, d_lowC0, d_closeC0] = [Link]([Link],
[Link], _olhc(0))
[d_openC1, d_highC1, d_lowC1, d_closeC1] = [Link]([Link],
[Link], _olhc(1))

// Getting ohlc for hourly past bar and current bar


[d_openH0, d_highH0, d_lowH0, d_closeH0] = [Link]([Link], "60",
_olhc(0))
[d_openH1, d_highH1, d_lowH1, d_closeH1] = [Link]([Link], "60",
_olhc(1))

// Getting ohlc for hourly past bar and current bar


[d_openH4_0, d_highH4_0, d_lowH4_0, d_closeH4_0] =
[Link]([Link], "240", _olhc(0))
[d_openH4_1, d_highH4_1, d_lowH4_1, d_closeH4_1] =
[Link]([Link], "240", _olhc(1))

// Getting ohlc for past week and current week


[d_openW0, d_highW0, d_lowW0, d_closeW0] = [Link]([Link], 'W',
_olhc(0))
[d_openW1, d_highW1, d_lowW1, d_closeW1] = [Link]([Link], 'W',
_olhc(1))

// Getting ohlc for past month


[d_openM0, d_highM0, d_lowM0, d_closeM0] = [Link]([Link], 'M',
_olhc(0))
[d_openM1, d_highM1, d_lowM1, d_closeM1] = [Link]([Link], 'M',
_olhc(1))

// Calculations of Pivots current day , last day, current week, last week , current
month, last month , hourly current and last hour
pp_pivotW0 = (d_highW0 + d_lowW0 + d_closeW0) / 3 // Weekly current Pivot
pp_pivotW1 = (d_highW1 + d_lowW1 + d_closeW1) / 3 // Weekly past Pivot
pp_pivotH0 = (d_highH0 + d_lowH0 + d_closeH0) / 3 // Hourly Current
pp_pivotH1 = (d_highH1 + d_lowH1 + d_closeH0) / 3 // Hourly last
pp_pivotH4_0 = (d_highH4_0 + d_lowH4_0 + d_closeH4_0) / 3 // 4 Hourly Current
pp_pivotH4_1 = (d_highH4_1 + d_lowH4_1 + d_closeH4_0) / 3 // 4 Hourly last
pp_pivotM0 = (d_highM0 + d_lowW0 + d_closeM0) / 3 // Monthly current Pivot
pp_pivotM1 = (d_highM1 + d_lowM1 + d_closeM1) / 3 // Monthly past Pivot
pp_pivotC0 = (d_highC0 + d_lowC0 + d_closeC0) / 3 // Monthly current Pivot
pp_pivotC1 = (d_highC1 + d_lowC1 + d_closeC1) / 3 // Monthly past Pivot

// r1_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 2 - d_low0 : pp_pivot0 +


0.382 * (d_high0 - d_low0)
// s1_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 2 - d_high0 : pp_pivot0 -
0.382 * (d_high0 - d_low0)
// r2_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 + d_high0 - d_low0 :
pp_pivot0 + 0.618 * (d_high0 - d_low0)
// s2_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 - (d_high0 - d_low0) :
pp_pivot0 - 0.618 * (d_high0 - d_low0)
// r3_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 2 + d_high0 - 2 * d_low0 :
pp_pivot0 + 1.000 * (d_high0 - d_low0)
// s3_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 2 - (2 * d_high0 - d_low0)
: pp_pivot0 - 1.000 * (d_high0 - d_low0)
// r4_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 3 + d_high0 - 3 * d_low0 :
pp_pivot0 + 1.382 * (d_high0 - d_low0)
// s4_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 3 - (3 * d_high0 - d_low0)
: pp_pivot0 - 1.382 * (d_high0 - d_low0)
// r5_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 4 + d_high0 - 4 * d_low0 :
pp_pivot0 + 1.618 * (d_high0 - d_low0)
// s5_pivot0 = pivot_type == 'Traditional' ? pp_pivot0 * 4 - (4 * d_high0 - d_low0)
: pp_pivot0 - 1.618 * (d_high0 - d_low0)

// Calculations of Pivots
pp_pivot = pivot_type == 'Traditional' ? (d_high + d_low + d_close*2) / 4 : (d_high
+ d_low + d_close*2) / 4
r1_pivot = pivot_type == 'Traditional' ? pp_pivot * 2 - d_low : pp_pivot + 0.382 *
(d_high - d_low)
s1_pivot = pivot_type == 'Traditional' ? pp_pivot * 2 - d_high : pp_pivot - 0.382 *
(d_high - d_low)
r2_pivot = pivot_type == 'Traditional' ? pp_pivot + d_high - d_low : pp_pivot +
0.618 * (d_high - d_low)
s2_pivot = pivot_type == 'Traditional' ? pp_pivot - (d_high - d_low) : pp_pivot -
0.618 * (d_high - d_low)
r3_pivot = pivot_type == 'Traditional' ? pp_pivot * 2 + d_high - 2 * d_low :
pp_pivot + 1.000 * (d_high - d_low)
s3_pivot = pivot_type == 'Traditional' ? pp_pivot * 2 - (2 * d_high - d_low) :
pp_pivot - 1.000 * (d_high - d_low)
r4_pivot = pivot_type == 'Traditional' ? pp_pivot * 3 + d_high - 3 * d_low :
pp_pivot + 1.382 * (d_high - d_low)
s4_pivot = pivot_type == 'Traditional' ? pp_pivot * 3 - (3 * d_high - d_low) :
pp_pivot - 1.382 * (d_high - d_low)
r5_pivot = pivot_type == 'Traditional' ? pp_pivot * 4 + d_high - 4 * d_low :
pp_pivot + 1.618 * (d_high - d_low)
s5_pivot = pivot_type == 'Traditional' ? pp_pivot * 4 - (4 * d_high - d_low) :
pp_pivot - 1.618 * (d_high - d_low)

_space = ' '

if pivot_type == 'Traditional'
for i = 1 to rightShift by 1
_space := _space + ' '
_space
_space := _space + '[T] [' + pivot_TF + '] '
_space
else
for i = 1 to rightShift - 4 by 1
_space := _space + ' '
_space
_space := _space + '[F] [' + pivot_TF + '] '
_space
if showPV // if your want only on intraday timeframes pivots, add
[Link] == true

//-------------------------Pivot Lines

draw_line(bar_index[leftShift], pp_pivot, bar_index[0], pp_pivot,


xloc.bar_index, [Link], #f57f17, line.style_solid, 2)

if showR1
draw_line(bar_index[leftShift], r1_pivot, bar_index[0], r1_pivot,
xloc.bar_index, [Link], #4caf50, line.style_solid, 2)
if showS1
draw_line(bar_index[leftShift], s1_pivot, bar_index[0], s1_pivot,
xloc.bar_index, [Link], #4caf50, line.style_solid, 2)
if showR2
draw_line(bar_index[leftShift], r2_pivot, bar_index[0], r2_pivot,
xloc.bar_index, [Link], #2196f3, line.style_dotted, 2)
if showS2
draw_line(bar_index[leftShift], s2_pivot, bar_index[0], s2_pivot,
xloc.bar_index, [Link], #2196f3, line.style_dotted, 2)
if showR3
draw_line(bar_index[leftShift], r3_pivot, bar_index[0], r3_pivot,
xloc.bar_index, [Link], #e91e63, line.style_dashed, 2)
if showS3
draw_line(bar_index[leftShift], s3_pivot, bar_index[0], s3_pivot,
xloc.bar_index, [Link], #e91e63, line.style_dashed, 2)
if showR4
draw_line(bar_index[leftShift], r4_pivot, bar_index[0], r4_pivot,
xloc.bar_index, [Link], #311B92, line.style_solid, 2)
if showS4
draw_line(bar_index[leftShift], s4_pivot, bar_index[0], s4_pivot,
xloc.bar_index, [Link], #311B92, line.style_solid, 2)
if showR5
draw_line(bar_index[leftShift], r5_pivot, bar_index[0], r5_pivot,
xloc.bar_index, [Link], #880E4F, line.style_dotted, 2)
if showS5
draw_line(bar_index[leftShift], s5_pivot, bar_index[0], s5_pivot,
xloc.bar_index, [Link], #880E4F, line.style_dotted, 2)

//-------------------------Pivot Labels

draw_label(bar_index[0], pp_pivot, _space + 'pp = ' + [Link](pp_pivot,


'0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link], #f57f17,
label.style_none, #f57f17, [Link], text.align_left, '')

if showR1
draw_label(bar_index[0], r1_pivot, _space + 'R1 = ' +
[Link](r1_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#4caf50,
label.style_none, #4caf50, [Link], text.align_left, '')
if showS1
draw_label(bar_index[0], s1_pivot, _space + 'S1 = ' +
[Link](s1_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#4caf50,
label.style_none, #4caf50, [Link], text.align_left, '')
if showR2
draw_label(bar_index[0], r2_pivot, _space + 'R2 = ' +
[Link](r2_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#2196f3,
label.style_none, #2196f3, [Link], text.align_left, '')
if showS2
draw_label(bar_index[0], s2_pivot, _space + 'S2 = ' +
[Link](s2_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#2196f3,
label.style_none, #2196f3, [Link], text.align_left, '')
if showR3
draw_label(bar_index[0], r3_pivot, _space + 'R3 = ' +
[Link](r3_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#e91e63,
label.style_none, #e91e63, [Link], text.align_left, '')
if showS3
draw_label(bar_index[0], s3_pivot, _space + 'S3 = ' +
[Link](s3_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#e91e63,
label.style_none, #e91e63, [Link], text.align_left, '')
if showR4
draw_label(bar_index[0], r4_pivot, _space + 'R4 = ' +
[Link](r4_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#311B92,
label.style_none, #311B92, [Link], text.align_left, '')
if showS4
draw_label(bar_index[0], s4_pivot, _space + 'S4 = ' +
[Link](s4_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#311B92,
label.style_none, #311B92, [Link], text.align_left, '')
if showR5
draw_label(bar_index[0], r5_pivot, _space + 'R5 = ' +
[Link](r5_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#880E4F,
label.style_none, #880E4F, [Link], text.align_left, '')
if showS5
draw_label(bar_index[0], s5_pivot, _space + 'S5 = ' +
[Link](s5_pivot, '0.00') + ' (' + ohlc + ')', xloc.bar_index, [Link],
#880E4F,
label.style_none, #880E4F, [Link], text.align_left, '')

//----------- Pivot End ------------------------------

// ---------- Bollinger Bands start -------------------


length_bb = [Link](20, minval=1)
src_bb = input(close, title="Source")
xe1 = [Link](src_bb, length_bb)
xe2 = [Link](xe1, length_bb)
xe3 = [Link](xe2, length_bb)
xe4 = [Link](xe3, length_bb)
xe5 = [Link](xe4, length_bb)
xe6 = [Link](xe5, length_bb)
b = 0.7
c1 = -b*b*b
c2 = 3*b*b+3*b*b*b
c3 = -6*b*b-3*b-3*b*b*b
c4 = 1+3*b+b*b*b+3*b*b
basis = c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3

mult = [Link](0.4, minval=0.001, maxval=50, title="StdDev")


//basis = [Link](src_bb, length_bb)
dev_bb = mult * [Link](src_bb, length_bb)
upper = basis + dev_bb
lower = basis - dev_bb
upper_e = basis + dev_bb*5
lower_e = basis - dev_bb*5
offset = [Link](0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
p3 = plot(upper_e, "Upper", color=#2962FF, offset = offset)
p4 = plot(lower_e, "Lower", color=#2962FF, offset = offset)
//fill(p1, p2, title = "Background", color=[Link](33, 150, 243, 95))

// ---------- Bollinger Bands end ---------------------

// Backtest Date Range Inputs //


StartTime = [Link](defval=timestamp('01 Jan 2022 09:15 +0530'), group="Date
Range", title='Start Time')
EndTime = [Link](defval=timestamp('01 Jan 2099 00:00 +0000'), group="Date
Range", title='End Time')
InDateRange = time>=StartTime and time<=EndTime

//Short & Long Options


Long = [Link](true, "Model Long Trades")
Short = [Link](true, "Model Short Trades")

//Start dashboard
import jdehorty/EconomicCalendar/1 as calendar

// ---- Table Settings Start ----//


max = 160 //Maximum Length
min = 10 //Minimum Length

// Input setting page start


dash_loc = [Link]("Bottom Right","Dashboard Posision" ,["Top
Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"],
group='Style Settings')
text_size = [Link]('Small',"Dashboard
Size" ,options=["Tiny","Small","Normal","Large"] ,group='Style Settings')
cell_up = [Link]([Link],'Up Cell Color' ,group='Style Settings')
cell_dn = [Link]([Link],'Down Cell Color' ,group='Style Settings')
cell_Neut = [Link]([Link],'Nochange Cell Color' ,group='Style
Settings')
row_col = [Link]
col_col = [Link]
txt_col = [Link]
cell_transp = [Link](60,'Cell
Transparency' ,minval=0 ,maxval=100 ,group='Style Settings')

Header_col = [Link](35, 94, 255)


//MACDV color
cell_MACDV1 = [Link]([Link],'Continue/Reversal ', group='MACD
COLOR')
cell_MACDV2 = [Link]([Link],'Buy G0 ', group='MACD COLOR')
cell_MACDV3 = [Link]([Link],'Buy Retest ', group='MACD COLOR')
cell_MACDV4 = [Link]([Link](194, 179, 47),'Sideway ', group='MACD
COLOR')
cell_MACDV5 = [Link]([Link],'Short go', group='MACD COLOR')
cell_MACDV6 = [Link]([Link],'Short Retest ' , group='MACD COLOR')
cell_MACDV7 = [Link]([Link](204, 8, 24),'Wait Continue/Reversal ',
group='MACD COLOR')
//Momentum color
cell_phase1 = [Link]([Link],'Phase1:Accumulation', group='Momentum')
cell_phase2 = [Link]([Link],'Phase2:Runing' , group='Momentum')
cell_phase3 = [Link]([Link],'Phase3:Re-Accumulation' ,
group='Momentum')
cell_phase4 = [Link]([Link],'Phase4:Distribution' , group='Momentum')
cell_phase5 = [Link]([Link],'Phase5:Bearish' , group='Momentum')
cell_phase6 = [Link]([Link],'Phase6:Rev/Continue' ,
group='Momentum')
// ---- Table Settings End ----}//

// ---- Indicators Show/Hide Settings Start ----//

showCls = [Link](defval=true, title="Show Price Close", group="Colum


On/Off")
showMA01 = [Link](defval=true, title="Show MA01", group="Colum
On/Off")
showMA02 = [Link](defval=true, title="Show MA02", group="Colum
On/Off")
showMACross = [Link](defval=true, title="Show Trend", group="Colum
On/Off")
showRSI = [Link](defval=true, title="Show RSI ", group="Colum
On/Off")
showMACDV = [Link](defval=true, title="Show MACDV", group="Colum
On/Off")
showSignalV = [Link](defval=true, title="Show SignalV", group="Colum
On/Off")
showMACDV_Status = [Link](defval=true, title="Show Condition", group="Colum
On/Off")
showmomentum = [Link](defval=true, title="Show Momentum", group="Colum
On/Off")

//---- MACD-V code start ----//


MACD_fast_length = input(title="MACD-V Fast", defval=14, group="MACD-V
Settings")
MACD_slow_length = input(title="MACD-V Slow", defval=26, group="MACD-V
Settings")
MACD_signal_length = [Link](title="MACD-V Signal ", minval = 1, maxval = 50,
defval = 9, group="MACD-V Settings")
MACD_atr_length = input(title="ATR", defval=26, group="MACD-V Settings")

// ---- Indicators Show/Hide Settings end ----}//

// ==================
// ==== Settings ====
// ==================

// ---- Timeframe Row Show/Hide Settings Start ----//


showTF1 = [Link](defval=true, title="Show TF MN",
inline='indicator1',group="Rows Settings")

f_MACDV(_close) =>

//---- Indicators code Start ----//


CLS= _close[1]

//---- RSI code start ----//


rsiPeriod = 14
RSI = [Link](_close, rsiPeriod)

//---- RSI code end ----//

//---- EMA 1 code start----//


length_MA1 = [Link](title="MA1",defval=50, minval=1)
MA1 = [Link](_close, length_MA1)
//plot(MA01, color=[Link], title="MA1")
//---- EMA 1 code end ----//

//---- EMA 2 code start---//


length_MA2 = [Link](title="MA2",defval=200, minval=1)
MA2 = [Link](_close, length_MA2)
//plot(MA02, color=[Link], title="MA2")
//---- EMA 2 code end ----//

// Input seeting page end


// Calculating
fast_ma = [Link](_close, MACD_fast_length)
slow_ma = [Link](_close, MACD_slow_length)
atr = [Link](MACD_atr_length)
MACDV = (((fast_ma - slow_ma)/atr)*100)//[( 12 bar EMA - 26 bar EMA) /
ATR(26) ] * 100
SignalV = [Link](MACDV, MACD_signal_length)
//---- MACD-V code end ----//

//---- Indicators code end ----//

//-----Condition start
stringmacdv =(MACDV>150) ? "Wait Continue/Reversal" :(MACDV>50 and
MACDV<150 and MACDV>SignalV ) ? "Buy G0" :(MACDV>50 and MACDV<150 and MACDV<SignalV
) ? "Buy Retest":(MACDV<50) and (MACDV>-50) ? "Sideway" :(MACDV<-50 and MACDV>-150
and MACDV>SignalV ) ? "Short go":(MACDV<-50 and MACDV>-150 and MACDV<SignalV ) ?
"Short Retest":(MACDV<150) ? "Wait Continue/Reversal" :na
//momentum
stringmomentum =(CLS>MA1 and CLS>MA2 and MA1<MA2) ? "Accumulation:Stop Sell -
Setup Buy" :(CLS>MA1 and CLS>MA2 and MA1>MA2) ? "Runing Up: Buy Runing":(CLS<MA1
and CLS>MA2 and MA1>MA2) ? "Re-Acumulasi: Continue Up":(CLS<MA1 and CLS<MA2 and
MA1>MA2) ? "Distribution: Stop Buy-Setup Short":(CLS<MA1 and CLS<MA2 and MA1<MA2) ?
"Re-Distribusi: Continue Down":(CLS>MA1 and CLS<MA2 and MA1<MA2) ? "Accumulation-
Distribusi: Don't Trade Wait Break":na

//-----Condition end

// Return values
[CLS, MA1, MA2, RSI, MACDV, SignalV, stringmacdv, stringmomentum]

// ] -------- Alerts ----------------- [

//---- Table Position & Size code start {----//


var table_position = dash_loc == 'Bottom Right' ? position.bottom_right :
dash_loc == 'Bottom Left' ? position.bottom_left :
dash_loc == 'Middle Right' ? position.middle_right :
dash_loc == 'Bottom Center' ? position.bottom_center :
dash_loc == 'Top Left' ? position.top_right : position.bottom_right

var table_text_size = text_size == 'Normal' ? [Link] :


text_size == 'Tiny' ? [Link] :
text_size == 'Small' ? [Link] :
text_size == 'Normal' ? [Link] : [Link]

var t = [Link](table_position,15,[Link](max-min)+2,
frame_color =[Link](#f1ff2a, 0),
frame_width =1,
border_color =[Link](#f1ff2a,0),
border_width =1)
//---- Table Position & Size code end ----//

// get values for table

[CLS_chart, MA1_chart, MA2_chart, RSI_chart, MACDV_chart, SignalV_chart,


stringmacdv_chart, stringmomentum_chart] = f_MACDV(close)
[CLS_5_min, MA1_5_min, MA2_5_min, RSI_5_min, MACDV_5_min, SignalV_5_min,
stringmacdv_5_min, stringmomentum_5_min] = [Link]([Link], "5",
f_MACDV(close), lookahead=barmerge.lookahead_off)
[CLS_15_min, MA1_15_min, MA2_15_min, RSI_15_min, MACDV_15_min, SignalV_15_min,
stringmacdv_15_min, stringmomentum_15_min] = [Link]([Link],
"15", f_MACDV(close), lookahead=barmerge.lookahead_off)
[CLS_1_hour, MA1_1_hour, MA2_1_hour, RSI_1_hour, MACDV_1_hour, SignalV_1_hour,
stringmacdv_1_hour, stringmomentum_1_hour] = [Link]([Link],
"60", f_MACDV(close), lookahead=barmerge.lookahead_off)
[CLS_4_hour, MA1_4_hour, MA2_4_hour, RSI_4_hour, MACDV_4_hour, SignalV_4_hour,
stringmacdv_4_hour, stringmomentum_4_hour] = [Link]([Link],
"240", f_MACDV(close), lookahead=barmerge.lookahead_off)
[CLS_1_day, MA1_1_day, MA2_1_day, RSI_1_day, MACDV_1_day, SignalV_1_day,
stringmacdv_1_day, stringmomentum_1_day] = [Link]([Link], "D",
f_MACDV(close), lookahead=barmerge.lookahead_off)

//---- Table Column & Rows code start ----//


if ([Link])
//---- Table Main Column Headers code start ----//

[Link](t,1,1,'TimeFrem',text_color=col_col,text_size=table_text_size,bgcolor=He
ader_col)
if showCls

[Link](t,2,1,'[Link]',text_color=col_col,text_size=table_text_size,bgcolor=Hea
der_col)
if showMA01

[Link](t,3,1,'MA01',text_color=col_col,text_size=table_text_size,bgcolor=Header
_col)
if showMA02

[Link](t,4,1,'MA02',text_color=col_col,text_size=table_text_size,bgcolor=Header
_col)
if showMACross

[Link](t,5,1,'Trend',text_color=col_col,text_size=table_text_size,bgcolor=Heade
r_col)
if showRSI

[Link](t,6,1,'RSI',text_color=col_col,text_size=table_text_size,bgcolor=Header_
col)
if showMACDV

[Link](t,7,1,'MACDV',text_color=col_col,text_size=table_text_size,bgcolor=Heade
r_col)
if showSignalV

[Link](t,8,1,'SignalV',text_color=col_col,text_size=table_text_size,bgcolor=Hea
der_col)
if showMACDV_Status

[Link](t,9,1,'Condition',text_color=col_col,text_size=table_text_size,bgcolor=H
eader_col)
if showmomentum
[Link](t,10,1,'Phase
Market',text_color=col_col,text_size=table_text_size,bgcolor=Header_col)

//---- Table Main Column Headers code end ----//

//---- Display data code start ----//

//---------------------- Chart period ----------------------------------

[Link](t,1,2, "Chart",text_color=[Link],text_size=table_text_size,
bgcolor=[Link](0, 68, 255))
if showCls
[Link](t,2,2, [Link](CLS_chart,
'#.###'),text_color=[Link](CLS_chart >CLS_chart[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_chart >CLS_chart[2] ?
cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,2, [Link](MA1_chart,
'#.###'),text_color=[Link](MA1_chart >MA1_chart[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_chart >MA1_chart[1] ?
cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,2, [Link](MA2_chart,
'#.###'),text_color=[Link](MA2_chart >MA2_chart[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_chart >MA2_chart[1] ?
cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,2, MA1_chart > MA2_chart ? "Bullish" :
"Bearish",text_color=[Link](MA1_chart > MA2_chart ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_chart > MA2_chart ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,2, [Link](RSI_chart,
'#.###'),text_color=[Link](RSI_chart > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_chart > 50 ? cell_up :
cell_dn ,cell_transp))
if showMACDV
[Link](t,7,2,[Link](MACDV_chart,
'#.###'),text_color=[Link](MACDV_chart > MACDV_chart[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_chart >
MACDV_chart[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,2,[Link](SignalV_chart,
'#.###'),text_color=[Link](SignalV_chart > SignalV_chart[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_chart>
SignalV_chart[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,2,stringmacdv_chart,text_color=[Link](0, 0,
0),text_size=table_text_size, bgcolor=[Link](MACDV_chart>50 ?
cell_up :MACDV_chart<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,2,stringmomentum_chart,text_color=[Link](2, 2,
2),text_size=table_text_size, bgcolor=[Link](CLS_chart>MA1_chart and
CLS_chart>MA2_chart and MA1_chart<MA2_chart ? cell_phase1 : (CLS_chart>MA1_chart
and CLS_chart>MA2_chart and MA1_chart>MA2_chart) ? cell_phase2 :
(CLS_chart<MA1_chart and CLS_chart>MA2_chart and MA1_chart>MA2_chart) ?
cell_phase3 :(CLS_chart<MA1_chart and CLS_chart<MA2_chart and
MA1_chart>MA2_chart) ? cell_phase4:(CLS_chart<MA1_chart and CLS_chart<MA2_chart and
MA1_chart<MA2_chart) ? cell_phase5:(CLS_chart>MA1_chart and CLS_chart<MA2_chart and
MA1_chart<MA2_chart) ? cell_phase6:col_col,cell_transp))

// alert("\nRSI =(" + [Link](CLS_chart, '#.###') + ")\n Momentum = (" +


[Link](stringmomentum_chart) + ")\n Trend =("+ [Link](MA1_chart >
MA2_chart ? "Bullish" : "Bearish")+").", alert.freq_once_per_bar_close)

//---------------------- 5 minute chart ----------------------------------

[Link](t,1,3, "5 minute",text_color=[Link],text_size=table_text_size,


bgcolor=[Link](0, 68, 255))
if showCls
[Link](t,2,3, [Link](CLS_5_min,
'#.###'),text_color=[Link](CLS_5_min >CLS_5_min[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_5_min >CLS_5_min[2] ?
cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,3, [Link](MA1_5_min,
'#.###'),text_color=[Link](MA1_5_min >MA1_5_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_5_min >MA1_5_min[1] ?
cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,3, [Link](MA2_5_min,
'#.###'),text_color=[Link](MA2_5_min >MA2_5_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_5_min >MA2_5_min[1] ?
cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,3, MA1_5_min > MA2_5_min ? "Bullish" :
"Bearish",text_color=[Link](MA1_5_min > MA2_5_min ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_5_min > MA2_5_min ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,3, [Link](RSI_5_min,
'#.###'),text_color=[Link](RSI_5_min > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_5_min > 50 ? cell_up :
cell_dn ,cell_transp))
if showMACDV
[Link](t,7,3,[Link](MACDV_5_min,
'#.###'),text_color=[Link](MACDV_5_min > MACDV_5_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_5_min >
MACDV_5_min[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,3,[Link](SignalV_5_min,
'#.###'),text_color=[Link](SignalV_5_min > SignalV_5_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_5_min>
SignalV_5_min[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,3,stringmacdv_5_min,text_color=[Link](5, 5,
5),text_size=table_text_size, bgcolor=[Link](MACDV_5_min>50 ?
cell_up :MACDV_5_min<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,3,stringmomentum_5_min,text_color=[Link](5, 5,
5),text_size=table_text_size, bgcolor=[Link](CLS_5_min>MA1_5_min and
CLS_5_min>MA2_5_min and MA1_5_min<MA2_5_min ? cell_phase1 : (CLS_5_min>MA1_5_min
and CLS_5_min>MA2_5_min and MA1_5_min>MA2_5_min) ? cell_phase2 :
(CLS_5_min<MA1_5_min and CLS_5_min>MA2_5_min and MA1_5_min>MA2_5_min) ?
cell_phase3 :(CLS_5_min<MA1_5_min and CLS_5_min<MA2_5_min and
MA1_5_min>MA2_5_min) ? cell_phase4:(CLS_5_min<MA1_5_min and CLS_5_min<MA2_5_min and
MA1_5_min<MA2_5_min) ? cell_phase5:(CLS_5_min>MA1_5_min and CLS_5_min<MA2_5_min and
MA1_5_min<MA2_5_min) ? cell_phase6:col_col,cell_transp))

//---------------------- 15 minute chart ----------------------------------

[Link](t,1,4, "15 minute",text_color=[Link](245, 243,


243),text_size=table_text_size, bgcolor=[Link](0, 68, 255))
if showCls
[Link](t,2,4, [Link](CLS_15_min,
'#.###'),text_color=[Link](CLS_15_min >CLS_15_min[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_15_min
>CLS_15_min[2] ? cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,4, [Link](MA1_15_min,
'#.###'),text_color=[Link](MA1_15_min >MA1_15_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_15_min >MA1_15_min[1]
? cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,4, [Link](MA2_15_min,
'#.###'),text_color=[Link](MA2_15_min >MA2_15_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_15_min
>MA2_15_min[1] ? cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,4, MA1_15_min > MA2_15_min ? "Bullish" :
"Bearish",text_color=[Link](MA1_15_min > MA2_15_min ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_15_min > MA2_15_min ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,4, [Link](RSI_15_min,
'#.###'),text_color=[Link](RSI_15_min > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_15_min > 50 ?
cell_up : cell_dn ,cell_transp))
if showMACDV
[Link](t,7,4,[Link](MACDV_15_min,
'#.###'),text_color=[Link](MACDV_15_min > MACDV_15_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_15_min >
MACDV_15_min[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,4,[Link](SignalV_15_min,
'#.###'),text_color=[Link](SignalV_15_min > SignalV_15_min[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_15_min>
SignalV_15_min[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,4,stringmacdv_15_min,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](MACDV_15_min>50 ?
cell_up :MACDV_15_min<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,4,stringmomentum_15_min,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](CLS_15_min>MA1_15_min and
CLS_15_min>MA2_15_min and MA1_15_min<MA2_15_min ? cell_phase1 :
(CLS_15_min>MA1_15_min and CLS_15_min>MA2_15_min and MA1_15_min>MA2_15_min) ?
cell_phase2 : (CLS_15_min<MA1_15_min and CLS_15_min>MA2_15_min and
MA1_15_min>MA2_15_min) ?cell_phase3 :(CLS_15_min<MA1_15_min and
CLS_15_min<MA2_15_min and MA1_15_min>MA2_15_min) ? cell_phase4:
(CLS_15_min<MA1_15_min and CLS_15_min<MA2_15_min and MA1_15_min<MA2_15_min) ?
cell_phase5:(CLS_15_min>MA1_15_min and CLS_15_min<MA2_15_min and
MA1_15_min<MA2_15_min) ? cell_phase6:col_col,cell_transp))

//---------------------- 1 Hour chart ----------------------------------

[Link](t,1,6, "1 Hour",text_color=[Link],text_size=table_text_size,


bgcolor=[Link](0, 68, 255))
if showCls
[Link](t,2,6, [Link](CLS_1_hour,
'#.###'),text_color=[Link](CLS_1_hour >CLS_1_hour[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_1_hour
>CLS_1_hour[2] ? cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,6, [Link](MA1_1_hour,
'#.###'),text_color=[Link](MA1_1_hour >MA1_1_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_1_hour >MA1_1_hour[1]
? cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,6, [Link](MA2_1_hour,
'#.###'),text_color=[Link](MA2_1_hour >MA2_1_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_1_hour
>MA2_1_hour[1] ? cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,6, MA1_1_hour > MA2_1_hour ? "Bullish" :
"Bearish",text_color=[Link](MA1_1_hour > MA2_1_hour ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_1_hour > MA2_1_hour ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,6, [Link](RSI_1_hour,
'#.###'),text_color=[Link](RSI_1_hour > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_1_hour > 50 ?
cell_up : cell_dn ,cell_transp))
if showMACDV
[Link](t,7,6,[Link](MACDV_1_hour,
'#.###'),text_color=[Link](MACDV_1_hour > MACDV_1_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_1_hour >
MACDV_1_hour[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,6,[Link](SignalV_1_hour,
'#.###'),text_color=[Link](SignalV_1_hour > SignalV_1_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_1_hour>
SignalV_1_hour[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,6,stringmacdv_1_hour,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](MACDV_1_hour>50 ?
cell_up :MACDV_1_hour<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,6,stringmomentum_1_hour,text_color=[Link](8, 8,
8),text_size=table_text_size, bgcolor=[Link](CLS_1_hour>MA1_1_hour and
CLS_1_hour>MA2_1_hour and MA1_1_hour<MA2_1_hour ? cell_phase1 :
(CLS_1_hour>MA1_1_hour and CLS_1_hour>MA2_1_hour and MA1_1_hour>MA2_1_hour) ?
cell_phase2 : (CLS_1_hour<MA1_1_hour and CLS_1_hour>MA2_1_hour and
MA1_1_hour>MA2_1_hour) ?cell_phase3 :(CLS_1_hour<MA1_1_hour and
CLS_1_hour<MA2_1_hour and MA1_1_hour>MA2_1_hour) ? cell_phase4:
(CLS_1_hour<MA1_1_hour and CLS_1_hour<MA2_1_hour and MA1_1_hour<MA2_1_hour) ?
cell_phase5:(CLS_1_hour>MA1_1_hour and CLS_1_hour<MA2_1_hour and
MA1_1_hour<MA2_1_hour) ? cell_phase6:col_col,cell_transp))

//---------------------- 4 Hour chart ----------------------------------

[Link](t,1,7, "4 Hour",text_color=[Link],text_size=table_text_size,


bgcolor=[Link](0, 68, 255))
if showCls
[Link](t,2,7, [Link](CLS_4_hour,
'#.###'),text_color=[Link](CLS_4_hour >CLS_4_hour[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_4_hour
>CLS_4_hour[2] ? cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,7, [Link](MA1_4_hour,
'#.###'),text_color=[Link](MA1_4_hour >MA1_4_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_4_hour >MA1_4_hour[1]
? cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,7, [Link](MA2_4_hour,
'#.###'),text_color=[Link](MA2_4_hour >MA2_4_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_4_hour
>MA2_4_hour[1] ? cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,7, MA1_4_hour > MA2_4_hour ? "Bullish" :
"Bearish",text_color=[Link](MA1_4_hour > MA2_4_hour ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_4_hour > MA2_4_hour ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,7, [Link](RSI_4_hour,
'#.###'),text_color=[Link](RSI_4_hour > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_4_hour > 50 ?
cell_up : cell_dn ,cell_transp))
if showMACDV
[Link](t,7,7,[Link](MACDV_4_hour,
'#.###'),text_color=[Link](MACDV_4_hour > MACDV_4_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_4_hour >
MACDV_4_hour[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,7,[Link](SignalV_4_hour,
'#.###'),text_color=[Link](SignalV_4_hour > SignalV_4_hour[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_4_hour>
SignalV_4_hour[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,7,stringmacdv_4_hour,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](MACDV_4_hour>50 ?
cell_up :MACDV_4_hour<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,7,stringmomentum_4_hour,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](CLS_4_hour>MA1_4_hour and
CLS_4_hour>MA2_4_hour and MA1_4_hour<MA2_4_hour ? cell_phase1 :
(CLS_4_hour>MA1_4_hour and CLS_4_hour>MA2_4_hour and MA1_4_hour>MA2_4_hour) ?
cell_phase2 : (CLS_4_hour<MA1_4_hour and CLS_4_hour>MA2_4_hour and
MA1_4_hour>MA2_4_hour) ?cell_phase3 :(CLS_4_hour<MA1_4_hour and
CLS_4_hour<MA2_4_hour and MA1_4_hour>MA2_4_hour) ? cell_phase4:
(CLS_4_hour<MA1_4_hour and CLS_4_hour<MA2_4_hour and MA1_4_hour<MA2_4_hour) ?
cell_phase5:(CLS_4_hour>MA1_4_hour and CLS_4_hour<MA2_4_hour and
MA1_4_hour<MA2_4_hour) ? cell_phase6:col_col,cell_transp))

//---------------------- 1 Day chart ----------------------------------

[Link](t,1,9, "1 Day",text_color=[Link],text_size=table_text_size,


bgcolor=[Link](0, 68, 253))
if showCls
[Link](t,2,9, [Link](CLS_1_day,
'#.###'),text_color=[Link](CLS_1_day >CLS_1_day[2] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](CLS_1_day >CLS_1_day[2] ?
cell_up : cell_dn ,cell_transp))
if showMA01
[Link](t,3,9, [Link](MA1_1_day,
'#.###'),text_color=[Link](MA1_1_day >MA1_1_day[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_1_day >MA1_1_day[1] ?
cell_up : cell_dn ,cell_transp))
if showMA02
[Link](t,4,9, [Link](MA2_1_day,
'#.###'),text_color=[Link](MA2_1_day >MA2_1_day[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA2_1_day >MA2_1_day[1] ?
cell_up : cell_dn ,cell_transp))
if showMACross
[Link](t,5,9, MA1_1_day > MA2_1_day ? "Bullish" :
"Bearish",text_color=[Link](MA1_1_day > MA2_1_day ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MA1_1_day > MA2_1_day ?
cell_up : cell_dn ,cell_transp))
if showRSI
[Link](t,6,9, [Link](RSI_1_day,
'#.###'),text_color=[Link](RSI_1_day > 50 ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](RSI_1_day > 50 ? cell_up :
cell_dn ,cell_transp))
if showMACDV
[Link](t,7,9,[Link](MACDV_1_day,
'#.###'),text_color=[Link](MACDV_1_day > MACDV_1_day[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](MACDV_1_day >
MACDV_1_day[1] ? cell_up : cell_dn ,cell_transp))
if showSignalV
[Link](t,8,9,[Link](SignalV_1_day,
'#.###'),text_color=[Link](SignalV_1_day > SignalV_1_day[1] ? cell_up :
cell_dn ,0),text_size=table_text_size, bgcolor=[Link](SignalV_1_day>
SignalV_1_day[1] ? cell_up : cell_dn ,cell_transp))
if showMACDV_Status
[Link](t,9,9,stringmacdv_1_day,text_color=[Link](5, 5,
5),text_size=table_text_size, bgcolor=[Link](MACDV_1_day>50 ?
cell_up :MACDV_1_day<-50 ? cell_dn:cell_MACDV4 ,cell_transp))
if showmomentum
[Link](t,10,9,stringmomentum_1_day,text_color=[Link](7, 7,
7),text_size=table_text_size, bgcolor=[Link](CLS_1_day>MA1_1_day and
CLS_1_day>MA2_1_day and MA1_1_day<MA2_1_day ? cell_phase1 : (CLS_1_day>MA1_1_day
and CLS_1_day>MA2_1_day and MA1_1_day>MA2_1_day) ? cell_phase2 :
(CLS_1_day<MA1_1_day and CLS_1_day>MA2_1_day and MA1_1_day>MA2_1_day) ?
cell_phase3 :(CLS_1_day<MA1_1_day and CLS_1_day<MA2_1_day and
MA1_1_day>MA2_1_day) ? cell_phase4:(CLS_1_day<MA1_1_day and CLS_1_day<MA2_1_day and
MA1_1_day<MA2_1_day) ? cell_phase5:(CLS_1_day>MA1_1_day and CLS_1_day<MA2_1_day and
MA1_1_day<MA2_1_day) ? cell_phase6:col_col,cell_transp))

//---- Display data code end ----//


//End dash board

// Gaps start --

closeGapsPartially = [Link](false, "Close Gaps Partially")


boxLimitInput = [Link](15, "Max Number of Gaps", minval = 1, maxval = 500)
minimalDeviationTooltip = "Specifies the minimal size of detected gaps, as a
percentage of the average high-low range for the last 14 bars."
minimalDeviationInput = nz([Link](30.0, "Minimal Deviation (%)", tooltip =
minimalDeviationTooltip, minval=1, maxval=100) / 100 * [Link](high-low, 14))
limitBoxLengthBoolInput = [Link](false, "Limit Max Gap Trail Length (bars)",
inline = "Length Limit")
limitBoxLengthIntInput = [Link](300, "", inline = "Length Limit", minval = 1)

groupName = "Border and fill colors"


colorUpBorderInput = [Link]([Link], "Up Gaps", inline = "Gap Up", group =
groupName)
colorUpBackgroundInput = [Link]([Link]([Link], 85), "", inline = "Gap
Up", group = groupName)
colorDownBorderInput = [Link]([Link], "Down Gaps", inline = "Gap Down",
group = groupName)
colorDownBackgroundInput = [Link]([Link]([Link], 85), "", inline = "Gap
Down", group = groupName)

type AlertInfo
int countOpenGap
int countClosedGap

method hasOpenedGap(AlertInfo this) =>


[Link] > 0

method hasClosedGap(AlertInfo this) =>


[Link] > 0

AlertInfo alertInfo = [Link](0, 0)

//@type A representation of a chart gap and all box drawings that it consists of.
//@field isActive If 'true', the gap has not yet been closed and is still being
extended on the chart.
//@field isBull The direction of the gap: 'true' for upward gaps and 'false' for
downward ones.
//@field inactiveBoxes An array of all boxes that have been drawn for this gap. The
last element of the array is the box on the chart that is currently extended
further.
type Gap
bool isActive
bool isBull
array<box> boxes
//@function Deletes all of the boxes that were drawn to represent the gap.
method delete(Gap this) =>
for _box in [Link]
_box.delete()

//@function Closes the gap partially, stopping the previous box and creating a new,
smaller box to continue the gap instead.
method partialClose(Gap this) =>
activeBox = [Link]()
activeBox.set_extend([Link])

top = [Link] ? activeBox.get_top() : low


bottom = [Link] ? high : activeBox.get_bottom()

[Link]([Link](
bar_index,
top,
bar_index,
bottom,
[Link] ? colorDownBorderInput : colorUpBorderInput,
bgcolor = [Link] ? colorDownBackgroundInput : colorUpBackgroundInput))

//@function Closes the gap fully, stopping the box from being extended.
method fullClose(Gap this) =>
[Link] += 1
activeBox = [Link]()
activeBox.set_extend([Link])
[Link] := false
if closeGapsPartially
[Link]()

method checkForClose(Gap this) =>


if [Link]
activeBox = [Link]()
top = activeBox.get_top()
bot = activeBox.get_bottom()
isBull = [Link]
activeBox.set_right(bar_index)

if (high > bot and isBull) or (low < top and not isBull)
if closeGapsPartially
[Link]()
else
[Link]()

bool forceCloseBoxExceededLengthLimit = (limitBoxLengthBoolInput and


bar_index - activeBox.get_left() >= limitBoxLengthIntInput)
if ((high > top and isBull) or (low < bot and not isBull)) or
forceCloseBoxExceededLengthLimit
[Link]()

var allGaps = [Link]<Gap>()

// Detect gaps.
isGapDown = high < low[1] and low[1] - high >= minimalDeviationInput
isGapUp = low > high[1] and low - high[1] >= minimalDeviationInput
isGap = isGapDown or isGapUp
boxBorderColor = isGapDown ? colorDownBorderInput : colorUpBorderInput
boxBgcolor = isGapDown ? colorDownBackgroundInput : colorUpBackgroundInput

registerNewGap(bool isGapDown) =>


[Link] += 1

newBox = [Link](
bar_index - 1,
(isGapDown ? low[1] : low),
bar_index,
(isGapDown ? high : high[1]),
border_color = boxBorderColor,
bgcolor = boxBgcolor,
extend = [Link])

[Link]([Link](true, isGapDown, [Link](newBox)))

if [Link]() > boxLimitInput


[Link]().delete()

// Detect covering of gaps.


for gap in allGaps
[Link]()

// Add a box for each new gap, removing the oldest one if needed.
if isGap
registerNewGap(isGapDown)

if [Link] and [Link]() == 0


noGapText = "No gaps found on the current chart. \n The cause could be that
some exchanges align the open of new bars on the close of the previous one,
resulting in charts with no gaps. Alternatively, your Minimal Deviation might be
too high."
var infoTable = [Link](position.bottom_right, 1, 1)
[Link](infoTable, 0, 0, text = noGapText, text_color = chart.bg_color,
bgcolor = chart.fg_color)

// Gaps end --

// Entry & Exit Functions //


//Entry Long Strategy
//if (InDateRange and Long==true and close > pp_pivot and high < pp_pivot0 and
close < r1_pivot )
//BuyCond1 = high[2] > basis and high[1] > upper and high < r1_pivot and 3*low >
(d_highW0 + d_lowW0 + d_closeW0)
//BuyCond2 = (close < open and close > basis and low < basis and low > r1_pivot)
//BuyCond1 = (pp_pivotC0 < pp_pivotC1) and high > r1_pivot
// BuyCond1 = close[1] > d_close
// // BuyCond2 = close > [Link]
// // BuyCond3 = low[1]< [Link]
// BuyCond4 = close > pp_pivotH4_1
// BuyCond5 = close[1] < open[1]
// BuyCond6 = close[1] > lower and close > lower
BuyCond1 = open < pp_pivotC1 and close > pp_pivotC1
BuyCond2 = close > pp_pivotH0
BuyCond3 = RSI_15_min > 50
if (InDateRange and Long==true and (BuyCond1 and BuyCond2 and BuyCond3))
[Link]("LongPosition", [Link], qty = 200)
//Entry Short Strategy

//if (InDateRange and Short==true and close < pp_pivot and low > pp_pivot0 and
close > s1_pivot)
//SellCond1 = low[2] < basis and low[1] < lower and low < s1_pivot and 3*high <
(d_highW0 + d_lowW0 + d_closeW0)
//SellCond2 = (open < close and close < basis and high > basis and high <
s1_pivot )
//SellCond1 = (pp_pivotC0 > pp_pivotC1) and high < s1_pivot
// SellCond1 = close[1] < d_close
// // SellCond2 = close < [Link]
// // SellCond3 = high[1] > [Link]
// SellCond4 = close < pp_pivotH4_1
// SellCond5 = open[1] < close[1]
// SellCond6 = close[1] < upper and close < upper
// SellCond1 = close > open
// SellCond2 = close < basis
// SellCond3 = open < pp_pivot
SellCond1 = open > pp_pivotC1 and close < pp_pivotC1
SellCond2 = close < pp_pivotH0
SellCond3 = RSI_15_min < 50
if (InDateRange and Short==true and SellCond1 and SellCond2 and SellCond3)
[Link]("ShortPosition", [Link], qty = 200)

//Exit Long Strategy


if (InDateRange and high > upper_e)
[Link]("LongPosition", qty = 200)
// [Link]("ShortPosition", qty = 200)
// [Link]("ShortPosition", qty = 10) //Exit Sell

//Exit Short Strategy


if (InDateRange and low < lower_e)
[Link]("ShortPosition", qty = 200)
// [Link]("LongPosition", qty = 200)

///////////////////////////////////////////////////////

// Higher Highs and Higher Lows

// lengthGroupTitle = "LENGTH LEFT / RIGHT"


// colorGroupTitle = "Text Color / Label Color"
// leftLenH = [Link](title="Pivot High", defval=10, minval=1, inline="Pivot
High", group=lengthGroupTitle)
// rightLenH = [Link](title="/", defval=10, minval=1, inline="Pivot High",
group=lengthGroupTitle)

// leftLenL = [Link](title="Pivot Low", defval=10, minval=1, inline="Pivot Low",


group=lengthGroupTitle)
// rightLenL = [Link](title="/", defval=10, minval=1, inline="Pivot Low",
group=lengthGroupTitle)

// ph = [Link](leftLenH, rightLenH)
// pl = [Link](leftLenL, rightLenL)

// plotshape(ph, title="HH", location=[Link], color=[Link],


transp=0, style=[Link], text="HH")
// plotshape(pl, title="HL", location=[Link], color=[Link], transp=0,
style=[Link], text="LL")
// // HH LL ends

You might also like