以文本方式查看主题

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

--  作者:llmyb
--  发布时间:2011/11/29 17:11:50
--  手工开仓,自动平仓求助

VARIABLE: eprice=0,zs=0,ko=0;
aa:tholding,linethick0;
bb:=extgbdata(\'quanju\');
cond := bb<>0 and ko=0;
u:BARSLAST(COND)+1;
hu :hhv(high,u);
lu : llv(low,u);
if cond then ko=close;
if bb>0 then begin
  if hu-ko<n*mindiff then begin
    zs :=hu-n*mindiff;
    end
  if hu-low>=n*mindiff then begin
    zs := ko+p*mindiff;
    end
  end
if bb<0 then begin
  if ko-lu<n*mindiff then begin
    zs:= lu+n*mindiff;
    end
  if hu-lu>=n*mindiff then begin
    zs:= ko-p*mindiff;
    end
  end
zsline :zs,circledot;
if bb>0 and holding=0 then
begin
buy(1,1,thisclose);
end

if holding>0 and cross(zs,low) then
begin
 sell(1,0,market);
end

if bb<0 and holding=0 then buyshort(barpos=datacount-1,1,thisclose+mindiff);
if holding<0  and cross(high,zs) then
begin
 sellshort(1,0,market);
end

if islastbar then extgbdataset(\'quanju\',aa);


--  作者:llmyb
--  发布时间:2011/11/29 17:13:35
--  

写法不知哪出问题,没有实现开仓后,标出止损线等功能。


--  作者:26327756l
--  发布时间:2011/11/29 17:17:02
--  

问题正在解决中


--  作者:fly
--  发布时间:2011/11/30 9:25:09
--  

类似此种的赋值语句,注意写法

cond := bb<>0 and ko=0;---------ko:=0

 

先仔细研究研究原作者关于"手动开仓,自动平仓"的每一句,再把自己的条件套进去修改.

[此贴子已经被作者于2011-11-30 9:27:08编辑过]