以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请老师给改下一下程序!谢谢  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=71716)

--  作者:FJ6008
--  发布时间:2014/11/5 15:50:40
--  请老师给改下一下程序!谢谢

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 );//开空
//判断当前持仓状态下的最大盈利

。。。。。。

这样就没有信号了;

请老师给改下一下!谢谢

 


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20141030122949.png
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2014/11/5 15:52:36
--  
截图的里面哪些是体现出“没信号”的?
--  作者:FJ6008
--  发布时间:2014/11/5 15:58:20
--  
这是单向的,开多31,平多-31,就是要改为;     平多-31开空-31,平空31开多31;
--  作者:FJ6008
--  发布时间:2014/11/5 16:00:30
--  
这就没有信号了
图片点击可在新窗口打开查看此主题相关图片如下:未命名.jpg
图片点击可在新窗口打开查看

--  作者:jinzhe
--  发布时间:2014/11/5 16:03:57
--  
把你的代码贴齐全了
--  作者:FJ6008
--  发布时间:2014/11/5 16:05:37
--  

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;


--  作者:jinzhe
--  发布时间:2014/11/5 16:23:44
--  

stopprice是0,那么永远不会上下穿ma1,

你给的条件永远不会开仓


--  作者:FJ6008
--  发布时间:2014/11/5 16:29:42
--  

ok

 


--  作者:FJ6008
--  发布时间:2014/11/5 16:41:29
--  

这样还是没有信号的;

 

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;


--  作者:jinzhe
--  发布时间:2014/11/5 16:47:54
--  


SELLSHORT( HOLDING=0,10%,market );//平空

 

错在这里的holding=0