MarcoValente

BB ATR Intraday strategy

1788 6 264
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
Rimuovi dagli script preferiti Aggiungi agli script preferiti
Hi, could you possibly clarify which colored line represents what?

Thanks
Rispondi
MarcoValente TheConcierge
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
+1 Rispondi
//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)
L1 = -gamma*L0 + L0 + gamma*nz(L1)
L2 = -gamma*L1 + L1 + gamma*nz(L2)
L3 = -gamma*L2 + L2 + gamma*nz(L3)
Filt = (L0 + 2*L1 + 2*L2 + L3) / 6

range =high - low
//
lh = high - low
pc = close
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-(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
newisUnderBBBottom = isUnderBBBottom != isUnderBBBottom
//receive high and low range
high_range = valuewhen(newisOverBBTop and close>highand close>high,hl2,0)
low_range = valuewhen(newisUnderBBBottom and close<low and close < low,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 ? high_range+0.0001: na : na
sell_limit_entry = isUnderBBBottom ? low_range==low_range ? low_range-0.0001: na : na

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

take_profit2_buy= isOverBBTop ? high_range==high_range ? 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 ? 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 ? bblow : na : na
stop_loss_sell = isUnderBBBottom ? low_range==low_range ? 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 ? high_range+0.0001: 1: 0
vendi = isUnderBBBottom ? low_range==low_range ?low_range-0.0001: -1 :0
codiff = compra ==1 ?1: 0
codiff2 = vendi ==-1 ? -1 :0
plotarrow(codiff,colorup=green,title="Arrow Long entry",transp=40)
plotarrow(codiff2,colordown=orange,title="Arrow Short entry",transp=40)

Rispondi
MarcoValente MarcoValente
I plot it again try to copy this one . This version you can hide the profit line so the grafic looks more clear
Rispondi
it told me script cant be translated from null , what does that mean ?
Rispondi
MarcoValente Kalghamdi12
Means that some lines are missing, but I just check it again and looks ok. Are you sure that you select all and make copy/paste ? Please try again
Rispondi
IT Italiano
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
HE עברית
Home Screener azioni Screener forex Screener cripto Calendario economico Come funziona Caratteristiche Grafico Regolamento Moderatori Soluzioni per broker & siti web Widget Libreria di Grafici azionari Suggerisci funzionalità Blog & Novità FAQ Aiuto & Wiki Twitter
Profilo Impostazioni profilo Account e fatturazione I miei ticket di supporto Contatta il supporto Idee pubblicate Follower Seguiti Messaggi Privati Chat Esci