绿柱 开空仓 持仓后记录绿柱的值 如果当前的绿柱值小于前面全部绿柱的平均值就平仓 老师怎么写
红绿柱是macd 的红绿柱?
首先,把macd的公式抄一遍
avg_macd:sum(macd1,enterbars+1)/(enterbars+1);
if macd1<avg_macd and enterbars>1 then sellshort(1,0,market);
还有 是最后一秒判断这个柱子的值是不是小于持仓后绿柱的平均值
老师 你写的不是我要的
比如 9点开空仓 9点01的绿柱A 9点02也绿柱 B 9点03当前绿柱 C 如果C在最后一秒的值小于(A+D)/2 就平仓
//红绿柱
昨收盘:=CALLSTOCK(STKLABEL,VTCLOSE,6,-1);
红绿柱:=(sma(ref(c,1),2,1)-sma(ref(c,1),6,1))*2.1,NOAXIS,COLORWHITE;
STICKLINE(红绿柱>0,昨收盘,昨收盘+红绿柱,0.1,0),COLORMAGENTA;
STICKLINE(红绿柱<0,昨收盘,昨收盘+红绿柱,0.1,0),COLORYELLOW;
avg:sum(昨收盘+红绿柱,enterbars+1)/(enterbars+1);
if 昨收盘+红绿柱<avg_macd and enterbars>1 and 红绿柱<0 then sellshort(1,0,market);