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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件金字塔软件问题提交 → 止损和移动止盈

   

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


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

主题:止损和移动止盈

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


加好友 发短信
等级:超级版主 帖子:4994 积分:0 威望:0 精华:0 注册:2016/9/1 10:46:51
  发帖心情 Post By:2018/1/30 9:46:51 [显示全部帖子]

实现功能:

1、ema均线上破水平线即平空开多,下破水平线即平多开空。

2、开仓后,如果亏损,且亏损n1个点即进行止损平仓。

3、开仓后,如果盈利,且盈利最大超过n2个点位,并回落n3个点即进行平仓,并反手开仓。

 

 

 

本策略仅供参考,切勿直接用于实盘。

variable:maxprofit=0;              //记录仓位的最大获利
input:A(3800,1,100000,100);  //定义的水平线
input:ss(1,1,50,1);                 //手数
input:p1(5,1,100,1);              //均线变量
input:n1(10,1,100,1);            //止损点位
input:n2(100,10,1000,1);       //止盈点位
input:n3(25,10,1000,1);         //回调点位

 

m1:ema(close,p1);
conpkkd:=cross(m1,A);
conpdkk:=cross(A,m1);

 

if conpkkd then                    //平空开多
  begin
  sellshort(holding<0,holding,market);
  buy(holding=0,ss,market);
  maxprofit:=0;
  end
 
if conpdkk then                  //平多开空
   begin
   sell(holding>0,holding,market);
   buyshort(holding=0,ss,market);
   maxprofit:=0;
   end
  
if holding>0 and enterprice-low>n1   then sell(1,holding,market);          //多头止损
if holding<0 and high-enterprice>n1  then sellshort(1,holding,market);  //空头止损

 

win:=0;    //最大盈利变量
win2:=0;    //最大回调变量
if holding>0 then
  begin
  win:=high-enterprice;      //记录多头最大盈利
  if win>maxprofit then maxprofit:=win;
  win2:=maxprofit-win;     //记录多头最大盈利后的回调
  end

 

if holding<0 then
   begin
   win:=enterprice-low;//记录空头最大盈利
   if win>maxprofit then maxprofit:=win;
   win2:=maxprofit-win;   //记录空头最大盈利后的回调
   end
  
if holding>0 and maxprofit>=n1 and win2>=n2 then    //多头止盈,并反手开空
   begin
   sell(1,holding,market);
   buyshort(1,ss,market);
   end
  
if holding<0 and maxprofit>=n1 and win2>=n2 then     //空头止盈,并反手开多
   begin
   sellshort(1,holding,market);
   buy(1,ss,market);
   end

 

line1:A,linethick2,colorwhite;    //水平线
line2:enterprice-n1*mindiff,linethick2,colorgreen;         //止损线
line3:enterprice+n2*mindiff,linethick2,colorred;           //止盈线
line4:enterprice+(n2-n3)*mindiff,linethick2,coloryellow;   //止盈回落线

[此贴子已经被作者于2018/2/1 14:59:28编辑过]

 回到顶部