以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://www.weistock.com/bbs/list.asp?boardid=4)
----  [讨论]动态止盈  (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=138222)

--  作者:70001789
--  发布时间:2016/8/18 14:43:47
--  [讨论]动态止盈
请问盈利50个点后回撤到70%止盈怎么写?以及如何限制只开一手仓,即手上有持仓时出现进场信号不开仓?谢谢!
图片点击可在新窗口打开查看此主题相关图片如下:rficymqppaa4vmi%wrvr8q.png
图片点击可在新窗口打开查看

动态止盈按照论坛给的,加了绿色字体,回测时发现许多平进平出,应该是条件没加进去


//判断当前持仓状态下的最大盈利
win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
  win:=(c-enterprice)/enterprice*100; //记录最大盈利
  if win > maxprofit then
  maxprofit:=win; 
  win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
if holding < 0 and enterbars > 0 then
begin
  win:=(enterprice-c)/enterprice*100; //记录最大盈利
  if win > maxprofit then
  maxprofit:=win;
  win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
end
//盈利超过50个点时,启动70%止盈
止赢:SELL(win2 >= 70 AND ABS(C-ENTERPrice)>=50 and openprofit > 0, 0) ;
     SELLSHORT(win2 >= 70 AND ABS(C-ENTERPrice)>=50  and openprofit > 0, 0) ;

--  作者:jinzhe
--  发布时间:2016/8/18 14:58:45
--  

首先确认一下,盈利50点之后回撤70%止盈

指的是盈利50点之后,行情一路往下跑,跑到只有盈利15点时止盈吗?

 


--  作者:70001789
--  发布时间:2016/8/18 15:07:36
--  
回撤到70%止盈,就是盈利50点后行情不对,盈利35个点止盈
--  作者:jinzhe
--  发布时间:2016/8/18 15:26:07
--  

if holding>0 and hhv(h,enterbars+1)>enterprice+50 and c<(hhv(h,enterbars+1)-(hhv(h,enterbars+1)-enterprice)*0.3) then sell(1,0,market);

if holding<0 and llv(l,enterbars+1)<enterprice-50 and c>(llv(l,enterbars+1)+(enterprice-llv(l,enterprice))*0.3) then sellshort(1,0,market);