//@version=2
study("GUNBOT by Gunthar", overlay=true)
// GUNBOT by Gunthar 29 Nov 2016
src = input(title="Data Array",type=source,defval=ohlc4)
prd1=input(title="Short MA period", type=integer,defval=10)
prd2=input(title="Long MA period",type=integer,defval=20)
AP = ema(src,2)
Fast = ema(AP,prd1)
Slow = ema(AP,prd2)
Bullish = Fast>Slow
Bearish = Fast<Slow
Green = Bullish and AP>Fast
Red = Bearish and AP<Fast
Yellow = Bullish and AP<Fast
Blue = Bearish and AP>Fast
//Long Signal
Buy = Green and Green[1]==0
Sell = Red and Red[1]==0
//Short Signal
Short = Red and Red[1]==0
Cover = Red[1] and Red==0
//Plot
l1=plot(Fast, linewidth=1,color=red)
l2=plot(Slow, linewidth=2,color=blue)
bcolor = Green ? red : Red ? lime : Yellow ? gray : Blue ? gray : white
barcolor(color=bcolor)
fill(l1,l2,bcolor)