0% found this document useful (0 votes)
619 views24 pages

VMS Gann Angles With Volatility Ver.1

This document contains the source code for a TradingView indicator that calculates and displays buying and selling volume metrics over different time periods. It includes functions for filling cells in tables to display the values, handling different time frames, and toggling between percentage and raw volume displays. The code also contains sections for risk disclaimers, styling options, and switching between multiple versions of the indicator.

Uploaded by

Vipul Agrawal
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)
619 views24 pages

VMS Gann Angles With Volatility Ver.1

This document contains the source code for a TradingView indicator that calculates and displays buying and selling volume metrics over different time periods. It includes functions for filling cells in tables to display the values, handling different time frames, and toggling between percentage and raw volume displays. The code also contains sections for risk disclaimers, styling options, and switching between multiple versions of the indicator.

Uploaded by

Vipul Agrawal
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
You are on page 1/ 24

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

0 at
https://mozilla.org/MPL/2.0/
// © madhavbbs

//@version=4
study(title="VMS Gann Angles With Volatility Ver.1", shorttitle="VMS Gann Ver.1",
overlay=true, format=format.price, precision=2)
///// RISK CHECKER
risk_checker_input = input(title="I know I have to do my own research and that I'm
trading at my own risk. I'm only trading with money I'm willing to lose or gain.",
type=input.bool, defval=false)
risk_checked = risk_checker_input==true
risk_unchecked = risk_checker_input==false
risk_checker = risk_unchecked
plotshape(risk_checker, title="Risk Checker", style=shape.labeldown, text="Accept
risks in settings menu to start indicator !" ,textcolor=color.white,
color=color.red, location=location.abovebar, size=size.huge, transp=0, show_last=1)
offset_val = input(title="Label Offset", type=input.integer, defval=50)
showlabels = input(title="Show Labels", type=input.bool, defval=true)

string i_text1 = input("VMS TradingView Indicators", "Text 1", inline = "11")


string i_text2 = input("t.me/VMSTradingViewindicators", "Text 2", inline =
"11", tooltip = "Clear 'Text 2' to prevent animation.")
string i_tableYpos = input("bottom", "Position", inline = "12", options = ["top",
"middle", "bottom"])
string i_tableXpos = input("left", "", inline = "12", options = ["left", "center",
"right"])
int i_height = input(6, "Height", minval = 1, maxval = 100, inline = "13")
int i_width = input(25, "Width", minval = 1, maxval = 100, inline = "13",
tooltip = "1-100")
color i_c_text = input(color.new(color.white, 0), "Text", inline = "14")
string i_textSize = input("normal", "Size", inline = "14", options = ["tiny",
"small", "normal", "large", "huge", "auto"])
color i_c_bg = input(color.new(color.blue, 0), "Background")

// We use `var` to only initialize the table on the first bar.


var table watermark = table.new(i_tableYpos + "_" + i_tableXpos, 1, 1)

// We only populate the table on the last bar; it's more efficient.
if barstate.islast
// This `varip` variable will preserve its value across realtime updates.
varip bool _changeText = true
// Toggle this value on each update.
_changeText := not _changeText
// If there's a "Text 2" string in inputs and it's time to flip, change the
text.
string _txt = str.length(i_text2) != 0 and _changeText ? i_text2 : i_text1
// Populate our table cell.
table.cell(watermark, 0, 0, _txt, i_width, i_height, i_c_text, text_size =
i_textSize, bgcolor = i_c_bg)

//2
///////////////////////////////////////////////////////////////////////////
switch_v1=input(false,"Switch to version 1.0",tooltip="You are currently on version
2.0 of this indicator , check this box in order to switch to version 1.0 of the
indicator")
var table perfTable = table.new(position.top_right, 4,4 , border_width = 3)

LIGHTTRANSP = 90
AVGTRANSP = 80
HEAVYTRANSP = 90

i_posColor = input(color.rgb(50,205,50), title="Positive Color")


i_negColor = input(color.rgb(255, 0, 0), title="Negative Color")

f_fillCell(_table, _column, _row, _value, _timeframe) =>


_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = abs(_value) > 10 ? HEAVYTRANSP : abs(_value) > 5 ? AVGTRANSP :
LIGHTTRANSP
_cellText = tostring(_value, "#.##") + "%\n" + _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color,
_transp), text_color = _c_color, width = 15)

f_fillCell_without_per(_table, _column, _row, _value, _timeframe) =>


_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = abs(_value) > 10 ? HEAVYTRANSP : abs(_value) > 5 ? AVGTRANSP :
LIGHTTRANSP
_cellText = tostring(_value, "#.##") + "\n"+ _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color,
_transp), text_color = _c_color, width = 15)

///////////////////////////////////////////////////////////////////////////////////
///////////
//code to count all candels from the start of the day
session_bar_counter = bar_index - valuewhen(change(time("D")) != 0, bar_index, 0)
disable_current=input(title="On/Off Currnet bar Volume", type=input.bool,
defval=true)
change_vol_percentage=input(title="% ", type=input.bool,
defval=true,tooltip="change % to actual volume")

//declare variable for sum of volume


sum_sv = 0.0
sum_bv = 0.0

//code to print volume on screen


f_print_bv(_txt) => var _lbl = label(na), label.delete(_lbl), _lbl :=
label.new(time, close*1.05, _txt+'\n '+"Day Buying Vol", xloc.bar_time, yloc.price,
size = size.normal,color=color.lime,style=label.style_label_right)
f_print_sv(_txt) => var _lbl = label(na), label.delete(_lbl), _lbl :=
label.new(time , close*1.05, _txt+'\n '+"Day Selling Vol", xloc.bar_time,
yloc.price, size = size.normal,style=label.style_label_left,color=color.red)

//code to check if the bar length is greater than a day


is_newbar(res) =>
t = time(res)
not na(t) and (na(t[1]) or t > t[1])
if_bar_greater_than_day=(is_newbar("D") or is_newbar("W") or is_newbar("M")) ? 1 :
0
volD = security(syminfo.tickerid, 'D', volume)

//array to store sum of buying and selling value


var pos_bv_arr = array.new_int()

//variable to check change of Day


t_m = change(time("D"))
//fpr loop to store sum of buying and selling value
for i=1 to session_bar_counter
if close[i] > open[i]
up=close[i] > open[i] ? 1 : 0
a=0,a := t_m ? up : a[1] + up
array.unshift(pos_bv_arr,a)
else
array.unshift(pos_bv_arr,0)

if(array.size(pos_bv_arr)>(session_bar_counter+1))
array.pop(pos_bv_arr)

//condition to display the buying and selling volumes and store the sumed volume
if not if_bar_greater_than_day and barstate.islast
if close <= open
sum_sv := volume
for i = 0 to session_bar_counter
if(array.get(pos_bv_arr,i)==0)
sum_sv := sum_sv + volume[session_bar_counter-i]
//sum_sv:=0
if not if_bar_greater_than_day and barstate.islast
if close >= open
sum_bv := volume
for i = 0 to session_bar_counter
if(array.get(pos_bv_arr,i)!=0)
sum_bv := sum_bv + volume[session_bar_counter-i]
//sum_bv:=0

///variable to store percentage value of the buying and selling volumes and store
the sumed volume
per_or_not_sv=change_vol_percentage?sum_sv/(sum_sv+sum_bv)*100:sum_sv
per_or_not_bv=change_vol_percentage?sum_bv/(sum_sv+sum_bv)*100:sum_bv

//if time frame is not greater than day then show the days buying and selling
volumes and percentage value enabled
if(barstate.islast and not if_bar_greater_than_day and change_vol_percentage and
switch_v1)
f_print_sv(tostring(round((per_or_not_sv)* 10) / 10)+'%')
f_print_bv(tostring(round((per_or_not_bv)* 10) / 10)+'%')

if(barstate.islast and not if_bar_greater_than_day and change_vol_percentage and


not switch_v1)
f_fillCell(perfTable, 0, 2, round((per_or_not_bv)* 10) / 10, "Days Buying vol")
f_fillCell(perfTable, 0, 1, -round((per_or_not_sv)* 10) / 10, "Days Selling
vol")
//if time frame is not greater than day then show the days buying and selling
volumes
if(barstate.islast and not if_bar_greater_than_day and not change_vol_percentage
and switch_v1)
f_print_sv(tostring(round((-per_or_not_sv)* 10) / 10))
f_print_bv(tostring(round((per_or_not_bv)* 10) / 10))
if(barstate.islast and not if_bar_greater_than_day and not change_vol_percentage
and not switch_v1)
f_fillCell_without_per(perfTable, 0, 2, round((per_or_not_bv)* 10) / 10, "Days
Buying vol")
f_fillCell_without_per(perfTable, 0, 1, -round((per_or_not_sv)* 10) / 10, "Days
Selling vol")

///if time frame greater than Day than only current bar volume is shown
var label vol=na
if(barstate.islast and open<close and if_bar_greater_than_day and switch_v1)
vol:=label.new(bar_index, na,text=tostring(volume)+'\n '+"current Bar Volume",
color=color.lime,style=label.style_labeldown, yloc=yloc.abovebar)

if(barstate.islast and open<close and if_bar_greater_than_day and not switch_v1)


f_fillCell_without_per(perfTable, 0, 3, round((volume)), "current Bar vol")

if(barstate.islast and open>close and if_bar_greater_than_day and switch_v1)


vol:=label.new(bar_index, na,text=tostring(volume)+'\n '+"current Bar Volume",
color=color.red,style=label.style_labeldown, yloc=yloc.abovebar)

if(barstate.islast and open>close and if_bar_greater_than_day and not switch_v1)


f_fillCell_without_per(perfTable, 0, 3, -round((volume)), "current Bar vol")

label.delete(vol[1])

///code to disable current bar volume is from time frame less than "D"
var label vol_current=na
if(barstate.islast and open<close and not if_bar_greater_than_day and
disable_current and switch_v1)
vol_current:=label.new(bar_index, na,text=tostring(volume)+'\n '+"current Bar
Volume", color=color.lime,style=label.style_labeldown, yloc=yloc.abovebar)
if(barstate.islast and open<close and not if_bar_greater_than_day and
disable_current and not switch_v1)
f_fillCell_without_per(perfTable, 0, 3, round((volume)), "current Bar vol")

if(barstate.islast and open>close and not if_bar_greater_than_day and


disable_current and switch_v1 )
vol_current:=label.new(bar_index, na,text=tostring(volume)+'\n '+"current Bar
Volume", color=color.red,style=label.style_labeldown, yloc=yloc.abovebar)
if(barstate.islast and open>close and not if_bar_greater_than_day and
disable_current and not switch_v1 )
f_fillCell_without_per(perfTable, 0, 3, -round((volume)), "current Bar vol")

label.delete(vol_current[1])

//3
var table perfTable1 = table.new(position.top_left, 3, 2, border_width = 3)

LIGHTTRANSP1 = 90
AVGTRANSP1 = 80
HEAVYTRANSP1 = 70

i_posColor1 = input(color.rgb(38, 166, 154), title="Positive Color")


i_negColor1 = input(color.rgb(240, 83, 80), title="Negative Color")

f_rateOfreturn(_v1, _v2) => (_v1 - _v2) * 100 / abs(_v2)

f_performance(_barsBack) =>
_performance = security(syminfo.tickerid, "1D", f_rateOfreturn(close,
close[_barsBack]))
_performance

lastYearClose = security(syminfo.tickerid, "12M", close[1],


lookahead=barmerge.lookahead_on)
f_fillCell1(_table, _column, _row, _value, _timeframe) =>
_c_color = _value >= 0 ? i_posColor1 : i_negColor1
_transp = abs(_value) > 10 ? HEAVYTRANSP1 : abs(_value) > 5 ? AVGTRANSP1 :
LIGHTTRANSP1
_cellText = tostring(_value, "0.00") + "%\n" + _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color,
_transp), text_color = _c_color, width = 6)

if barstate.islast
f_fillCell1(perfTable1, 0, 0, f_performance(5), "1W")
f_fillCell1(perfTable1, 1, 0, f_performance(21), "1M")
f_fillCell1(perfTable1, 2, 0, f_performance(63), "3M")
f_fillCell1(perfTable1, 0, 1, f_performance(126), "6M")
f_fillCell1(perfTable1, 1, 1, f_rateOfreturn(close, lastYearClose), "YTD")
f_fillCell1(perfTable1, 2, 1, f_performance(251), "1Y")
//4

tick = input(title="Symbol", type=input.symbol, defval="", tooltip="Select the


ticker you want to track.")
res = input(title="Resolution", type=input.resolution, defval="", tooltip="Select
the resolution you want to track.")
source = security(tick,res,close)

////////////////////////////////////////////////////////////////////////////////
// A. Oscillators //
////////////////////////////////////////////////////////////////////////////////

//1. Relative Strength Index (14)


RSI(src,per) =>
len = per
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
RSI=rsi
rsi_Sig=RSI(source,14)

//RSI Signal
A1_red =
rsi_Sig<30
?1:0
A1_blue =
rsi_Sig>70
?1:0

//2. Stochastic %K (14, 3, 3)


STOCH(src,perK,perD,perS) =>
K = perK
D = perD
smooth = perS
hh = highest(security(tick,res,high), K)
ll = lowest(security(tick,res,low), K)
k = sma((src - ll) / (hh - ll) * 100, smooth)
d = sma(k, D)
STOCH=k
stoch_Sig = STOCH(source,14,3,3)
//STOCH Signal
A2_red =
stoch_Sig<20
?1:0
A2_blue =
stoch_Sig>80
?1:0

//3. Commodity Channel Index (20)


CCI(src,per) =>
lengthcci1 = per
macci1 = sma(src, lengthcci1)
cci1 = (src - macci1) / (0.015 * dev(src, lengthcci1))
CCI = cci1
cci_Sig=CCI(source,20)

//CCI Signal
A3_red =
cci_Sig<-100
?1:0
A3_blue =
cci_Sig>100
?1:0

//4. Average Directional Index (14)


adxlen = 14
dilen = 14
dirmov(len) =>
up = change(security(tick,res,high))
down = -change(security(tick,res,low))
truerange = rma(security(tick,res,tr), len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]

ADX(dilen, adxlen) =>


[plus, minus] = dirmov(dilen)
sum = plus + minus
ADX = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

adxHigh(dilen, adxlen) =>


[plus, minus] = dirmov(dilen)
plus

adxLow(dilen, adxlen) =>


[plus, minus] = dirmov(dilen)
minus

ADX_Sig = ADX(dilen, adxlen)


di_sigHigh = adxHigh(dilen, adxlen)
di_sigLow = adxLow(dilen, adxlen)

//ADX Signal
A4_red =
di_sigLow>di_sigHigh
and ADX_Sig>25
?1:0
A4_blue =
di_sigHigh>di_sigLow
and ADX_Sig>25
?1:0

//5. Awesome Oscillator


ao = sma(security(tick,res,hl2),5) - sma(security(tick,res,hl2),34)

//AO Signal
A5_red =
ao<0
?1:0
A5_blue =
ao>0
?1:0

//6. Momentum (10)


mom = source - source[10]

//momentum Signal
A6_red =
mom<0
?1:0
A6_blue =
mom>0
?1:0

//7. MACD Level (12, 26)


fast_ma = ema(source, 12)
slow_ma = ema(source, 26)
macd = fast_ma - slow_ma
signal = ema(macd, 9)
hist = macd - signal

//MACD Signal
A7_red =
hist < hist[1]
?1:0
A7_blue =
hist > hist[1]
?1:0

//8. Stochastic RSI Fast (3, 3, 14, 14)


rsi1 = rsi(source, 14)
rsik = sma(stoch(rsi1, rsi1, rsi1, 14), 3)
rsid = sma(rsik, 3)
rsih0 = 80
rsih1 = 20

//Stoch RSI Signal


A8_red =
rsik < rsih1
?1:0
A8_blue =
rsik > rsih0
?1:0

//9. Williams Percent Range (14)


upper = highest(source, 14)
lower = lowest(source, 14)
out = 100 * (source - upper) / (upper - lower)
rband1 = -20
rband0 = -80

// %R Signal
A9_red =
out < rband0
?1:0
A9_blue =
out > rband1
?1:0

//10. Bull bear Power


Length = 30
r1=iff(source[1]<security(tick,res,open),max(security(tick,res,high-open)-
source[1],security(tick,res,high-low)),security(tick,res,high-low))
r2=iff(source[1]>security(tick,res,open),max(source[1]-
security(tick,res,open),security(tick,res,high-low)),security(tick,res,high-low))
bull=iff(source==security(tick,res,open),iff(security(tick,res,high)-
source==source-
security(tick,res,low),iff(source[1]>security(tick,res,open),max(security(tick,res,
high-low),source-security(tick,res,low)),r1),iff(security(tick,res,high)-
source>source-security(tick,res,low),iff(source[1]<security(tick,res,open),
max(security(tick,res,high)-source[1],source-security(tick,res,low)),
security(tick,res,high-
open)),r1)),iff(source<security(tick,res,open),iff(source[1]<security(tick,res,open
),max(security(tick,res,high)-source[1],source-security(tick,res,low)),
max(security(tick,res,high-low),source-security(tick,res,low))),r1))
bear=iff(source==security(tick,res,open),iff(security(tick,res,high)-
source==source-
security(tick,res,low),iff(source[1]<security(tick,res,open),max(security(tick,res,
open-low),security(tick,res,high)-source),r2),iff(security(tick,res,high)-
source>source-
security(tick,res,low),r2,iff(source[1]>security(tick,res,open),max(source[1]-
security(tick,res,low),security(tick,res,high)-source), security(tick,res,open-
low)))),iff(source<security(tick,res,open),r2,iff(source[1]>security(tick,res,open)
,max(source[1]-security(tick,res,low),security(tick,res,high)-
source),max(security(tick,res,open-low),security(tick,res,high)-source))))

// Bull bear Signal


A10_red =
sma(bull-bear,Length)<0
?1:0
A10_blue =
sma(bull-bear,Length)>0
?1:0

//11.Ultimate Oscillator (7, 14, 28)


length7 = 7,
length14 = 14,
length28 = 28
average(bp, tr_, length) => sum(bp, length) / sum(tr_, length)
high_ = max(security(tick,res,high), source[1])
low_ = min(security(tick,res,low), source[1])
bp = source - low_
tr_ = high_ - low_
avg7 = average(bp, tr_, length7)
avg14 = average(bp, tr_, length14)
avg28 = average(bp, tr_, length28)
uoout = 100 * (4*avg7 + 2*avg14 + avg28)/7

// UO Signal
A11_red =
uoout < 30
?1:0
A11_blue =
uoout > 70
?1:0

//Sum Signal A
A_red = A1_red + A2_red + A3_red + A4_red + A5_red + A6_red + A7_red + A8_red +
A9_red + A10_red + A11_red
A_blue = A1_blue + A2_blue + A3_blue + A4_blue + A5_blue + A6_blue + A7_blue +
A8_blue + A9_blue + A10_blue + A11_blue

////////////////////////////////////////////////////////////////////////////////
// B. Moving Averages //
////////////////////////////////////////////////////////////////////////////////

//1. EMA (5)


B1_red =
source<ema(source,5)
?1:0
B1_blue =
source>ema(source,5)
?1:0

//2. SMA (5)


B2_red =
source<sma(source,5)
?1:0
B2_blue =
source>sma(source,5)
?1:0

//3. EMA (10)


B3_red =
source<ema(source,10)
?1:0
B3_blue =
source>ema(source,10)
?1:0

//4. SMA (10)


B4_red =
source<sma(source,10)
?1:0
B4_blue =
source>sma(source,10)
?1:0

//5. EMA (20)


B5_red =
source<ema(source,20)
?1:0
B5_blue =
source>ema(source,20)
?1:0

//6. SMA (20)


B6_red =
source<sma(source,20)
?1:0
B6_blue =
source>sma(source,20)
?1:0

//7. EMA (30)


B7_red =
source<ema(source,30)
?1:0
B7_blue =
source>ema(source,30)
?1:0

//8. SMA (30)


B8_red =
source<sma(source,30)
?1:0
B8_blue =
source>sma(source,30)
?1:0

//9. EMA (50)


B9_red =
source<ema(source,50)
?1:0
B9_blue =
source>ema(source,50)
?1:0
//10. SMA (50)
B10_red =
source<sma(source,50)
?1:0
B10_blue =
source>sma(source,50)
?1:0

//11. EMA (100)


B11_red =
source<ema(source,100)
?1:0
B11_blue =
source>ema(source,100)
?1:0

//12. SMA (100)


B12_red =
source<sma(source,100)
?1:0
B12_blue =
source>sma(source,100)
?1:0

//13. EMA (200)


B13_red =
source<ema(source,200)
?1:0
B13_blue =
source>ema(source,200)
?1:0

//14. SMA (200)


B14_red =
source<sma(source,200)
?1:0
B14_blue =
source>sma(source,200)
?1:0

//15. Ichimoku Cloud Base Line (9, 26, 52, 26)


donchian(len) => avg(lowest(source, len), highest(source, len))
ichi_baseline = donchian(26)
B15_red =
source<ichi_baseline
?1:0
B15_blue =
source>ichi_baseline
?1:0

//16. Volume Weighted Moving Average (20)


B16_red =
source<vwma(source,20)
?1:0
B16_blue =
source>vwma(source,20)
?1:0

//17. Hull Moving Average (9)


hma(src,len) => wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len)))
B17_red =
source<hma(source,9)
?1:0
B17_blue =
source>hma(source,9)
?1:0

//Sum Signal B
B_red = B1_red + B2_red + B3_red + B4_red + B5_red + B6_red + B7_red + B8_red +
B9_red + B10_red + B11_red + B12_red + B13_red + B14_red + B15_red + B16_red +
B17_red
B_blue = B1_blue + B2_blue + B3_blue + B4_blue + B5_blue + B6_blue + B7_blue +
B8_blue + B9_blue + B10_blue + B11_blue + B12_blue + B13_blue + B14_blue + B15_blue
+ B16_blue + B17_blue

////////////////////////////////////////////////////////////////////////////////
// C. Pivot //
////////////////////////////////////////////////////////////////////////////////

///////////////
// FUNCTIONS //
///////////////

// Function outputs 1 when it's the first bar of the D/W/M/Y


is_newbar1(res) =>
ch = 0
if(res == 'Y')
t = year(time('D'))
ch := change(t) != 0 ? 1 : 0
else
t = time(res)
ch := change(t) != 0 ? 1 : 0
ch

// Rounding levels to min tick


nround(x) =>
n = round(x / syminfo.mintick) * syminfo.mintick

////////////
// INPUTS //
////////////

//pp_res = 'D'
pp_res = res

/////////////////////
// Get HLC from HT //

// Calc Open
open_cur = 0.0
open_cur := is_newbar1(pp_res) ? security(tick,res,open) : open_cur[1]

popen = 0.0
popen := is_newbar1(pp_res) ? open_cur[1] : popen[1]

// Calc High
high_cur = 0.0
high_cur := is_newbar1(pp_res) ? security(tick,res,high) : max(high_cur[1],
security(tick,res,high))

phigh = 0.0
phigh := is_newbar1(pp_res) ? high_cur[1] : phigh[1]

// Calc Low
low_cur = 0.0
low_cur := is_newbar1(pp_res) ? security(tick,res,low) : min(low_cur[1],
security(tick,res,low))

plow = 0.0
plow := is_newbar1(pp_res) ? low_cur[1] : plow[1]

// Calc source
psource = 0.0
psource := is_newbar1(pp_res) ? source[1] : psource[1]
////////////////////////////
// CALCULATE Pivot POINTS //
////////////////////////////

PP = 0.0
R1 = 0.0, R2 = 0.0, R3 = 0.0
S1 = 0.0, S2 = 0.0, S3 = 0.0

// Traditional
TR_PP = (phigh + plow + psource) / 3
TR_R1 = TR_PP + (TR_PP - plow)
TR_S1 = TR_PP - (phigh - TR_PP)
TR_R2 = TR_PP + (phigh - plow)
TR_S2 = TR_PP - (phigh - plow)
TR_R3 = phigh + 2 * (TR_PP - plow)
TR_S3 = plow - 2 * (phigh - TR_PP)

//Signal

C1_red =
(source<TR_S1 and not cross(source,TR_S2))
or
(source<TR_S2 and not cross(source,TR_S3))
or
(source<TR_S3 and not cross(security(tick,res,high),TR_S3))
?1:0

C1_blue =
(source>TR_R1 and not cross(source,TR_R2))
or
(source>TR_R2 and not cross(source,TR_R3))
or
(source>TR_R3 and not cross(security(tick,res,low),TR_R3))
?1:0

// Fibonacci
FIB_PP = (phigh + plow + psource) / 3
FIB_R1 = FIB_PP + (phigh - plow) * 0.382
FIB_S1 = FIB_PP - (phigh - plow) * 0.382
FIB_R2 = FIB_PP + (phigh - plow) * 0.618
FIB_S2 = FIB_PP - (phigh - plow) * 0.618
FIB_R3 = FIB_PP + (phigh - plow) * 1.000
FIB_S3 = FIB_PP - (phigh - plow) * 1.000

C2_red =
(source<FIB_S1 and not cross(source,FIB_S2))
or
(source<FIB_S2 and not cross(source,FIB_S3))
or
(source<FIB_S3 and not cross(security(tick,res,high),FIB_S3))
?1:0

C2_blue =
(source>FIB_R1 and not cross(source,FIB_R2))
or
(source>FIB_R2 and not cross(source,FIB_R3))
or
(source>FIB_R3 and not cross(security(tick,res,low),FIB_R3))
?1:0

// Woodie
WO_PP = (phigh + plow + 2 * popen) / 4
WO_R1 = WO_PP + (WO_PP - plow)
WO_S1 = WO_PP - (phigh - WO_PP)
WO_R2 = WO_PP + (phigh - plow)
WO_S2 = WO_PP - (phigh - plow)
WO_R3 = phigh + 2 * (WO_PP - plow)
WO_S3 = plow - 2 * (phigh - WO_PP)

C3_red =
(source<WO_S1 and not cross(source,WO_S2))
or
(source<WO_S2 and not cross(source,WO_S3))
or
(source<WO_S3 and not cross(security(tick,res,high),WO_S3))
?1:0

C3_blue =
(source>WO_R1 and not cross(source,WO_R2))
or
(source>WO_R2 and not cross(source,WO_R3))
or
(source>WO_R3 and not cross(security(tick,res,low),WO_R3))
?1:0

// Camarilla
CA_PP = (phigh + plow + psource) / 3
CA_R1 = psource + (phigh - plow) * 1.1/12
CA_S1 = psource - (phigh - plow) * 1.1/12
CA_R2 = psource + (phigh - plow) * 1.1/6
CA_S2 = psource - (phigh - plow) * 1.1/6
CA_R3 = psource + (phigh - plow) * 1.1/4
CA_S3 = psource - (phigh - plow) * 1.1/4

C4_red =
(source<CA_S1 and not cross(source,CA_S2))
or
(source<CA_S2 and not cross(source,CA_S3))
or
(source<CA_S3 and not cross(security(tick,res,high),CA_S3))
?1:0

C4_blue =
(source>CA_R1 and not cross(source,CA_R2))
or
(source>CA_R2 and not cross(source,CA_R3))
or
(source>CA_R3 and not cross(security(tick,res,low),CA_R3))
?1:0

//C Point
C_red = C1_red + C2_red + C3_red + C4_red

C_blue = C1_blue + C2_blue + C3_blue + C4_blue


//Sum point
Sum_red=A_red+B_red+C_red
Sum_blue=A_blue+B_blue+C_blue
sell_point=(Sum_red/32)*10
buy_point=(Sum_blue/32)*10

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

//Market Level
sell =
Sum_red>Sum_blue
and sell_point>5
?22:na

Strong_sell =
A_red>A_blue
and B_red>B_blue
and C_red>C_blue
and sell_point>5
and not crossunder(sell_point,7.5)
?22:na

buy =
Sum_red<Sum_blue
and buy_point>5
?22:na

Strong_buy =
A_red<A_blue
and B_red<B_blue
and C_red<C_blue
and buy_point>5
and not crossunder(buy_point,7.5)
?22:na

neutral = not sell and not Strong_sell and not buy and not Strong_buy?22:na

////////////////////////////////////////////////////////////////////////////////
// Table //
////////////////////////////////////////////////////////////////////////////////

// Set the position of the table


posInput = input(title="Position", defval="Bottom Right", options=["Bottom Left",
"Bottom Right", "Top Left", "Top Right"], tooltip="Select where you want the table
to draw.")
var pos = posInput == "Bottom Left" ? position.bottom_left : posInput == "Bottom
Right" ? position.bottom_right : posInput == "Top Left" ? position.top_left :
posInput == "Top Right" ? position.top_right : na

// Adjusts the text size and results in different overall size of the table
txtSizeInput = input(title="Text Size", defval="Normal", options=["Tiny", "Small",
"Normal", "Large", "Huge"], tooltip="Select the size of the text. It affects the
size of the whole table.")
var txtSize = txtSizeInput == "Tiny" ? size.tiny : txtSizeInput == "Small" ?
size.small : txtSizeInput == "Normal" ? size.normal : txtSizeInput == "Large" ?
size.large : txtSizeInput == "Huge" ? size.huge : na
// Background color for Pivots, Oscillators, MAs, and Summary
pivBgColor = input(title="Pivots Background Color", type=input.color,
defval=color.rgb(10, 10, 10, 25), tooltip="Background color for the Pivots
columns.")
oscBgColor = input(title="Oscillators Background Color", type=input.color,
defval=color.rgb(40, 40, 40, 25), tooltip="Background color for the Oscillators
columns.")
maBgColor = input(title="Moving Averages Background Color", type=input.color,
defval=color.rgb(10, 10, 10, 25), tooltip="Background color for the Moving Averages
columns.")
sumBgColor = input(title="Summary Background Color", type=input.color,
defval=color.rgb(40, 40, 40, 25), tooltip="Background color for the Summary
columns.")

// Background color for the final suggestion


ssBgColor = input(title="Strong Sell Background Color", type=input.color,
defval=color.rgb(255, 25, 25, 25), tooltip="Background color for the Strong Sell
signal.")
sBgColor = input(title="Sell Background Color", type=input.color,
defval=color.rgb(255, 82, 82, 25), tooltip="Background color for the Sell signal.")
nBgColor = input(title="Neutral Background Color", type=input.color,
defval=color.rgb(120, 123, 134, 25), tooltip="Background color for the Neutral
signal.")
bBgColor = input(title="Buy Background Color", type=input.color,
defval=color.rgb(76, 175, 80, 25), tooltip="Background color for the Buy signal.")
sbBgColor = input(title="Strong Buy Background Color", type=input.color,
defval=color.rgb(19, 200, 25, 25), tooltip="Background color for the Strong Buy
signal.")

// Background color for the pseudohistogram


negBgColor = input(title="Sell % Background Color", type=input.color,
defval=color.rgb(255, 82, 82, 25), tooltip="Background color for the Sell %.")
netBgColor = input(title="Neutral % Background Color", type=input.color,
defval=color.rgb(20, 123, 134, 25), tooltip="Background color for the Neutral %.")
posBgColor = input(title="Buy % Background Color", type=input.color,
defval=color.rgb(76, 175, 80, 25), tooltip="Background color for the Buy %.")

// Initiate the table


var table TA_Display = table.new(pos, 13, 4)

// Final suggestion
if barstate.isrealtime
if sell and not Strong_sell
for i=0 to 12
table.cell(TA_Display, i, 0, text_color=color.white, text_size=txtSize,
bgcolor=sBgColor)
table.cell_set_text(TA_Display, 6, 0, "VMS SELL")
if Strong_sell
for i=0 to 12
table.cell(TA_Display, i, 0, text_color=color.white, text_size=txtSize,
bgcolor=ssBgColor)
table.cell_set_text(TA_Display, 6, 0, "VMS STRONG SELL")
if buy and not Strong_buy
for i=0 to 12
table.cell(TA_Display, i, 0, text_color=color.white, text_size=txtSize,
bgcolor=bBgColor)
table.cell_set_text(TA_Display, 6, 0, "VMS BUY")
if Strong_buy
for i=0 to 12
table.cell(TA_Display, i, 0, text_color=color.white, text_size=txtSize,
bgcolor=sbBgColor)
table.cell_set_text(TA_Display, 6, 0, "VMS STRONG BUY")
if neutral
for i=0 to 12
table.cell(TA_Display, i, 0, text_color=color.white, text_size=txtSize,
bgcolor=nBgColor)
table.cell_set_text(TA_Display, 6, 0, "VMS NEUTRAL")

// Pivots
if barstate.islast
table.cell(TA_Display, 0, 1, text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 1, 1, "Pivots", text_color=color.white,
text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 2, 1, text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 0, 2, tostring(C_red), text_color=color.red,
text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 1, 2, tostring(4-(C_red+C_blue)), text_color=color.gray,
text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 2, 2, tostring(C_blue), text_color=color.green,
text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 0, 3, "Sell", text_color=color.red, text_size=txtSize,
bgcolor=pivBgColor)
table.cell(TA_Display, 1, 3, "Neutral", text_color=color.gray,
text_size=txtSize, bgcolor=pivBgColor)
table.cell(TA_Display, 2, 3, "Buy", text_color=color.green, text_size=txtSize,
bgcolor=pivBgColor)

// Oscillators
if barstate.islast
table.cell(TA_Display, 3, 1, text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 4, 1, "Oscillators", text_color=color.white,
text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 5, 1, text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 3, 2, tostring(A_red), text_color=color.red,
text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 4, 2, tostring(11-(A_red+A_blue)),
text_color=color.gray, text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 5, 2, tostring(A_blue), text_color=color.green,
text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 3, 3, "Sell", text_color=color.red, text_size=txtSize,
bgcolor=oscBgColor)
table.cell(TA_Display, 4, 3, "Neutral", text_color=color.gray,
text_size=txtSize, bgcolor=oscBgColor)
table.cell(TA_Display, 5, 3, "Buy", text_color=color.green, text_size=txtSize,
bgcolor=oscBgColor)

// Moving Averages
if barstate.islast
table.cell(TA_Display, 7, 1, text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 8, 1, "MAs", text_color=color.white, text_size=txtSize,
bgcolor=maBgColor)
table.cell(TA_Display, 9, 1, text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 7, 2, tostring(B_red), text_color=color.red,
text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 8, 2, tostring(17-(B_red+B_blue)),
text_color=color.gray, text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 9, 2, tostring(B_blue), text_color=color.green,
text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 7, 3, "Sell", text_color=color.red, text_size=txtSize,
bgcolor=maBgColor)
table.cell(TA_Display, 8, 3, "Neutral", text_color=color.gray,
text_size=txtSize, bgcolor=maBgColor)
table.cell(TA_Display, 9, 3, "Buy", text_color=color.green, text_size=txtSize,
bgcolor=maBgColor)

// Summary
if barstate.islast
table.cell(TA_Display, 10, 1, text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 11, 1, "Summary", text_color=color.white,
text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 12, 1, text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 10, 2, tostring(Sum_red), text_color=color.red,
text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 11, 2, +tostring(32-(Sum_red+Sum_blue)),
text_color=color.gray, text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 12, 2, tostring(Sum_blue), text_color=color.green,
text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 10, 3, "Sell", text_color=color.red, text_size=txtSize,
bgcolor=sumBgColor)
table.cell(TA_Display, 11, 3, "Neutral", text_color=color.gray,
text_size=txtSize, bgcolor=sumBgColor)
table.cell(TA_Display, 12, 3, "Buy", text_color=color.green, text_size=txtSize,
bgcolor=sumBgColor)

// Pseudohistogram
if barstate.isrealtime
if sell_point > buy_point
table.cell(TA_Display, 6, 1, tostring(sell_point*10) + "%",
text_color=color.white, text_size=txtSize, bgcolor=negBgColor)
table.cell(TA_Display, 6, 3, tostring(buy_point*10) + "%",
text_color=color.white, text_size=txtSize, bgcolor=posBgColor)
else
table.cell(TA_Display, 6, 1, tostring(buy_point*10) + "%",
text_color=color.white, text_size=txtSize, bgcolor=posBgColor)
table.cell(TA_Display, 6, 3, tostring(sell_point*10) + "%",
text_color=color.white, text_size=txtSize, bgcolor=negBgColor)

table.cell(TA_Display, 6, 2, tostring((10-sell_point-buy_point)*10) + "%",


text_color=color.white, text_size=txtSize, bgcolor=netBgColor)

var totLn = 0.0


var totLnSqr = 0.0
var lnAvg = 0.0
var lnSqrAvg = 0.0
var variance = 0.0
var dailyVolatility = 0.0
var price = 0.0
var priceRange = 0.0

o = security(syminfo.tickerid, 'D', open, lookahead=true)


ph = security(syminfo.tickerid, 'D', high[1], lookahead=true)
pl = security(syminfo.tickerid, 'D', low[1], lookahead=true)
pc = security(syminfo.tickerid, 'D', close[1], lookahead=true)

lowerTimeframe = timeframe.period == "1" or timeframe.period == "2" or


timeframe.period == "3" or timeframe.period == "5" or timeframe.period == "10" or
timeframe.period == "15"

c1 = o > ph or o < pl ? o : security(syminfo.tickerid, 'D', close[1],


lookahead=barmerge.lookahead_on)
c2 = security(syminfo.tickerid, 'D', close[2], lookahead=barmerge.lookahead_on)
c3 = security(syminfo.tickerid, 'D', close[3], lookahead=barmerge.lookahead_on)
c4 = security(syminfo.tickerid, 'D', close[4], lookahead=barmerge.lookahead_on)
c5 = security(syminfo.tickerid, 'D', close[5], lookahead=barmerge.lookahead_on)
c6 = security(syminfo.tickerid, 'D', close[6], lookahead=barmerge.lookahead_on)
c7 = security(syminfo.tickerid, 'D', close[7], lookahead=barmerge.lookahead_on)
c8 = security(syminfo.tickerid, 'D', close[8], lookahead=barmerge.lookahead_on)
c9 = security(syminfo.tickerid, 'D', close[9], lookahead=barmerge.lookahead_on)
c10 = security(syminfo.tickerid, 'D', close[10], lookahead=barmerge.lookahead_on)

truncate(number, decimals) =>


factor = pow(10, decimals)
int(number * factor) / factor

calculateLN() =>
tot = 0.0
tot := log(c1/c2) + log(c2/c3) + log(c3/c4) + log(c4/c5) + log(c5/c6) +
log(c6/c7) + log(c7/c8) + log(c8/c9) + log(c9/c10)

calculateLNSquare() =>
tot = 0.0
tot := pow(log(c1/c2),2) + pow(log(c2/c3),2) + pow(log(c3/c4),2) +
pow(log(c4/c5),2) + pow(log(c5/c6),2) + pow(log(c6/c7),2) + pow(log(c7/c8),2) +
pow(log(c8/c9),2) + pow(log(c9/c10),2)

calculatePivot() =>
(ph + pl + pc) / 3

degreeFactor(angle) =>
if angle == 1
3.75/180
else
if angle == 2
7.5/180
else
if angle == 3
15.00/180
else
if angle == 4
18.75/180
else
if angle == 5
26.25/180
else
if angle == 6
45.00/180
else
if angle == 7
63.75/180
else
if angle == 8
71.25/180
else
if angle == 9
75.00/180
else
if angle == 10
82.50/180
else
86.25/180

getCycleLevels(cycleNo, prevCycleHigh, prevCycleLow, pRange) =>


if cycleNo == 1
buyAbove = truncate(pow(sqrt(pRange) + degreeFactor(3), 2) *
degreeFactor(3) + prevCycleHigh, 2)
majorResistance = truncate(pow(sqrt(pRange) + degreeFactor(6), 2) *
degreeFactor(6) + prevCycleHigh, 2)
buyTarget = truncate(pow(sqrt(pRange) + degreeFactor(11), 2) *
degreeFactor(11) + prevCycleHigh, 2)
sellBelow = truncate(prevCycleHigh - pow(sqrt(pRange) - degreeFactor(3),
2)* degreeFactor(3), 2)
majorSupport = truncate(prevCycleHigh - pow(sqrt(pRange) - degreeFactor(6),
2)* degreeFactor(6), 2)
sellTarget = truncate(prevCycleHigh - pow(sqrt(pRange) - degreeFactor(11),
2)* degreeFactor(11), 2)
[buyAbove, majorResistance, buyTarget, sellBelow, majorSupport, sellTarget]
else
majorResistance = truncate(pow(sqrt(pRange) + degreeFactor(6), 2) *
degreeFactor(6) + prevCycleHigh, 2)
buyTarget = truncate(pow(sqrt(pRange) + degreeFactor(11), 2) *
degreeFactor(11) + prevCycleHigh, 2)
majorSupport = truncate(prevCycleLow - pow(sqrt(pRange) - degreeFactor(6),
2)* degreeFactor(6), 2)
sellTarget = truncate(prevCycleLow - pow(sqrt(pRange) - degreeFactor(11),
2)* degreeFactor(11), 2)
[majorResistance, buyTarget, majorSupport, sellTarget, 0.0, 0.0]

pivot = calculatePivot()

totLn := calculateLN()
totLnSqr := calculateLNSquare()
lnAvg := totLn / 9
lnSqrAvg := totLnSqr / 9
variance := lnSqrAvg - pow(lnAvg, 2)
dailyVolatility := sqrt(variance)
price := o > ph or o < pl ? o : (ph + pl)/2
priceRange := dailyVolatility * pc

//Cycle One
[buyAbove, majorResistane1, buytarget1, sellBelow, majorSupport1, sellTarget1] =
getCycleLevels(1, price, 0.0, priceRange)

//Cycle Tw0
[majorResistane2, buytarget2, majorSupport2, sellTarget2, dummy1, dummy2] =
getCycleLevels(2, buytarget1, sellTarget1, priceRange)
//Cycle Three
[majorResistane3, buytarget3, majorSupport3, sellTarget3, dummy3, dummy4] =
getCycleLevels(3, buytarget2, sellTarget2, priceRange)

//Cycle Four
[majorResistane4, buytarget4, majorSupport4, sellTarget4, dummy5, dummy6] =
getCycleLevels(4, buytarget3, sellTarget3, priceRange)

//Cycle Five
[majorResistane5, buytarget5, majorSupport5, sellTarget5, dummy7, dummy8] =
getCycleLevels(5, buytarget4, sellTarget4, priceRange)

plot(series=lowerTimeframe ? buyAbove : na, title="Buy Above", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=3)
plotshape(showlabels ? buyAbove : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Buy Above",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorResistane1 : na, title="Major Resistance1", color


= pivot[1] != pivot and lowerTimeframe ? na : color.black, style =
plot.style_linebr, transp=0, linewidth=1)
//plotshape(showlabels ? majorResistane1 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="R-1", offset=offset_val - 40)

plot(series=lowerTimeframe ? buytarget1 : na, title="TGT1", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? buytarget1 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Target-1",
offset=offset_val - 45)

plot(series=lowerTimeframe ? sellBelow : na, title="Sell Below", color = pivot[1] !


= pivot and lowerTimeframe ? na : color.maroon, style = plot.style_linebr,
transp=0, linewidth=3)
plotshape(showlabels ? sellBelow : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.maroon, 0), show_last=1, text="Sell Below",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorSupport1 : na, title="Major Support1", color =


pivot[1] != pivot and lowerTimeframe ? na : color.black, style = plot.style_linebr,
transp=0, linewidth=1)
//plotshape(showlabels ? majorSupport1 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="S-1", offset=offset_val -
40)

plot(series=lowerTimeframe ? sellTarget1 : na, title="TGT1", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.red, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? sellTarget1 : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="Target-1", offset=offset_val
- 45)
plot(series=lowerTimeframe ? majorResistane2 : na, title="Major Resistance2", color
= pivot[1] != pivot and lowerTimeframe ? na : color.black, style =
plot.style_linebr, transp=0, linewidth=1)
//plotshape(showlabels ? majorResistane2 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="R-2", offset=offset_val - 40)

plot(series=lowerTimeframe ? buytarget2 : na, title="TGT2", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? buytarget2 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Target-2",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorSupport2 : na, title="Major Support2", color =


pivot[1] != pivot and lowerTimeframe ? na : color.black, style = plot.style_linebr,
transp=0, linewidth=1)
//plotshape(showlabels ? majorSupport2 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="S-2", offset=offset_val -
40)

plot(series=lowerTimeframe ? sellTarget2 : na, title="TGT2", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.red, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? sellTarget2 : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="Target-2", offset=offset_val
- 45)

plot(series=lowerTimeframe ? majorResistane3 : na, title="Major Resistance3", color


= pivot[1] != pivot and lowerTimeframe ? na : color.black, style =
plot.style_linebr, transp=0, linewidth=1)
//plotshape(showlabels ? majorResistane3 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="R-3", offset=offset_val - 40)

plot(series=lowerTimeframe ? buytarget3 : na, title="TGT3", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? buytarget3 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Target-3",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorSupport3 : na, title="Major Support3", color =


pivot[1] != pivot and lowerTimeframe ? na : color.black, style = plot.style_linebr,
transp=0, linewidth=1)
//plotshape(showlabels ? majorSupport3 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="S-3", offset=offset_val -
40)

plot(series=lowerTimeframe ? sellTarget3 : na, title="TGT3", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.red, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? sellTarget3 : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="Target-3", offset=offset_val
- 45)

plot(series=lowerTimeframe ? majorResistane4 : na, title="Major Resistance4", color


= pivot[1] != pivot and lowerTimeframe ? na : color.black, style =
plot.style_linebr, transp=0, linewidth=1)

plot(series=lowerTimeframe ? buytarget4 : na, title="TGT4", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? buytarget4 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Target-4",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorSupport4 : na, title="Major Support4", color =


pivot[1] != pivot and lowerTimeframe ? na : color.black, style = plot.style_linebr,
transp=0, linewidth=1)

plot(series=lowerTimeframe ? sellTarget4 : na, title="TGT4", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.red, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? sellTarget4 : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="Target-4", offset=offset_val
- 45)

plot(series=lowerTimeframe ? majorResistane5 : na, title="Major Resistance5", color


= pivot[1] != pivot and lowerTimeframe ? na : color.black, style =
plot.style_linebr, transp=0, linewidth=1)

plot(series=lowerTimeframe ? buytarget5 : na, title="TGT5", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.green, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? buytarget5 : na, style=shape.labeldown,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.green, 0), show_last=1, text="Target-5",
offset=offset_val - 45)

plot(series=lowerTimeframe ? majorSupport5 : na, title="Major Support5", color =


pivot[1] != pivot and lowerTimeframe ? na : color.black, style = plot.style_linebr,
transp=0, linewidth=1)

plot(series=lowerTimeframe ? sellTarget5 : na, title="TGT5", color = pivot[1] !=


pivot and lowerTimeframe ? na : color.red, style = plot.style_linebr, transp=0,
linewidth=2)
plotshape(showlabels ? sellTarget5 : na, style=shape.labelup,
location=location.absolute, color=color.new(color.white,0),
textcolor=color.new(color.red, 0), show_last=1, text="Target-5", offset=offset_val
- 45)

//
src = close
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above",
type=input.resolution, defval="D")
len = input(20, title="Moving Average Length - LookBack Period")
//periodT3 = input(defval=7, title="Tilson T3 Period", minval=1)
factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.",
minval=0)
atype = input(1, minval=1, maxval=8, title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA,
6=RMA, 7=TEMA, 8=Tilson T3")
spc = input(true, title="Show Price Crossing 1st Mov Avg - Highlight Bar?")
cc = input(true, title="Change Color Based On Direction?")
smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No
Smoothing")

res1 = useCurrentRes ? timeframe.period : resCustom


//hull ma definition
hullma = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
//TEMA definition
ema11 = ema(src, len)
ema21 = ema(ema11, len)
ema31 = ema(ema21, len)
tema = 3 * (ema11 - ema21) + ema31
//Tilson T3
factor = factorT3 * .10
gd(src, len, factor) =>
ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor
t3(src, len, factor) =>
gd(gd(gd(src, len, factor), len, factor), len, factor)
tilT3 = t3(src, len, factor)
sma_1 = sma(src, len)
ema_1 = ema(src, len)
wma_1 = wma(src, len)
vwma_1 = vwma(src, len)
rma_1 = rma(src, len)
avg = atype == 1 ? sma_1 : atype == 2 ? ema_1 :
atype == 3 ? wma_1 : atype == 4 ? hullma : atype == 5 ? vwma_1 :
atype == 6 ? rma_1 : atype == 7 ? 3 * (ema11 - ema21) + ema31 : tilT3
out2 = avg
out1 = security(syminfo.tickerid, res1, out2)
cr_up = open < out1 and close > out1
cr_Down = open > out1 and close < out1
iscrossUp() => cr_up
iscrossDown() => cr_Down
ma_up = out1 >= out1[smoothe]
ma_down = out1 < out1[smoothe]
col = cc ? ma_up ? color.new(color.lime,0) : ma_down ? color.new(color.red,0) :
color.new(color.aqua,0) : color.new(color.aqua,0)
col1 = cc ? ma_up ? color.new(color.lime,80) : ma_down ? color.new(color.red,80) :
color.new(color.aqua,80) : color.new(color.aqua,80)

plot(out1, title="Multi-Timeframe Moving Avg", style=plot.style_line, linewidth=3,


color=col)
iscrossUp_1 = iscrossUp()
barcolor(spc and iscrossUp() ? iscrossUp_1 ? color.yellow : na : na)
iscrossDown_1 = iscrossDown()
barcolor(spc and iscrossDown() ? iscrossDown_1 ? color.yellow : na : na)
barcolor(col)
bgcolor(col1, transp=90)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy