ap1:=amount/(vol*volunit);
ap2:=(o+h+l+c)/4;
yes:=ap1>=h or ap1<=l;
amt:=if(yes,ap2*vol*volunit,amount);
CB6:=SUM(amt,6)/SUM(VOL,6)/100;
CB13:=SUM(amt,13)/SUM(VOL,13)/100;
CB21:=SUM(amt,21)/SUM(VOL,21)/100;
CB34:=SUM(amt,34)/SUM(VOL,34)/100;
CB55:=SUM(amt,55)/SUM(VOL,55)/100;
CB89:=SUM(amt,89)/SUM(VOL,89)/100;
CB144:=SUM(amt,144)/SUM(VOL,144)/100;
CB233:=SUM(amt,233)/SUM(VOL,233)/100;
CB377:=SUM(amt,377)/SUM(VOL,377)/100;
短期成本:(CB6+CB13+CB21)/3;
中期成本:(CB34+CB55+CB89)/3,colorred;
长期成本:=(CB144+CB233+CB377)/3;
平均成本:=(短期成本+中期成本+长期成本)/3;
启动:ema(cost(71),21),COLORgreen;
牛市成本:ema(cost(34),3),COLORwhite,linethick2;
牛市启动:ema(cost(81),30),COLORyellow;