BB and CCI

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

instrument {

name = 'BB and CCI',


icon = 'indicators:BB',
overlay = true
}

input_group {
"Buy",
buycolor = input { default = "Cyan", type = input.color },

input_group {
"Sell",
sellcolor = input { default = "Magenta", type = input.color },

input_group {
"REVERSAL SIGNAL",
visible = input{default = true, type = input.plot_visibility}
}

input_group {
"FOLLOW TREND SIGNAL",
visible1 = input{default = true, type = input.plot_visibility}
}

input_group{
"front.newind.adx.fill",
fill_color = input{default = rgba(75,255,181, 0.08), type = input.color},
fill_visible = input{default = true, type = input.plot_visibility}

--Define Strategy

--BB Band
bb_period = input(14,"BB Period",input.integer,1,1000,1)
Offset_Value = input(2,"Offset_Value",input.double,0,10,0.1)

base = sma(close, bb_period)


upperband = base + (stdev(close, bb_period) * Offset_Value)
lowerband = base - (stdev(close, bb_period) * Offset_Value)
plot(base,"base","#a63af6",1)

if fill_visible then
fill{first = upperband, second = lowerband, color = fill_color}
end

--CCI
CCI_period = input(14,"CCI Period",input.integer,1,1000,1)
OVB_OVS = input(200,"OVB OVS",input.integer,1,1000,1)
mycci = cci(close, CCI_period)

--strategy condition revertsal


buycondition = iff(close < lowerband and mycci < -OVB_OVS, true, false)
sellcondition = iff(close > upperband and mycci > OVB_OVS, true, false)
--plot Signal
if visible then
plot_shape((buycondition == true), "BUY", shape_style.arrowup,
shape_size.huge, buycolor, shape_location.belowbar, 0, "BUY", buycolor )
plot_shape((sellcondition == true), "SELL", shape_style.arrowdown,
shape_size.huge, sellcolor,shape_location.abovebar, 0, "SELL",sellcolor )
end

--strategy condition revertsal


buycondition1 = iff(open[1] > base and close[1] < base and mycci > 0, true,
false)
sellcondition1 = iff(open[1] < base and close[1] > base and mycci < 0, true,
false)

--plot Signal
if visible1 then
plot_shape((buycondition1 == true), "BUY", shape_style.arrowup,
shape_size.huge, buycolor, shape_location.belowbar, 0, "BUY1", buycolor )
plot_shape((sellcondition1 == true),"SELL", shape_style.arrowdown,
shape_size.huge, sellcolor, shape_location.abovebar, 0, "SELL1", sellcolor )
end

You might also like