April 6, 2015

New types of “shape”: label up and label down

The function “plotshape” contains 12 styles now.

study('Labels plotshape example')
ma1 = ema(open, 6)
ma2 = ema(close, 100)
plot(ma1)
plot(ma2, color=gray)
isGoingUp = ma1[1] < ma2[1] and ma1 >= ma2
isGoingDown = ma1[1] > ma2[1] and ma1 <= ma2
plotshape(isGoingUp ? ma1 : na, color=lime, text="Ma1 Going Up", 
   textcolor=black,
   style=shape.labelup,
   location=location.absolute)
plotshape(isGoingDown ? ma1 : na, color=red, text="Ma1 Falling Down", 
   textcolor=white,
   style=shape.labeldown,
   location=location.absolute)
script
study('Labels plotshape example 2', overlay=true)
ma1 = ema(open, 6)
ma2 = ema(close, 100)
plot(ma1)
plot(ma2, color=gray)
	isUp = close >= open
plotshape(cross(ma1, ma2), color=isUp ? lime : red, text="Cross\nis here", 
   textcolor=isUp ? black : white,
   style=shape.labeldown,
   location=location.abovebar)

script2

You can read more about Pine Script Language in the Pine Script Tutorial and in the Pine Script Reference.