以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  求助解决  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=2147)

--  作者:wjxkjs
--  发布时间:2010/7/16 16:40:18
--  求助解决

10)       追踪止赢功能(按回调比例)

input:NS(5,1,100,1);{ 回调比例}
tt0:=time<145000;
tt2:=time>145700;//收盘时间

SELLSHORT(tt0 and BP and 持仓<0,持仓,market);
SELLSHORT(tt0 and 持仓<0,持仓,Stopr, LLV(L,ENTERBARS)*(1+NS/100));
BUY(tt0 and BK and  持仓=0,20%,market);

SELL(tt0 and SP and 持仓>0,持仓,market);
SELL(tt0 and 持仓>0,持仓,Stopr, HHV(H,ENTERBARS)*(1-NS/100));
BUYSHORT(tt0 and SK and 持仓=0,20%,market);

 

这是程序帮助中对追踪止盈的一个范例,在没有加入这里的内容时,我的软件一切正常。加入这部分内容后,发现开仓后就立即平仓的特别多。而且在K线下面基本上每个都有一个三角形,是什么原因?


--  作者:admin
--  发布时间:2010/7/16 17:27:43
--  [求助]如何统计当天最大盈利和亏损次数?
以上代码无法实现追棕止赢,我们稍后会给大家做一个移动止损得范例
--  作者:wjxkjs
--  发布时间:2010/7/16 21:31:07
--  

移动止损的例子,论坛有。希望能有追踪止盈的范例


--  作者:wjxkjs
--  发布时间:2010/7/16 22:02:16
--  [求助]编写模型
http://www.weistock.com/bbs/dispbbs.asp?BoardID=4&ID=1900&replyID=&skin=1
--  作者:wjxkjs
--  发布时间:2010/7/16 23:18:02
--  

VARIABLE: aspect=0; //初始化假定做多头
VARIABLE: stopprice=0;//止损价格变量
VARIABLE: stopnum =NS*mindiff; //止损价差
 

if barpos = 0 then
  stopprice := h - stopnum;

if aspect = 0 then
begin
 //多头处理 
 if h <= stopprice then
 begin
  //多反空
  aspect:= 1;
  stopprice := l+stopnum;
 end
 
 //处理移动的底部
 if h - stopnum > stopprice then
  stopprice := h-stopnum;
end

if aspect = 1 then
begin
 //空头处理 
 if l >= stopprice then
 begin
  //空反多
  aspect:= 0;
  stopprice := h-stopnum;
 end
 
 //处理移动的底部
 if l+ stopnum < stopprice then
  stopprice := L+stopnum;

 

老师,仿照移动止损的例子,做了一个移动止盈的,好像测试有效。请老师指点--价格大于stopprice空头止赢