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


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

   

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


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

主题:不能实现移动止损

帅哥哟,离线,有人找我吗?
进击的红太狼
  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;

 回到顶部