以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (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=78401) |
-- 作者:厚德载物生 -- 发布时间:2015/5/8 11:48:21 -- 请帮写 今日账户最大净亏损,当日停盘不再交易 请帮写 今日账户最大净亏损,当日停盘不再交易 这是 我自己写的代码,在图表模式下,正常显示运作, 但是如果套用阿火的 后台下单模版,用后台预警交易 就会出现继续开仓的情况,可是 虚拟持仓显示都为零 请各位老师指点 是不是后台下单模版 与一些图表函数或者全局变量有冲突 CYC:=BARSLAST(DATE>REF(DATE,1))+1; 账户日亏:=ref(NETPROFIT,r1+1)-NETPROFIT; 账户日亏1:=ref(asset,r1+1)-asset; DK:= 账户日亏>DAK or 账户日亏>DAK1 ; if holding=0 and c4 and TIME8 and not (DK) then begin
强转开空4:BUYSHORT(1,lots,marketr),orderqueue;
debugfile(\'D:\\00002743.txt\', \'强转开空4 %.0f\',holding ); end cc00002743:=holding;//这句放在信号稳定的地方 drawtextex(1,1,800,0,\'虚拟持仓为:\'+numtostr(cc00002743,0));//在图表上输入虚拟持仓以便监控 if not(islastbar) or workmode<>1 then exit; xiadan00002743:=cc00002743-hold; if xiadan00002743>0.5 then begin cang:=min(xiadan00002743,abs(hold)); if hold<0 then begin tsellshort(1,cang,mkt,0,0,\'00002743\'),allowrepeat; debugfile(\'D:\\00002743.txt\',numtostr(hold,0)+\' \'+numtostr(cc00002743,0)+\' 平空 %.0f\',cang); end cang:=xiadan00002743+min(hold,0); if cang>0 then begin tbuy(1,cang,mkt,0,0,\'00002743\'),allowrepeat; debugfile(\'D:\\00002743.txt\',numtostr(hold,0)+\' \'+numtostr(cc00002743,0)+\' 开多 %.0f\',cang); end end if xiadan00002743<-0.5 then begin cang:=min(abs(xiadan00002743),abs(hold)); if hold>0 then begin tsell(1,cang,mkt,0,0,\'00002743\'),allowrepeat; debugfile(\'D:\\00002743.txt\',numtostr(hold,0)+\' \'+numtostr(cc00002743,0)+\' 平多 %.0f\',cang); end cang:=abs(xiadan00002743)-max(hold,0); if cang>0 then begin tbuyshort(1,cang,mkt,0,0,\'00002743\'),allowrepeat; debugfile(\'D:\\00002743.txt\',numtostr(hold,0)+\' \'+numtostr(cc00002743,0)+\' 开空 %.0f\',cang); end end hold:=cc00002743; //注意:不勾选软件自带追单功能,此模型自带 //固定1秒轮询 if TISREMAIN(0)=1 and TSUBMIT(0)>10 then TCANCEL(1,0); //TISPRVREMAIN(N) and TISPRVREMAIN(0) if not (TISPRVREMAIN(0) <>1) then exit; cc:=holding; if holding>0 and c<ref(c,1) then sell(1,1,MARKETR); if holding<0 and c>ref(c,1) then sellshort(1,1,MARKETR); if holding=0 and c>ref(c,1) then buy(1,1,MARKETR); if holding=0 and c<ref(c,1) then buyshort(1,1,MARKETR); if not(islastbar) or workmode<>1 then exit; tm:=20;//撤单时间 ac:=\'00002743\';//下单账户 wt:=tremainqty(0,ac,stklabel); buyhold:=tbuyholdingex(ac,stklabel,1); sellhold:=tsellholdingex(ac,stklabel,1); if wt>0.5 and tsubmit(0)>tm then tcancelex(1,0,ac,stklabel);//如果用软件自带的撤单功能,这句删除。 if wt<0.5 then begin kc1:=max(cc,0)-buyhold; kc2:=abs(min(cc,0))-sellhold; if kc1<-0.5 then tsell(1,abs(kc1),mkt,0,0,ac),allowrepeat; if kc2<-0.5 then tsellshort(1,abs(kc2),mkt,0,0,ac),allowrepeat; if sellhold<0.5 and kc1>0.5 then tbuy(1,kc1,mkt,0,0,ac),allowrepeat; if buyhold<0.5 and kc2>0.5 then tbuyshort(1,kc2,mkt,0,0,ac),allowrepeat; end |
-- 作者:厚德载物生 -- 发布时间:2015/5/8 11:50:02 -- 上一段 是我不开仓的限制条件,下面两段 是图表转后台的执行代码 以后后台持仓同步代码 |
-- 作者:厚德载物生 -- 发布时间:2015/5/8 11:54:58 -- 今天的测试 我把最大亏损停盘设定成1000,用带后台下单模块 的代码运行 开始运作正常,满足条件,自动停盘 |
-- 作者:jinzhe -- 发布时间:2015/5/8 13:41:34 -- 那么10点55的时候有没有调试文档记录持仓和开仓条件的? |
-- 作者:厚德载物生 -- 发布时间:2015/5/8 14:17:31 -- 2015-05-08 09:24:41.460 开空0 -1 2015-05-08 09:24:42.970 开空0 -1 2015-05-08 09:24:44.489 开空0 -1 2015-05-08 09:24:46.426 开空0 -1 2015-05-08 09:24:46.427 0 -1 开空 1 2015-05-08 09:35:06.420 平多5 0 2015-05-08 09:35:07.942 平多5 0 2015-05-08 09:35:09.445 平多5 0 2015-05-08 09:35:10.969 平多5 0 2015-05-08 09:35:12.475 平多5 0 2015-05-08 09:35:13.984 平多5 0 2015-05-08 09:35:16.190 平多5 0 2015-05-08 09:35:16.191 -1 0 平空 1 2015-05-08 10:54:46.199 开多0 1 2015-05-08 10:54:46.200 0 1 开多 1 2015-05-08 11:20:01.661 平多4 0 2015-05-08 11:20:01.805 平多4 0 2015-05-08 11:20:02.718 平多4 0 2015-05-08 11:20:04.231 平多4 0 2015-05-08 11:20:05.744 平多4 0 2015-05-08 11:20:07.446 平多4 0 2015-05-08 11:20:08.784 平多4 0 2015-05-08 11:20:10.410 平多4 0 2015-05-08 11:20:11.798 平多4 0 2015-05-08 11:20:13.554 平多4 0 2015-05-08 11:20:16.392 平多5 0
|
-- 作者:厚德载物生 -- 发布时间:2015/5/8 14:20:14 -- 10点54分46秒开多0 很奇怪 所有开仓条件都是统一的写法 if holding=0 and c0 and TIME8 and not (DK) then begin
开空0:BUYSHORT(1,lots,marketr),orderqueue;
debugfile(\'D:\\00002743.txt\', \'开空0 %.0f\',holding ); end if holding=0 and c1 and TIME8 and not (DK) then begin
开空1:BUYSHORT(1,lots,marketr),orderqueue;
debugfile(\'D:\\00002743.txt\', \'开空1 %.0f\',holding ); end 之前也满足条件没有开仓,为何等到10点54又重新开仓》? |
-- 作者:jinzhe -- 发布时间:2015/5/8 14:24:26 -- 你是后台开仓不对吧?看看后台是怎么写的,还有再看看下单日志里面,看看是信号触发还是其他方式触发 |