X_1:=(C-MA(C,20))/MA(C,20)*100;
X_2:=(C-REF(C,1))/REF(C,1)*100;
X_3:=BArslAST(BARSLAST(X_1>0 AND REF(X_1,1)>0)>0);
X_4:=BARSLAST(BARSLAST(X_1<0 AND REF(X_1,1)<0)>0);
利润:IF(X_3>0,SUM(X_2,X_3),0),STICK;
买入:IF(REF(X_4,1)>0 AND X_4=0,5,0),STICK,COLORMAGENTA;
卖出:IF(REF(X_3,1)>0 AND X_3=0,5,0),STICK,COLORCYAN;
持币:IF(X_4>0,(-5),0),STICK;
STICKLINE(利润>0,利润,0,2,0),COLORRED;
STICKLINE(利润<=0,利润,0,2,0),COLORGREEN;
STICKLINE(X_4>0,(-5),0,2,0),COLORYELLOW;
STICKLINE(买入>0,5,0,2,0),COLORLIRED;
STICKLINE(卖出>0,5,0,2,0),COLORLIBLUE;