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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件交易策略发布专区 → [原创]根据杨永彬介绍、编写的代码策略,大家学习学习

   

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


  共有13091人关注过本帖平板打印复制链接

主题:[原创]根据杨永彬介绍、编写的代码策略,大家学习学习

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


加好友 发短信
等级:新手上路 帖子:13 积分:38 威望:0 精华:0 注册:2012/12/9 10:14:50
  发帖心情 Post By:2013/3/21 16:51:24 [只看该作者]

{这也是我们经常使用的移动平均线交叉系统,我们使用的是3分钟的线,这个系统也非常简单,
短期(8)移动平均线位于长期(11)移动平均线上方,现价大于最近14根K线最高价的0.2%倍时,买入开仓。
短期(8)移动平均线位于长期(11)移动平均线下方,现价小雨最近14根K线最低价的0.2%倍时,卖出开仓。
这个市场里有短期上升和长期上升,这种情况发生的非常多。}

//////////////////////////////
M:=BARSLAST(DATE<>REF(DATE,1))+1;
MA8:SUM(C,8)/8;//这样计算相当于SMA
MA11:SUM(C,11)/11;

手数:=1;
H14:HHV(REF(H,1),14)*(1+0.002);
L14:LLV(REF(L,1),14)*(1+0.002);

////////////////////////////////////////
Buy1:=C>H14 AND MA8>MA11;
Sell1:=C<L14  AND MA8<MA11;
SS:=手数;     {开仓手数}
ZsDs:=3;     {平仓点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
variable:YdZy=1;     {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=2,KHcDs=2;   {多、空单回撤点数}
variable:DYlDs=5,KYlDs=5;   {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1:=1;     {赚5保1开关,1为开,0为关}
DuoKong:=1;
/////////////////////////////////////////////////////////////////
variable:a1:=0;
variable:a2:=0;
variable:c1:=1;
if (Buy1) and c1>0 then begin
  a1:=time0;
  a2:=c;
  c1:=-1;
end
if not((Buy1)) then begin
  a1:=time0;
  a2:=c;
  c1:=1;
end
cxsj:=(time0-a1)>=3 or not(islastbar); {信号持续成立的时间,等于0表示没有信号}
///////////////////////////////////////////////////////////////////
//持有空单
If Holding<0 then Begin
 If Buy1 then begin   //平空单
  空平:SellShort(1,0,mkt),orderqueue;
 End
 
 //止损
 If C-LOW>ZsDs then begin
  SellShort(1,0,mkt),orderqueue;
 End
 
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新低
  If L<LowPrice then begin
   LowPrice:=L;
  End 
  
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If Enterprice-LowPrice>=KYlDs then begin
   If L-LowPrice>=KHcDs Then Begin  //回撤超过3点
    空赢:SellShort(1,0,market);
   End 
  End 
 End
 
 //赚3保1
 If Z3B1=1 then begin
  If Enterprice-LowPrice>=3 then begin
   If Enterprice-L<=1.2 then begin
    空保:SellShort(1,0,market);
   End
  End
 End
End
//开多单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=2 then begin
  If Buy1  AND cxsj then begin
   多开:Buy(1=1,SS,mkt);
   HighPrice:=Enterprice;  //将开仓价保存到最高价
  End 
 End
end
//持有多单
If Holding>0 then Begin
 If Sell1 then begin  {平多单}
  多平:Sell(1,0,mkt),orderqueue;
 End
 
 //多单管理
 //止损
 If HIGH-C>ZsDs then begin
  Sell(1,0,mkt),orderqueue;
 End
 //移动止盈
 If YdZy=1 then begin
  //每周期判断是否创新高
  If H>HighPrice then begin
   HighPrice:=H;
  End 
 
  //如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
  If HighPrice-Enterprice>=DYlDs then begin
   If HighPrice-H>=DHcDs Then Begin  //回撤超过3点
    多赢:Sell(1,0,market);
   End 
  End 
 End
 //赚3保1
 If Z3B1=1 then begin
  If HighPrice-Enterprice>=3 then begin
   If H-Enterprice<=1.2 then begin
    多保:Sell(1,0,market);
   End
  End
 End
End
//开空单
If holding=0 then begin
 If DuoKong=1 Or DuoKong=3 then begin
  If Sell1   AND cxsj then begin
   空开:BuyShort(1=1,SS,mkt);
   LowPrice:=enterprice;
  End 
 End
end
//在日内尾盘收盘的时候清掉所有方向的单
IF HOLDING<>0 AND TIME>145930 THEN BEGIN
IF HOLDING>0  THEN BEGIN
尾多:SELL(1,0,THISCLOSE);
End
IF  HOLDING<0  THEN BEGIN
尾空:SELLSHORT(1,0,THISCLOSE);
End
End

[此贴子已经被作者于2013-3-21 16:51:46编辑过]

版主评定:好评,获得25个金币奖励好评,获得25个金币奖励
(理由:好文章)
 回到顶部