TradingView
MarcoValente
20 ตุลา 2016 เวลา 11 นาฬิกา 16 นาที

BB ATR Intraday strategy 

Crude Oil (WTI)FXCM

คำอธิบาย

This script is a better version of my old intraday strategy. Now can also have BB with ATR to control volatility, you can see on the chart Take Profit and Stop loss value, but you can adjust it as you like. It is good on Intraday Time frame from 5 to 60 . Better if use together with some trend indicator like ADX , because with no trend is not accurate
ความคิดเห็น
TheConcierge
Hi, could you possibly clarify which colored line represents what?

Thanks
MarcoValente
If you open data window on the right of your scrren you ll find a legend of lines and colors. But if you need to know more , please just ask
MarcoValente
//Created By Marco 20 10 2016
//@version=2
// Intraday
study(title="BB ATR Intraday ", shorttitle=" BB ATR Intra Strat", overlay=true)
src = close

bas=input(true,"Base use Filter or MA?(filter is default)")
bblenght = input(55, minval=1, title="Bollinger Bars Lenght")
bbstdev = input(0.3, minval=0.1,step=0.05, title="Bollinger Bars Standard Deviation")
yy=input(true,"Use ATR BB?")
lena=input(20,"ATR Length")
mult = input(0.6,"Mult ATR",step=0.1, minval=0.001, maxval=50)
qw=input(false,"Show Take Profit level?")
tp =input(2.0,defval=2.0,step=0.5,title ="percentuale take profitto")


//study("FILTER 1",overlay=true)
Price=hl2
gamma=input(.87,"Filter period",step=0.01)
L0 = (1 - gamma)*Price + gamma*nz(L0[1])
L1 = -gamma*L0 + L0[1] + gamma*nz(L1[1])
L2 = -gamma*L1 + L1[1] + gamma*nz(L2[1])
L3 = -gamma*L2 + L2[1] + gamma*nz(L3[1])
Filt = (L0 + 2*L1 + 2*L2 + L3) / 6

range =high - low
//
lh = high - low
pc = close[1]
hc = abs( high - pc )
lc = abs( low - pc )
MM = max( max( lh, hc ), lc )
atrs = iff( MM == hc, hc / ( pc + ( hc / 2 ) ),
iff( MM == lc, lc / ( low + ( lc / 2 ) ),
iff( MM == lh, lh / ( low + ( lh / 2 ) ), 0 ) ) )

APTR = atrs*(2/(lena+1))+nz(APTR[1])*(1-(2/(lena+1)))

bsma = sma(src, bblenght)
basis=bas?Filt:bsma
dev = mult * APTR
at=basis*dev
std = bbstdev * stdev(src, bblenght)
upperBB = basis +(yy?at:std)
lowerBB = basis -(yy?at:std)

midBB=(upperBB+lowerBB)/2
col=close>midBB?lime:red
//is over the top?
isOverBBTop =low and close > upperBB ? true : false
isUnderBBBottom = high and close< lowerBB? true : false
newisOverBBTop = isOverBBTop != isOverBBTop[1]
newisUnderBBBottom = isUnderBBBottom != isUnderBBBottom[1]
//receive high and low range
high_range = valuewhen(newisOverBBTop and close>high[3]and close>high[1],hl2,0)
low_range = valuewhen(newisUnderBBBottom and close<low[3] and close < low[1],hl2,0)

bblow = valuewhen(newisOverBBTop,(lowerBB/0.00005) * 0.00005,0)
bbhigh = valuewhen(newisUnderBBBottom,((upperBB*1000)/5)/ 200,0)

//take it only if over the BB limit
buy_limit_entry = isOverBBTop ? high_range==high_range[1] ? high_range+0.0001: na : na
sell_limit_entry = isUnderBBBottom ? low_range==low_range[1] ? low_range-0.0001: na : na

take_profit_buy= isOverBBTop ? high_range==high_range[1] ? buy_limit_entry + 1*(buy_limit_entry-bblow)+2*(abs(bbhigh-bblow)) : na : na
take_profit_sell= isUnderBBBottom ? low_range==low_range[1] ? sell_limit_entry - 1*(bbhigh-sell_limit_entry)-2*(abs(bbhigh-bblow)) : na : na

take_profit2_buy= isOverBBTop ? high_range==high_range[1] ? buy_limit_entry + 1*(buy_limit_entry-bblow)+2*(abs(bbhigh-bblow)) + buy_limit_entry*tp/100 : na : na
take_profit2_sell= isUnderBBBottom ? low_range==low_range[1] ? sell_limit_entry - 1*(bbhigh-sell_limit_entry)-2*(abs(bbhigh-bblow))-sell_limit_entry*tp/100 : na : na

stop_loss_buy = isOverBBTop ? high_range==high_range[1] ? bblow : na : na
stop_loss_sell = isUnderBBBottom ? low_range==low_range[1] ? bbhigh : na : na

highlightHigh = isOverBBTop ? lime : aqua
highlightLow = isUnderBBBottom ? lime : aqua

colorLineUp = buy_limit_entry ?green : green
colorLineDown = sell_limit_entry ? red : red

colorBuyTP = high>=take_profit_buy ? lime : blue
colorSellTP = low<=take_profit_sell ? orange : maroon
colorBuyTP2 = high>=take_profit2_buy ? green : navy
colorSellTP2 = low<=take_profit2_sell ? maroon : fuchsia

//plot Statements
bbup=plot(upperBB, title="BB Upper Band", style=linebr, linewidth=2, color=highlightHigh)
bbdo=plot(lowerBB, title="BB Bottom Band", style=linebr, linewidth=2, color=highlightLow)
plot( buy_limit_entry, title="Buy Entry", style=linebr, linewidth=2, color=colorLineUp, transp=40)
plot( sell_limit_entry, title="Short Entry", style=linebr, linewidth=2, color=colorLineDown, transp=40)
plot( stop_loss_buy, title="Buy Stop", style=cross, linewidth=1, color=black, transp=65)
plot( stop_loss_sell, title="Short Stop", style=cross, linewidth=1, color=black, transp=65)
plot(qw? take_profit_buy:na, title="Buy TP 1:1", style=circles, linewidth=2, color=colorBuyTP, transp=65)
plot(qw? take_profit_sell:na, title="Short TP 1:1", style=circles, linewidth=2, color=colorSellTP, transp=65)
plot( qw?take_profit2_buy:na, title="Buy TP2 1:2", style=circles, linewidth=2, color=colorBuyTP2, transp=70)
plot(qw? take_profit2_sell:na, title="Short TP2 1:2", style=circles, linewidth=2, color=colorSellTP2, transp=70)
fill(bbup, bbdo, color=col, transp=80)
//
compra= isOverBBTop ? high_range==high_range[1] ? high_range+0.0001: 1: 0
vendi = isUnderBBBottom ? low_range==low_range[1] ?low_range-0.0001: -1 :0
codiff = compra[1] ==1 ?1: 0
codiff2 = vendi[1] ==-1 ? -1 :0
plotarrow(codiff,colorup=green,title="Arrow Long entry",transp=40)
plotarrow(codiff2,colordown=orange,title="Arrow Short entry",transp=40)

MarcoValente
I plot it again try to copy this one . This version you can hide the profit line so the grafic looks more clear
geochristythomas1996
Jh
CEHido
Hi sir.
Sorry to bother you. I have a question. I really liked the indicator you wrote. However, since it is an old pine version, I may have problems in the future. Is there a new version of this available? Or can you help with the new pine version?

Thank you so much.

Sincerely...
ducip254
Hello! Does this repaint?
UnknownUnicorn2268682
Can you update this script to verrsion 4? Thanks
socialjks8
Really Great Indicator. Thanks. sir buy sell arrow too long. pls customise as triangle or dot...
ss1860
Thank you for your good job
เพิ่มเติม