You are on page 1of 2

//@version=4

strategy("indian trader V4.0",overlay=true)

res = input(title="Resolution", type=input.resolution, defval="240",confirm = true)

ProfitPerc = input(title=" Take Profit (%)",type=input.float, minval=0.0, step=0.1,


defval=1.4) * 0.01

stoploss = input(title=" Stop Loss (%)",type=input.float, minval=0.0, step=0.1, defval=0.7)


* 0.01

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

ATR = input(3,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]

tempx = calcx()

calcswap() =>

swap = 0.0

swap := tempx>tempx[1]?1:tempx<tempx[1]?-1:swap[1]

swap

tempswap = calcswap()

swap2=tempswap==1?color.yellow:color.blue

swap3=thisCCI >=0 ?color.yellow:color.blue

swap4=original?swap3:swap2

//display current timeframe's Trend

plot(tempx,color=swap4 == color.blue ? color.red : swap4,transp=0,linewidth=1)

htfx = security(syminfo.tickerid,res,tempx[1],lookahead = barmerge.lookahead_on)

htfswap4 = security(syminfo.tickerid,res,swap4[1],lookahead = barmerge.lookahead_on)

plot(htfx,color=htfswap4,transp=0,linewidth=3)

//plotarrow( ? 1 : swap4[1] == color.yellow and swap4 == color.blue ? -1 :0 , title="Up


Entry Arrow", colorup=color.green,colordown = color.blue, maxheight=10, minheight=10,
transp=0)

plotshape( swap4[1] == color.blue and swap4 == color.yellow ? 1 : na , text="Sell",


textcolor=color.white, style = shape.triangleup , color = color.green , location =
location.belowbar , size = size.tiny )

plotshape( swap4[1] == color.yellow and swap4 == color.blue ? 1 : na , text="Sell",


textcolor=color.white,style = shape.triangledown ,color = color.red , location =
location.abovebar , size = size.tiny)

buy = swap4[1] == color.blue and swap4 == color.yellow and htfswap4 == color.yellow

sell = swap4[1] == color.yellow and swap4 == color.blue and htfswap4 == color.blue

You might also like