You are on page 1of 4

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

0 at
https://mozilla.org/MPL/2.0/
// @ifahsmiler

//@version=4
study("Super Combo",overlay=true)
RedGan=input(title="On/Off Red line", type=input.bool, defval=true)
BlueGan=input(title="On/Off Blue line", type=input.bool, defval=true)
labelOn=input(title="On/Off Label ", type=input.bool, defval=true)
LabelColor=input(title="Label color", type=input.color,defval=color.black)
Extend=input(title="Extend line", type=input.bool, defval=true)
PriceLevel=input(title="Price Level", defval=3, options=[3, 5])

var label rl1 = na


var label rl2 = na
var label sl1 = na
var label bl1 = na
var label bl2 = na
label.delete(rl1)
label.delete(rl2)
label.delete(sl1)
label.delete(bl1)
label.delete(bl2)

drawLine(resistance,start,end,extend,linecolor) =>
gannLine=line.new(x1=start, y1=resistance, x2=end, y2=resistance)
line.set_color(gannLine, linecolor)
if extend
line.set_extend(id=gannLine, extend=extend.left)
gannLine

drawLabel(x,y,text) =>
GannLabel=label.new(x, y, text,xloc=xloc.bar_time,style=label.style_none)
GannLabel

max = 20
rangeMin = 0
var GannNum = array.new_float(0)
dt = time - time[1]
labelPosition = time + 3*dt

if barstate.islast
for min=rangeMin to max
for i=0 to 3
gNum=0
if min == rangeMin and i==0
gNum:=min + (min+2)
else if min > rangeMin and i ==0
gNum:=round(array.get(GannNum,array.size(GannNum)-1)) + (min+1) +
min
else
gNum:=round(array.get(GannNum,array.size(GannNum)-1)) + (min+2) +
min
array.push(GannNum,gNum)

maxItem=array.size(GannNum)-1
next=0
denomenator=0.0
if close[0] >= 10000
denomenator :=0.01
else if close[0] >= 1000
denomenator :=0.1
else if close[0] >= 100
denomenator :=1
else if close[0] >=10
denomenator :=10
else if close[0] >=0.05
denomenator :=100
else
denomenator :=1000

price=close[0]*denomenator
resistance=0.0
support=0.0
blueGannPrice1=0.0
GannPos=0
for i=0 to array.size(GannNum)-1
if i==maxItem
next:=i
else
next:=i+1

if array.get(GannNum,i) <= price and array.get(GannNum,next) > price


resistance:=array.get(GannNum,next)/denomenator
support:=array.get(GannNum,i)/denomenator
blueGannPrice1:=(support+resistance)/2
GannPos:=i
break

// label.new(bar_index, 0, "\nArrayWork = " + tostring(text), size = size.small)

//Print lines

startLine=bar_index[0]
endLine=bar_index[10]
GannWeightPosition = close[0] >= blueGannPrice1 ? 2 : -1

if RedGan
resistance1=drawLine(resistance,startLine,endLine,Extend,color.red)
support1=drawLine(support,startLine,endLine,Extend,color.red)
if labelOn
rl1:=drawLabel(labelPosition,resistance,"\R1 = " +
tostring(resistance))
label.set_textcolor(rl1,LabelColor)
sl1:=drawLabel(labelPosition,support,"\S1 = " + tostring(support))
label.set_textcolor(sl1,LabelColor)
if PriceLevel == 5

resistancePrice2=array.get(GannNum,GannPos+GannWeightPosition)/denomenator

resistance2=drawLine(resistancePrice2,startLine,endLine,Extend,color.red)
if labelOn
resistanceText2=GannWeightPosition > 0 ? "\R2 = " : "\S2 = "
rl2:=drawLabel(labelPosition,resistancePrice2,resistanceText2 +
tostring(resistancePrice2))
label.set_textcolor(rl2,LabelColor)
if BlueGan
blueGann1=drawLine(blueGannPrice1,startLine,endLine,Extend,color.blue)
if labelOn
BlueText1 = close[0] >= blueGannPrice1 ? "\S1 = " : "\R1 = "
bl1:=drawLabel(labelPosition,blueGannPrice1,BlueText1 +
tostring(blueGannPrice1))
label.set_textcolor(bl1,LabelColor)
if PriceLevel == 5
BlueGannPrice2 = GannWeightPosition > 0 ?
(array.get(GannNum,GannPos+1)+array.get(GannNum,GannPos+2))/2 :
(array.get(GannNum,GannPos-1)+array.get(GannNum,GannPos))/2
BlueGannPrice2 := BlueGannPrice2/denomenator
blueGann2=drawLine(BlueGannPrice2,startLine,endLine,Extend,color.blue)
if labelOn
BlueText2 = GannWeightPosition > 0 ? "\R1 = " : "\S1 = "
bl2:=drawLabel(labelPosition,BlueGannPrice2,BlueText2 +
tostring(BlueGannPrice2))
label.set_textcolor(bl2,LabelColor)

//inputs
_Period1 = input(2, "EMA2 Period")
_Period2 = input(5, "EMA5 Period")
_Period3 = input(7, "EMA7 Period")
_Period4 = input(20, "SMA20 Period")
_Period5 = input(50, "SMA50 Period")
_Period6 = input(200, "SMA200 Period")
_Period7 = input(20, "EMA20 Period")
_Period8 = input(34, "EMA34 Period")
_Period9 = input(50, "EMA50 Period")
_Period10 = input(90, "EMA90 Period")
_Period11 = input(200, "EMA200 Period")
length=input(9,"BB SMA")
src = input(close,"source")
mult = input(2.0, minval=0.001, maxval=50)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")

plot2 = plot(ema(close, 2), title="EMA2", color=#80c605)


plot5 = plot(ema(close, 5), title="EMA5", color=#fe9d19)
plot7 = plot(ema(close, 7), title="EMA7", color=#199dfe)
plot20 = plot(sma(close, 20), title="MA20", color=#000000)
plot50 = plot(sma(close, 50), title="MA50", color=#b919fe)
plot200 = plot(sma(close, 200), title="MA200", color=#fe7a19)
plote20 = plot(ema(close, 20), title="EMA20", color=#000000)
plot34 = plot(ema(close, 34), title="EMA34", color=#fe7a19)
plote50 = plot(ema(close, 50), title="EMA50", color=#b919fe)
plot90 = plot(ema(close, 90), title="EMA90", color=#60cc11)
plote200 = plot(ema(close, 200), title="EMA200", color=#fe7a19)

basis = sma(src,length)
dev = mult * stdev(src, length)
out = sar(start, increment, maximum)
plot(out, "ParabolicSAR", color=#3A6CA8)
uppr = basis + dev
lowr = basis - dev
conversionPeriods = input(9, minval=1, title="Conversion Line Length")
basePeriods = input(26, minval=1, title="Base Line Length")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Length")
displacement = input(26, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)

plot(conversionLine, color=#0496ff, title="Conversion Line")


plot(baseLine, color=#991515, title="Base Line")
plot(close, offset = -displacement + 1, color=#459915, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement - 1, color=#0496ff,
title="Lead 1")
p2 = plot(leadLine2, offset = displacement - 1, color=#991515,
title="Lead 2")
fill(p1, p2, color = leadLine1 > leadLine2 ? #0496ff :#991515)

BasisBB = plot(basis, title = "BasisBB",color=#0496ff)


UpperBB = plot(uppr, title = "UpperBB", color=#000000)
LowerBB = plot(lowr, title = "LowerBB", color=#000000)

g=bar_index==1
ath()=>
a=0.0
a:=g ? high : high>a[1] ? high:a[1]

a = security(syminfo.tickerid, 'M', ath(),lookahead=barmerge.lookahead_on)


plot(a, title='ATH',linewidth=2, trackprice=true, color=color.maroon, offset=-9999)

atl()=>
r=0.0
r:=g ? low : low<r[1] ? low:r[1]

r = security(syminfo.tickerid, 'M', atl(),lookahead=barmerge.lookahead_on)


plot(r, title='ATL',linewidth=2, trackprice=true, color=color.maroon, offset=-9999)

ftwh()=>
h= highest(high[1],52)

h = security(syminfo.tickerid, 'W', ftwh(),lookahead=barmerge.lookahead_on)


plot(h, title='52weekhigh',linewidth=2, trackprice=true, color=color.red, offset=-
9999)

ftwl()=>
l= lowest(low[1],52)

l = security(syminfo.tickerid, 'W', ftwl(),lookahead=barmerge.lookahead_on)


plot(l, title='52weeklow',linewidth=2, trackprice=true, color=color.red, offset=-
9999)

plot(h-h*25/100, title='52weekhigh 25% low',linewidth=2, trackprice=true,


color=color.lime, offset=-9999)
plot(l+l*30/100, title='52weeklow 30% high',linewidth=2, trackprice=true,
color=color.lime, offset=-9999)

You might also like