以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请管理进来帮忙查看一下代码是否有问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=72308)

--  作者:zm71212302
--  发布时间:2014/11/24 13:58:39
--  请管理进来帮忙查看一下代码是否有问题

huichechangliang:=3;//回撤值常量
开仓点差:h-TENTERPRICE,LINETHICK0;
if cross(TOPENPROFIT,3000) THEN extgbdataset(\'huichechangliang\',3.5);
{多头回撤平仓}
if h-TENTERPRICE>huichechangliang and tbuyholding(0)>0 and extgbdata(\'jiluqi22\')=0 then begin
     extgbdataset(\'tiqujia\',h);//
     extgbdataset(\'jiluqi22\',1);
     end//记录器
if h>extgbdata(\'tiqujia\') and tbuyholding(0)>0 then extgbdataset(\'tiqujia\',h);
if l<(extgbdata(\'tiqujia\')-huichechangliang) and tbuyholding(0)>0 then begin
 tsell(1,0,mkt),orderqueue;
  extgbdataset(\'jiluqi22\',0);
  DEBUGFILE(\'C:\\st1\\ST11.TXT\',\'多头回撤平仓%.2f\',1);
end
{空头回撤平仓}
if TENTERPRICE-l>huichechangliang and TSELLHOLDING(0)>0 and extgbdata(\'jiluqi22\')=0 then begin
     extgbdataset(\'tiqujia\',l);
     extgbdataset(\'jiluqi22\',1);
     end
if l<extgbdata(\'tiqujia\') and TSELLHOLDING(0)>0 then extgbdataset(\'tiqujia\',l);
if h>(extgbdata(\'tiqujia\')+huichechangliang) and TSELLHOLDING(0)>0 then begin
 TSELLSHORT(1,0,mkt),orderqueue;
 extgbdataset(\'jiluqi22\',0);
  DEBUGFILE(\'C:\\st1\\ST11.TXT\',\'空头回撤平仓%.2f\',1);
end

{------------------停损交易-----------------------}
zhisunjiaoyi:=0;//停止交易
if date<>ref(date,1) then dangqianzich:=tasset;//当前资产
kechengshouk:=dangqianzich*0.025;//可亏损承受
if cross(dangqianzich-tasset,kechengshouk) then begin
tsell(TBUYHOLDING(1)>0,0,mkt);
tsellshort(TSELLHOLDING(1)<0,0,mkt);
extgbdataset(\'zhisunjiaoyi\',1);
DEBUGFILE(\'C:\\st1\\ST11.TXT\',\'停损交易%.2f\',1);
end
{----------------------移动止损----------------------}
zhisunch:=5;//止损常量
kaidansu:=1;//kaidansu
if cross(tasset-dangqianzich,1800) THEN zhisunch:=5;
止损位:TENTERPRICE-zhisunch,LINETHICK0;
if TENTERPRICE-zhisunch and TBUYHOLDING(1)>0 then tsell(1,0,mkt);//多清
if TENTERPRICE+zhisunch and TSELLHOLDING(1)>0 then tsellshort(1,0,mkt);//空清
{------------------------------------------------------}
平仓历时:TEXITBARS(1),LINETHICK0;
实际持仓:tholding2,LINETHICK0;
if tholding>0 then tsell(平多 or 平多1 or 开空,0,lmt,l),orderqueue;//多平
if tholding<0 then tsellshort(平空 or 平空1 or 开多,0,lmt,h),orderqueue;//空平
fenmiaok:TIMETOT0(DYNAINFO(207))-TEXITBARS(1),LINETHICK0;//分秒
huansuan:=2;//换算
if TEXITBARS(1)>0 and fenmiaok<10 THEN extgbdataset(\'huansuan\',0);
if TEXITBARS(1)>0 and fenmiaok>10 then extgbdataset(\'huansuan\',1);
if entertime then BEGIN
if tholding2=0 and zhisunjiaoyi=0 and huansuan>0 then Tbuyshort(开空,kaidansu,lmt,l),orderqueue;//多平
if tholding2=0 and zhisunjiaoyi=0 and huansuan>0 then tbuy(开多,kaidansu,lmt,h),orderqueue;//空平
end
{--------------------时间平仓----------------------}
if  exittime then BEGIN
tsell(TBUYHOLDING(1)>0,0,mkt);//多清
tsellshort(TSELLHOLDING(1)>0,0,mkt);//空清
end


--  作者:jinzhe
--  发布时间:2014/11/24 14:04:58
--  
没有问题的,如果不想看到提醒,那么在代码最开始加这样一句:WARNING_DISABLE:4;
--  作者:zm71212302
--  发布时间:2014/11/24 14:10:55
--  

可是为什么程序没有移动止损,明明行情出来了,却不动作


--  作者:zm71212302
--  发布时间:2014/11/24 14:13:14
--  

zhisunch:=5;//止损常量
kaidansu:=1;//kaidansu
if cross(tasset-dangqianzich,1800) THEN zhisunch:=5;
止损位:TENTERPRICE-zhisunch,LINETHICK0;
if TENTERPRICE-zhisunch and TBUYHOLDING(1)>0 then tsell(1,0,mkt);//多清
if TENTERPRICE+zhisunch and TSELLHOLDING(1)>0 then tsellshort(1,0,mkt);//空清



亏损5个点不止损呀

 


--  作者:zm71212302
--  发布时间:2014/11/24 14:17:37
--  

zhisunch:=5;//止损常量
kaidansu:=1;//kaidansu
if cross(tasset-dangqianzich,1800) THEN zhisunch:=5;
止损位:TENTERPRICE-zhisunch,LINETHICK0;
if TENTERPRICE-zhisunch and TBUYHOLDING(1)>0 then tsell(1,0,mkt);//多清
if TENTERPRICE+zhisunch and TSELLHOLDING(1)>0 then tsellshort(1,0,mkt);//空清



亏损5个点不止损呀

 


--  作者:jinzhe
--  发布时间:2014/11/24 14:17:39
--  

这个时候你就需要用调试代码来进行调试了,而不是靠现在的猜想

用debugfile函数把你想知道数据输出一遍,看看明明目测的条件成立了但是不下单是什么原因