以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  如何用这个模型开平仓?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=10115)

--  作者:qkl586
--  发布时间:2012/2/14 1:25:52
--  如何用这个模型开平仓?

INPUT:X(10,1,20,1);
VARIABLE: aspect=0; //初始化假定做多头
VARIABLE: stopprice=0;//止损价格变量
VARIABLE: stopnum =X; //止损价差
RUNMODE:0;            //工作于逐周期模式
if barpos = 0 then
  stopprice:=l - stopnum;//该周期最低价减止损价差
if aspect=0 then
begin
 //多头处理 
 if l <=stopprice then
 begin
  //多反空
  aspect:=1;
  stopprice:=h+stopnum;
 end
  //处理移动的底部
 if l - stopnum > stopprice then
  stopprice:=l-stopnum;
end
if aspect=1 then
begin
 //空头处理 
 if h>=stopprice then
 begin
  //空反多
  aspect:= 0;
  stopprice:=l-stopnum;
 end
 //处理移动的底部
 if h + stopnum<stopprice then
  stopprice :=h+stopnum;
end
//画线
PARTLINE( aspect =0, stopprice , colorrgb(255,0,0));
PARTLINE( aspect =1, stopprice , colorrgb(0,255,0));

 

上述模型是我在论坛上发现的移动止损的范例,我想将止损的条件改为开平仓的条件(即多头止损条件触发了直接平多开空,空头止损条件触发了直接平空开多)。

应该如何修改呢?只会苯办法的编程,这样的不会弄,邯郸学步整了一晚上也没弄好,求助高手了!

 


--  作者:fly
--  发布时间:2012/2/14 9:28:11
--  
等等,少后回复
--  作者:qkl586
--  发布时间:2012/2/15 0:01:48
--  

依然期待中......

 


--  作者:fly
--  发布时间:2012/2/15 10:07:13
--  

这个就是个如何移动止损的例子

并没有给定什么条件下止损

 

以下这个帖子,给的比较详细,且给出了止损条件

http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=2160&page=2

 

至于您说的止损平仓后直接反手的例子,简化了,其实就是平仓后反手

可参考该帖问题5,直接就是平仓反手的模型

http://www.weistock.com/bbs/dispbbs.asp?boardid=4&Id=332

 

 


--  作者:qkl586
--  发布时间:2012/2/15 14:41:06
--  
先学习,不明白再请教。