欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 我想每赚10个点平一手可第一个10点就全平了,老大帮看看哪写错了

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有4862人关注过本帖树形打印复制链接

主题:我想每赚10个点平一手可第一个10点就全平了,老大帮看看哪写错了

帅哥哟,离线,有人找我吗?
hj339
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:30 积分:98 威望:0 精华:0 注册:2011/12/8 16:58:13
我想每赚10个点平一手可第一个10点就全平了,老大帮看看哪写错了  发帖心情 Post By:2012/7/26 16:44:06    Post IP:120.192.237.128[只看该作者]

我想每赚10个点平一手可第一个10点就全平了,老大帮看看哪写错了
 
 
//赢10点(m2及M4均先设为10)
 If holding < 0 then begin
  sellshort(Enterprice-l>=M2, 1, limitr, enterprice-M2+mindiff);
 end
  
 If  holding > 0 then begin
  sell(h-Enterprice>=M2, 1, limitr, enterprice+m2-mindiff);
  end
  
   //赢20点
 If holding < 0 then begin
  sellshort(Enterprice-l>=M2+M4, 1, limitr, enterprice-M2+mindiff);
 end
  
 If  holding > 0 then begin
  sell(h-Enterprice>=M2+M4, 1, limitr, enterprice+m2-mindiff);
  end
  //赢30点
 If Enterprice-l>=M2+2*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+2*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢40点
 If Enterprice-l>=M2+3*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+3*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢50点
 If Enterprice-l>=M2+4*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+4*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢60点
 If Enterprice-l>=M2+5*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+5*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢70点
 If Enterprice-l>=M2+6*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+6*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢80点
 If Enterprice-l>=M2+7*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+7*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
   //赢90点
 If Enterprice-l>=M2+8*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+8*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
    //赢100点
 If Enterprice-l>=M2+9*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+9*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end
    //赢110点
 If Enterprice-l>=M2+10*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2+mindiff);
 end
  
 If h-Enterprice>=M2+10*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2-mindiff);
  end

我想每赚10个点平一手可第一个10点就全平了,老大帮看看哪写错了

 回到顶部
帅哥哟,离线,有人找我吗?
王锋
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:罗宾汉 帖子:11808 积分:20695 威望:0 精华:10 注册:2009/8/18 8:15:13
  发帖心情 Post By:2012/7/26 16:46:54    Post IP:116.231.98.166[只看该作者]

发个完整的公式上来,否则我们也没法查找问题的



金字塔—专业程序化软件提供商

金字塔-技术部

-----------------------------------------------------------------------------------------------------

工作时间:周一至周五 08:30 - 17:30   周末及法定节假日休息

Email:service@weistock.com
 回到顶部
帅哥哟,离线,有人找我吗?
hj339
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:30 积分:98 威望:0 精华:0 注册:2011/12/8 16:58:13
  发帖心情 Post By:2012/7/26 17:46:28    Post IP:120.192.237.128[只看该作者]

INPUT:N(8,1,100,1); //设置参数时;
INPUT:M(21,1,100,1); //设置参数时;;
INPUT:M2(10,1,100,1); //设置参数时;
INPUT:M4(10,1,100,1); //设置参数时;
MA1:MA(C,n);
MA3:MA(C,m);

 

//建立多头的进场条件
long := time>093000 and time<140000;

if long  and cross(ma1,ma3) then
 begin
 sellshort(holding < 0 , 0, thisclose);
 end
if long and cross(ma1,ma3) then
 begin
 buy(holding = 0 , N, thisclose);
 end
//14:00-14:55平空仓
if cross(ma3,ma1) and time>140000 and time<145500 then
begin
sellshort(holding < 0, 0, thisclose);
end

 


//开空条件
short :=  time > 093000 and time < 140000;

if short  and cross(ma3,ma1) then
 begin
 sell(holding > 0, 0, thisclose);
 end
if short and l < cross(ma3,ma1) then
 begin
 buyshort(holding = 0 ,N, thisclose);
 end 

 //140000-1455平多仓
if cross(ma3,ma1) and time>=140000 and time<=145500 then
begin
sell(holding > 0, 0, thisclose);
end


//收盘前5分钟平仓
if time > 145400 then
 begin
 sell(holding > 0, 0, thisclose);
 sellshort(holding < 0, 0, thisclose);
 end

//赢10点(m2及M4均先设为10)
 If holding < 0 then begin
  sellshort(Enterprice-l>=M2, 1, limitr, enterprice-M2+mindiff);
 end
 
 If  holding > 0 then begin
  sell(h-Enterprice>=M2, 1, limitr, enterprice+m2-mindiff);
  end
 
   //赢20点
 If holding < 0 then begin
  sellshort(Enterprice-l>=M2+M4, 1, limitr, enterprice-M2-m4+mindiff);
 end
 
 If  holding > 0 then begin
  sell(h-Enterprice>=M2+M4, 1, limitr, enterprice+m2+m4-mindiff);
  end
  //赢30点
 If Enterprice-l>=M2+2*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-2*m4+mindiff);
 end
 
 If h-Enterprice>=M2+2*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+2*m4-mindiff);
  end
   //赢40点
 If Enterprice-l>=M2+3*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-3*m4+mindiff);
 end
 
 If h-Enterprice>=M2+3*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+3*m4-mindiff);
  end
   //赢50点
 If Enterprice-l>=M2+4*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-4*m4+mindiff);
 end
 
 If h-Enterprice>=M2+4*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+4*m4-mindiff);
  end
   //赢60点
 If Enterprice-l>=M2+5*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-5*m4+mindiff);
 end
 
 If h-Enterprice>=M2+5*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+5*m4-mindiff);
  end
   //赢70点
 If Enterprice-l>=M2+6*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-6*m4+mindiff);
 end
 
 If h-Enterprice>=M2+6*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+6*m4-mindiff);
  end
   //赢80点
 If Enterprice-l>=M2+7*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-7*m4+mindiff);
 end
 
 If h-Enterprice>=M2+7*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+7*m4-mindiff);
  end
   //赢90点
 If Enterprice-l>=M2+8*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-8*m4+mindiff);
 end
 
 If h-Enterprice>=M2+8*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+8*m4-mindiff);
  end
    //赢100点
 If Enterprice-l>=M2+9*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-9*m4+mindiff);
 end
 
 If h-Enterprice>=M2+9*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+9*m4-mindiff);
  end
    //赢110点
 If Enterprice-l>=M2+10*M4 then begin
  sellshort(holding < 0, 1, limitr, enterprice-M2-10*m4+mindiff);
 end
 
 If h-Enterprice>=M2+10*M4 then begin
  sell(holding > 0, 1, limitr, enterprice+m2+10*m4-mindiff);
  end


 回到顶部
帅哥哟,离线,有人找我吗?
guotx2010
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:蜘蛛侠 帖子:1366 积分:5210 威望:0 精华:7 注册:2010/12/11 18:00:33
  发帖心情 Post By:2012/7/27 8:24:57    Post IP:113.98.195.99[只看该作者]

图表方式不好实现,使用后台策略来实现吧,因为要取实际持仓。

 


 回到顶部
帅哥哟,离线,有人找我吗?
hj339
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:30 积分:98 威望:0 精华:0 注册:2011/12/8 16:58:13
  发帖心情 Post By:2012/7/27 8:46:19    Post IP:120.192.237.128[只看该作者]

后台方式怎么实现????


 回到顶部
帅哥哟,离线,有人找我吗?
阿火
  6楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 原leevolvo
等级:版主 帖子:2160 积分:10563 威望:0 精华:11 注册:2010/11/3 11:21:19
  发帖心情 Post By:2012/7/27 8:56:27    Post IP:218.66.121.220[只看该作者]

已经做好了修改

另外,楼主注意顺序。你自己写的顺序是错的。

如果穿越当根最高价比收盘价高10个点,按你的写法,你会平仓的

但是在收盘价的位置产生信号,却在当根平仓。这是不符合逻辑的,因为盘中价早于收盘价出现。怎么可能“开仓在后,平仓在前”呢!

 

这种方法要实盘,还有2点要注意:

1,同一根K线多次符合止盈条件,图表只会自动下一次。除非规定一根K线只能止盈一次

2,盘中下单和K线走完下单并存,实盘交易时还需要作稍微的修改,请参考 阿火秘笈

 

INPUT:N(8,1,100,1); //设置参数时;
INPUT:M(21,1,100,1); //设置参数时;;
INPUT:M2(10,1,100,1); //设置参数时;
INPUT:M4(10,1,100,1); //设置参数时;
variable:price=drawnull;
MA1:MA(C,n);
MA3:MA(C,m);
if holding>0 then begin
 cis:=intpart((h-price)/10);
 if cis>0 then begin
  //如果同一根K线上涨了20个点以上,虽然有2个平仓信号,但图表只会执行一次
  for i=1 to cis do begin
   sell(1,1,limitr,price+10*i);
  end
  price:=price+10*cis;
 end
end
if holding<0 then begin
 cis:=intpart((price-l)/10);
 if cis>0 then begin
  for i=1 to cis do begin
   sellshort(1,1,limitr,price-10*i);
  end
  price:=price-10*cis;
 end
end

//建立多头的进场条件
long := time>093000 and time<140000;

if long  and cross(ma1,ma3) then
 begin
 sellshort(holding < 0 , 0, thisclose);
 end
if cross(ma3,ma1) and time>140000 and time<145500 then
begin
sellshort(holding < 0, 0, thisclose);
end
if holding = 0 and long and cross(ma1,ma3) then
 begin
 buy(1 , N, thisclose);
 price:=c;
 end
//14:00-14:55平空仓


//开空条件
short :=  time > 093000 and time < 140000;

if short  and cross(ma3,ma1) then
 begin
 sell(holding > 0, 0, thisclose);
 end
if cross(ma3,ma1) and time>=140000 and time<=145500 then
begin
sell(holding > 0, 0, thisclose);
end
if holding = 0 and short and l < cross(ma3,ma1) then
 begin
 buyshort(1 ,N, thisclose);
 price:=c;
 end
 //140000-1455平多仓

//收盘前5分钟平仓
if time > 145400 then
 begin
 sell(holding > 0, 0, thisclose);
 sellshort(holding < 0, 0, thisclose);
 end

[此贴子已经被作者于2012-7-27 9:23:37编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
hj339
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:30 积分:98 威望:0 精华:0 注册:2011/12/8 16:58:13
  发帖心情 Post By:2012/7/27 10:05:26    Post IP:120.192.237.128[只看该作者]

阿火兄,怎样才能修改到能实盘,请帮帮忙,我是菜鸟


 回到顶部