500g程序交易源代码https://zhuanlan.zhihu.com/p/57502355
8G策略代码https://dwz.cn/xW6zpv5Q
LengthShort(9),LengthLong(45),BIASLength(6),n(2);
vars:
BIAS(0);
if Xaverage(close,LengthShort) crosses above Xaverage(close,LengthLong) then condition1=true;
value1=Xaverage(close,LengthShort)-Xaverage(close,LengthLong);
bias=XAverage(value1,n);
if condition1=true and Bias[2]>bias[1] and Bias[1] <Bias and Bias<BIASLength then begin
buy next bar at market;
end;
if Xaverage(close,LengthShort) crosses under Xaverage(close,LengthLong) then
begin
condition1=false;
sell next bar at market;
end;
if Xaverage(close,LengthShort) crosses below Xaverage(close,LengthLong) then condition2=true;
if condition2=true and Bias[2]<bias[1] and Bias[1] >Bias and Bias<BIASLength then
begin
sellshort next bar at market;
end;
if Xaverage(close,LengthShort) crosses above Xaverage(close,LengthLong) then
begin
condition2=false;
buytocover next bar at market;
end;