问题描述
input length1 = 8;
input length2 = 21;
input length3 = 34;
input length4 = 55;
input length5 = 89;
input displace = 0;
def ema8 = ExpAverage(close,8);
def ema21 = ExpAverage(close,21);
def ema34 = ExpAverage(close,34);
def ema55 = ExpAverage(close,55);
def ema89 = ExpAverage(close,89);
def price = close;
plot EMA8_ = ExpAverage(close,8);
plot EMA21_ = ExpAverage(close,21);
plot EMA34_ = ExpAverage (close,34);
plot EMA55_ = ExpAverage (close,55);
plot EMA89_ = ExpAverage (close,89);
AddLabel(close,”Stacked EMAs”,(if price > ema89 and price > ema55 and price > ema34 and price > ema21 and price > ema8 then Color.GREEN else Color.RED));
解决方法
//@version=4
study("Help (TOS)",overlay=true)
length1 = input(8,'length1')
length2 = input(21,'length2')
length3 = input(34,'length3')
length4 = input(55,'length4')
length5 = input(89,'length5')
ema1 = ema(close,length1)
ema2 = ema(close,length2)
ema3 = ema(close,length3)
ema4 = ema(close,length4)
ema5 = ema(close,length5)
plot(ema1,color=color.green)
plot(ema2,color=color.yellow)
plot(ema3,color=color.red)
plot(ema4,color=color.purple)
plot(ema5,color=color.black)
plot(close,color=color.blue,linewidth=2)
stack = close > ema5 and close > ema4 and close > ema3 and close > ema2 and close > ema1
plotshape(true,text="Stacked EMAs",textcolor=stack ? color.green : color.red,show_last=1)
