MA1:=MA(CLOSE,5);
MA2:=( stopprice);
variable:maxprofit=0;//有仓位时最大获利幅度
//开多
IF CROSS(MA1,MA2) THEN
BEGIN
BUY( HOLDING=0,10%,market);//开多操作
maxprofit:=0;
END//平仓
SELL(CROSS(MA2,MA1),0);//平多
//判断当前持仓状态下的最大盈利
。。。。。。
这是:单开,单平;我想在改为:
平多同时开空;平空同时开多
MA1:=MA(CLOSE,5);
MA2:=( stopprice);
variable:maxprofit=0;//有仓位时最大获利幅度
//开多
IF CROSS(MA1,MA2) THEN
BEGIN
BUY( HOLDING=0,10%,market);//开多操作
SELLSHORT(HOLDING=0,10%,market );//开空
maxprofit:=0;
END//平仓
SELL(CROSS(MA2,MA1),0);//平多
BUYSHORT(HOLDING=0,10%,market );//开空
//判断当前持仓状态下的最大盈利
。。。。。。
这样就没有信号了;
请老师给改下一下!谢谢
VARIABLE: aspect=0; //初始化假定做多头
VARIABLE: stopprice=0;//止损价格变量
VARIABLE: stopnum = 10; //止损价差
RUNMODE:0; //工作于逐周期模式
MA1:=MA(CLOSE,5);
MA2:=( stopprice);
variable:maxprofit=0;//有仓位时最大获利幅度
//开多
IF CROSS(MA1,MA2) THEN
BEGIN
BUY( HOLDING=0,10%,market);//开多操作
SELLSHORT(HOLDING=0,10%,market );//开空
maxprofit:=0;
END//平仓
SELL(CROSS(MA2,MA1),0);//平多
BUYSHORT(HOLDING=0,10%,market );//开空
//判断当前持仓状态下的最大盈利
win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
if holding < 0 and enterbars > 0 then
begin
win:=(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//出现浮动亏损比如2%平仓
止损:SELL(win < -2,0);
//出现最高盈利后,回落到盈利的60%平仓出场
持仓: holding,NODRAW;
盈亏:asset*ML,noaxis,COLORFFFF00,NODRAW;
收益:ROUND((asset-50000)*ML/50000),COLORFFFF00,NODRAW;
次数:=totaltrade,COLORFFFFFF,NODRAW;
胜率:percentwin,COLORFFFFFF,NODRAW;
连赢:=maxseqwin,COLORFFFFFF,NODRAW;
连亏:=maxseqloss,COLORFFFFFF,NODRAW;
stopprice是0,那么永远不会上下穿ma1,
你给的条件永远不会开仓
ok
这样还是没有信号的;
VARIABLE: aspect=0; //初始化假定做多头
VARIABLE: stopprice=0;//止损价格变量
VARIABLE: stopnum = 10; //止损价差
RUNMODE:0; //工作于逐周期模式
if barpos = 0 then
stopprice := l - stopnum;
if aspect = 0 then
begin
//多头处理
if l <= stopprice then
begin
//多反空
aspect:= 1;
stopprice := h+stopnum;
end
//处理移动的底部
if l - stopnum > stopprice then
stopprice := l-stopnum;
end
if aspect = 1 then
begin
//空头处理
if h >= stopprice then
begin
//空反多
aspect:= 0;
stopprice := l-stopnum;
end
//处理移动的底部
if h + stopnum < stopprice then
stopprice := h+stopnum;
end
//画线
PARTLINE(aspect = 0, stopprice , colorrgb(255,0,0)),LINETHICK2;
PARTLINE(aspect = 1, stopprice , colorrgb(0,255,0)),LINETHICK2;
MA1:=MA(CLOSE,1);
MA2:=( stopprice);
variable:maxprofit=0;//有仓位时最大获利幅度
//开多
IF CROSS(MA1,MA2) THEN
BEGIN
SELLSHORT( HOLDING=0,10%,market );//平空
BUY( HOLDING=0,10%,market);//开多操作
maxprofit:=0;
END//平仓
SELL(CROSS(MA2,MA1),0);//平多
BUYSHORT(HOLDING=0,10%,market );
//判断当前持仓状态下的最大盈利
win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
win:=(c-enterprice)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
if holding < 0 and enterbars > 0 then
begin
win:=(enterprice-c)/enterprice*100; //记录最大盈利
if win > maxprofit then
maxprofit:=win;
win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//出现浮动亏损比如2%平仓
止损:SELL(win < -2,0);
//出现最高盈利后,回落到盈利的60%平仓出场
持仓: holding,NODRAW;
盈亏:asset*ML,noaxis,COLORFFFF00,NODRAW;
收益:ROUND((asset-50000)*ML/50000),COLORFFFF00,NODRAW;
次数:=totaltrade,COLORFFFFFF,NODRAW;
胜率:percentwin,COLORFFFFFF,NODRAW;
连赢:=maxseqwin,COLORFFFFFF,NODRAW;
连亏:=maxseqloss,COLORFFFFFF,NODRAW;
SELLSHORT( HOLDING=0,10%,market );//平空
错在这里的holding=0