0% found this document useful (0 votes)
28 views4 pages

MATTool Script

The document is a TradingView script for a trading strategy called 'Trend Bull V2', which includes various indicators such as moving averages, VWAP, and support/resistance levels. It defines conditions for long and short trading signals based on price movements and technical indicators, and includes alert conditions for these signals. Additionally, it plots daily pivot points and previous day high/low values for further analysis.

Uploaded by

Atul
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)
28 views4 pages

MATTool Script

The document is a TradingView script for a trading strategy called 'Trend Bull V2', which includes various indicators such as moving averages, VWAP, and support/resistance levels. It defines conditions for long and short trading signals based on price movements and technical indicators, and includes alert conditions for these signals. Additionally, it plots daily pivot points and previous day high/low values for further analysis.

Uploaded by

Atul
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/ 4

// © Nick

//@version=4
study(title="Trend Bull V2", shorttitle="TBull", overlay=true)

SEMA = input(true, title="Moving Average")


showVWAP = input(title="Show VWAP", type=input.bool, defval=true)
SP = input(true, title="Prev D High & Low")
SPSR = input(true, title="Support & Resistance")
SST = input(true, title="Buy Sell Arrow")
SS = input(false, title="Show Supertrend")

// Long and Short Strategy

mult = input(title="Mult",type=input.float, defval=3)


len = input(title="Len",type=input.integer, defval=10)
[superTrend, dir] = supertrend(mult, len)
colResistance = dir == 1 and dir == dir[1] ? color.new(color.red, 0) :
color.new(color.red, 100)
colSupport = dir == -1 and dir == dir[1] ? color.new(color.green, 0) :
color.new(color.green, 100)
plot(SS and superTrend ? superTrend : na , title="SuperTrend",color =
colResistance, linewidth=2)
plot(SS and superTrend ? superTrend : na , title="SuperTrend",color = colSupport,
linewidth=2)

// Continuous BUY SELL Signal CONDITIONS

Long = close > ema(close,21) and close > ema(close,9) and rsi(close,14) > 55 and
close > vwap and dir == -1 and volume > sma(volume,300) and close > open
Short = close < ema(close,21) and close < ema(close,9) and rsi(close,14) < 45 and
close < vwap and dir == 1 and volume > sma(volume,300) and close < open

plotshape(SST and Long ? Long : na , title="Long Strategy", textcolor=color.white,


style=shape.triangleup, location=location.belowbar, color=color.green, transp=0,
size=size.small)
plotshape(SST and Short ? Short : na , title="Short Strategy",
textcolor=color.white, style=shape.triangledown, location=location.abovebar,
color=color.red, transp=0, size=size.small)

// ALERTS

alertcondition(Long, title="Long", message="Long")


alertcondition(Short, title="Short", message="Short")

//VWAP
cvwap1 = vwap(hlc3)
plotvwap = plot(showVWAP ? cvwap1 : na,title="VWAP",color=color.black,
transp=0, linewidth=2)

// Moving Averages

len1=input(9, title="EMA 1")


len2=input(21, title="EMA 2")
len3=input(50, title="EMA 3")
len4=input(200, title="EMA 4")

M1=ema(close, len1)
M2=ema(close, len2)
M3=ema(close, len3)
M4=ema(close, len4)

plot(SEMA and M1 ? M1 : na , title="EMA 9",color=#4caf50,transp=10, linewidth=2)


plot(SEMA and M2 ? M2 : na , title="EMA 20",color=#FF0800,transp=10, linewidth=2)
plot(SEMA and M3 ? M3 : na , title="EMA 50",color=#0000FF,transp=10,linewidth=2)
plot(SEMA and M4 ? M4 : na , title="EMA 200",color=#FFE135,transp=10, linewidth=2)

// Pivots Points

Pivot = (high + low + close) / 3.0


R1 = (2*Pivot) - low
S1 = (2*Pivot) - high
R2 = Pivot + ( high - low)
S2 = Pivot - ( high - low)
R3 = high + (2*(Pivot - low))
S3 = low - (2*(high - Pivot ))

DPP = security( syminfo.tickerid , 'D', Pivot[1], lookahead=barmerge.lookahead_on)


DR1= security( syminfo.tickerid , 'D', R1[1], lookahead=barmerge.lookahead_on)
DR2 = security( syminfo.tickerid , 'D', R2[1], lookahead=barmerge.lookahead_on)
DR3 = security( syminfo.tickerid , 'D', R3[1], lookahead=barmerge.lookahead_on)
DS1 = security( syminfo.tickerid , 'D', S1[1], lookahead=barmerge.lookahead_on)
DS2 = security( syminfo.tickerid , 'D', S2[1], lookahead=barmerge.lookahead_on)
DS3 = security( syminfo.tickerid , 'D', S3[1], lookahead=barmerge.lookahead_on)

plot(SPSR and DPP ? DPP : na , title= "Daily Pivot", color = #0000ff, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DR1 ? DR1 : na , title= "Daily R1", color = #ff0000, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DR2 ? DR2 : na , title= "Daily R2", color = #ff0000, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DR3 ? DR3 : na , title= "Daily R3", color = #ff0000, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DS1 ? DS1 : na , title= "Daily S1", color = #4caf50, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DS2 ? DS2 : na , title= "Daily S2", color = #4caf50, style =
plot.style_stepline, linewidth =2)
plot(SPSR and DS3 ? DS3 : na , title= "Daily S3", color = #4caf50, style =
plot.style_stepline, linewidth =2)

///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////
/////////////////////////////////////////////////// PREVIOUS
DAY /////////////////////////////////////////////////

prevDayHigh = security(syminfo.tickerid, 'D', high[1], lookahead=true)


prevDayLow = security(syminfo.tickerid, 'D', low[1], lookahead=true)
plot( SP and prevDayHigh ? prevDayHigh : na, title="Prev Day High",
style=plot.style_circles, linewidth=1, color=color.black, transp=0)
plot( SP and prevDayLow ? prevDayLow : na, title="Prev Day Low",
style=plot.style_circles, linewidth=1, color=color.black, transp=0)

//Continues Supertrend

CCI = input(10,title = "CCI")


ATR = input(1,title = "ATR")
Multiplier= 1
original = false
thisCCI = cci(close, CCI)
lastCCI = nz(thisCCI[1])

calcx()=>
bufferDn= high + Multiplier * wma(tr,ATR)
bufferUp= low - Multiplier * wma(tr,ATR)
if (thisCCI >= 0 and lastCCI < 0)
bufferUp := bufferDn[1]
if (thisCCI <= 0 and lastCCI > 0)
bufferDn := bufferUp[1]

if (thisCCI >= 0)
if (bufferUp < bufferUp[1])
bufferUp := bufferUp[1]
else
if (thisCCI <= 0)
if (bufferDn > bufferDn[1])
bufferDn := bufferDn[1]

x = 0.0
x := thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]
x

tempx = calcx()

calcswap() =>
swap = 0.0
swap := tempx>tempx[1]?1:tempx<tempx[1]?-1:swap[1]
swap

tempswap = calcswap()

swap2=tempswap==1?color.green:color.red
swap3=thisCCI >=0 ?color.green :color.red
swap4=original?swap3:swap2

//display Trend

plot( SST and tempx ? tempx : na , title = "ATR Line" ,color=swap4 == color.green ?
color.green : swap4,transp=0,linewidth=2)

plotshape( SST and swap4[1] == color.red and swap4 == color.green ? 1 : na , title


= "ATR Signal" , style = shape.triangleup , color = color.green , location =
location.belowbar , size = size.small )
plotshape( SST and swap4[1] == color.green and swap4 == color.red ? 1 : na , title
= "ATR Signal" , style = shape.triangledown , color = color.red , location =
location.abovebar , size = size.small)

You might also like