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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 不能实现移动止损

   

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


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

主题:不能实现移动止损

帅哥哟,离线,有人找我吗?
进击的红太狼
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:2 积分:0 威望:0 精华:0 注册:2018/11/7 16:00:47
不能实现移动止损  发帖心情 Post By:2018/12/5 20:11:19    Post IP:117.174.30.140[只看该作者]

请版主帮看看,移动止损部分是在其他帖子上拷贝学习的,好像不能实现移动止盈的功能呢,我自己初步判断是不是high和low的数值不对,因为我是在5nK线上加载的。请帮忙看下该怎么实现移动止盈功能。

//各种变量***************************************
input:NumberOpenPositions(1,1,10),NumberStop(15,10,20),TargetProfit(30,10,1000);
variable:MaxProfit=0;
TodayOpen:valuewhen(todaybar=1,open);
MaOneMin:ma(close,12);
CrossUp:cross(MaOneMin,TodayOpen),nodraw;
CrossDown:cross(TodayOpen,MaOneMin),nodraw;

//固定止损部分***********************************
if enterprice-c>NumberStop*mindiff and holding>0 then
   sell(1,holding,marketr);
if c-enterprice>NumberStop*mindiff and holding<0 then
   sellshort(1,holding,marketr);

//移动止损部分***********************************
if holding>0 and enterbars>=0 then begin
   win:=high-avgenterprice;
   if win>MaxProfit then MaxProfit:=win;
   win2:=MaxProfit-win;end
if holding<0 and enterbars>=0 then begin
   win:=avgenterprice-low;
   if win>MaxProfit then MaxProfit:=win;
   win2:=MaxProfit-win;end
if MaxProfit>=TargetProfit*mindiff and win2>0.2*MaxProfit then begin
   sell(holding>0,holding,marketr);
   sellshort(holding<0,holding,marketr);
   MaxProfit:=0;end
   
//开仓部分****************************************
//if MaOneMin>TodayOpen and holding=0 then
   buyshort(CrossDown,NumberOpenPositions,marketr);
//if TodayOpen>MaOneMin and holding=0 then
   buy(CrossUp,NumberOpenPositions,marketr);
   
当前持仓:HOLDING,COLORGRAY,LINETHICK0,nodraw;

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2018/12/6 9:39:08    Post IP:180.169.30.6[只看该作者]

 这段代码并没有什么问题的。你觉得有问题你需要具体指出来,具体情况具体分析。比如某个K线某个价格情况下符合条件却没有移动止损之类的,给出具体例子说明,才能方便处理的。另外如果你是没办法分清里面各种开平操作的情况,可以给交易语句做一下处理:

比如

if MaxProfit>=TargetProfit*mindiff and win2>0.2*MaxProfit then begin
   移动止损1:sell(holding>0,holding,marketr);
   移动止损2:sellshort(holding<0,holding,marketr);
   MaxProfit:=0;end

这样你也能看到具体什么位置出了止损的信号。


命数如织,当如磐石。
 回到顶部