想写一个止损的公式,但是下面的公式保存时总提示应使用逐K线计算,不知序列计算和逐K线计算有什么区别呢,为什么下面的代码必须用逐K线计算?谢谢
MA1:=MA(CLOSE,5);
MA2:=MA(CLOSE,30);
variable:resmaxprofit=0;//有仓位时最大获利幅度
//开仓
IF CROSS(MA1,MA2) THEN
BEGIN
tBUY(1,1,lmt,c);
resmaxprofit:=0;
END
//平仓
tSELL(CROSS(MA2,MA1),0,lmt,c);
//判断当前持仓状态下的最大盈利
win:=0;
win2:=0;
if tholding > 0 and tenterbars > 0 then
begin
win:=(c-tenterprice)/tenterprice*100; //记录最大盈利
if win > resmaxprofit then
resmaxprofit:=win;
win2:=(resmaxprofit-win)/resmaxprofit*100; //最大盈利后的回调幅度
end
if tholding < 0 and tenterbars > 0 then
begin
win:=(tenterprice-c)/tenterprice*100; //记录最大盈利
if win > resmaxprofit then
resmaxprofit:=win;
win2:=(resmaxprofit-win)/resmaxprofit*100; //最大盈利后的回调幅度
end
//出现浮动亏损比如2%平仓
止损:tSELL(win < -2,0,lmt,c);
//出现最高盈利后,回落到盈利的60%平仓出场
止赢:tSELL(win2 >= 50,0,lmt,c);
end
公式写的有问题啊 语法错误的 缺少BEGIN