Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共24 条记录, 每页显示 10 条, 页签: [1] [2][3]
[浏览完整版]

标题:这个图表程序化要怎么改成后台程序化

1楼
zqs0595 发表于:2016/11/9 16:30:39

一分钟级别的策略,里面有调15分钟级别的指标

 

input:shakeRate(1,0.3,20,2);  

orderNum:=ROUNDS(ASSET/200/c,0); 

begintime:=(time>010300 and time<031000) or (time>130300 and time<184000);
endtime:=(time>032950 and time<033000) or (time>185950 and time<190000);

VARIABLE:cond:='none';   
VARIABLE:pbxGoldPlus:='false';
VARIABLE:pbxDeadPlus:='false';
VARIABLE:pbxCond:='none';
VARIABLE:pbxCondPre:='none';
VARIABLE:outPrice:=0;

ma10:=ma(c,150);
last2h:=hhv(h,30);
last2l:=llv(l,30);

 

DIFF:=STKINDI('','MACD.DIFF',0,3);
DEA:=STKINDI('','MACD.DEA',0,3);

 

D1:STKINDI('','PBX.D1',0,3);
D2:STKINDI('','PBX.D2',0,3);
Z1:STKINDI('','PBX.Z1',0,3);
Z2:STKINDI('','PBX.Z2',0,3);
C1:STKINDI('','PBX.C1',0,3);
C2:STKINDI('','PBX.C2',0,3);

pbxGoldPlus:='false';
pbxDeadPlus:='false';

 

TR1:=STKINDI('','ATR.TR1',0,3);
ATR:=STKINDI('','ATR.ATR',0,3);

if HOLDING>0 and h>outPrice then outPrice:=h;
if HOLDING<0 and l<outPrice then outPrice:=l;

macdGoldPlus:=CROSS(DIFF,DEA);
macdDeadPlus:=CROSS(DEA,DIFF);

//多头仓位平仓 
if HOLDING>0 and (macdDeadPlus or pbxDeadPlus='true' or endtime or c<ma10 or c<outPrice-2*ATR) then begin
    SELL(1,HOLDING,MARKET); 
end

//空头仓位平仓
if HOLDING<0 and (macdGoldPlus or pbxGoldPlus='true' or endtime or c>ma10 or c>outPrice+2*ATR) then begin
    SELLSHORT(1,HOLDING,MARKET);
end

//开多

if HOLDING=0 and ((DIFF>DEA and pbxGoldPlus='true') or (macdGoldPlus='true' and pbxC))
   and begintime and (c-last2l)*100/last2l<shakeRate then begin
    BUY(1,orderNum,MARKET);

end

//开空  

if HOLDING=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
   and begintime and (last2h-c)*100/last2h<shakeRate then begin   
    BUYSHORT(1,orderNum,MARKET);

end

pbxCondPre:=pbxCond;

2楼
jinzhe 发表于:2016/11/9 16:47:03

input:shakeRate(1,0.3,20,2);  

orderNum:=ROUNDS(ASSET/200/c,0); 

begintime:=(time>010300 and time<031000) or (time>130300 and time<184000);
endtime:=(time>032950 and time<033000) or (time>185950 and time<190000);

globalVARIABLE:cond:='none';   
globalVARIABLE:pbxGoldPlus:='false';
globalVARIABLE:pbxDeadPlus:='false';
globalVARIABLE:pbxCond:='none';
globalVARIABLE:pbxCondPre:='none';
globalVARIABLE:outPrice:=0;

ma10:=ma(c,150);
last2h:=hhv(h,30);
last2l:=llv(l,30);

 

DIFF:=STKINDI('','MACD.DIFF',0,3);
DEA:=STKINDI('','MACD.DEA',0,3);

 

D1:STKINDI('','PBX.D1',0,3);
D2:STKINDI('','PBX.D2',0,3);
Z1:STKINDI('','PBX.Z1',0,3);
Z2:STKINDI('','PBX.Z2',0,3);
C1:STKINDI('','PBX.C1',0,3);
C2:STKINDI('','PBX.C2',0,3);

pbxGoldPlus:='false';
pbxDeadPlus:='false';


 

TR1:=STKINDI('','ATR.TR1',0,3);
ATR:=STKINDI('','ATR.ATR',0,3);

if tbuyHOLDING(0)>0 and h>outPrice then outPrice:=h;
if tsellHOLDING(0)>0 and l<outPrice then outPrice:=l;

macdGoldPlus:=CROSS(DIFF,DEA);
macdDeadPlus:=CROSS(DEA,DIFF);

//多头仓位平仓 
if tbuyHOLDING(0)>0 and (macdDeadPlus or pbxDeadPlus='true' or endtime or c<ma10 or c<outPrice-2*ATR) then begin
    tSELL(1,0,mkT); 
end

//空头仓位平仓
if tsellHOLDING(0)>0 and (macdGoldPlus or pbxGoldPlus='true' or endtime or c>ma10 or c>outPrice+2*ATR) then begin
    tSELLSHORT(1,0,mkt);
end

//开多

if tbuyHOLDING(0)=0 and ((DIFF>DEA and pbxGoldPlus='true') or (macdGoldPlus='true' and pbxC))
   and begintime and (c-last2l)*100/last2l<shakeRate then begin
    tBUY(1,orderNum,mkt);

end

//开空 

if tsellHOLDING(0)=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
   and begintime and (last2h-c)*100/last2h<shakeRate then begin   
    tBUYSHORT(1,orderNum,mkt);

end

pbxCondPre:=pbxCond;

3楼
zqs0595 发表于:2016/11/9 17:00:58
我这个代码会复制成几份,修改参数后分别监控不同的品种,如果用globalVARIABLE,策略间相同的变量会冲突吗?
4楼
jinzhe 发表于:2016/11/9 17:01:36

不会冲突,机制上和variable差不多,后台里面不会互相冲突

5楼
zqs0595 发表于:2016/11/10 8:59:41
globalVARIABLE和工具-》数据管理-》全局变量里面的那些有什么区别啊?
6楼
jinzhe 发表于:2016/11/10 9:08:54
这里的全局变量是全软件通用的,不管是哪个策略获取的全局变量都是同一个
7楼
jinzhe 发表于:2016/11/10 9:09:59

比如这里的A1,不管在哪个策略里面,用extgbdata('A1') 获取的全局变量一定是同一个值


图片点击可在新窗口打开查看此主题相关图片如下:2.png
图片点击可在新窗口打开查看
8楼
zqs0595 发表于:2016/11/11 9:21:07

我把上面的这段代码加了一些日志打印,可是一出信号,为什么后台日志不是只打出一条,而是一秒内打出非常多条

//开空  
if EXTGBDATA('PBMACD_MA_SELL')=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
   and (last2h-c)*100/last2h<shakeRate then begin   
    TBUYSHORT(1,orderNum,mkt);
    EXTGBDATASET('PBMACD_MA_SELL',orderNum);
    DEBUGFILE2(logFilePath,'b_pbMacd_MA:甲醇开空',1,1);
    DEBUGFILE2(logFilePath,'b_pbMacd_RB:数量=%.0f',orderNum,1);  
    cond:='buy';
    outPrice:=l;
end

 

2016-11-10 21:50:01.855    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871    b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871    b_pbMacd_MA:甲醇开空

9楼
jinzhe 发表于:2016/11/11 9:41:51

因为你用的是debugfile2,这个是逐k打印的,后台监控了多少根k线,那么每来一笔行情就会输出对应的多少条件信息

你要用debugfile来输出

10楼
zqs0595 发表于:2016/11/11 10:03:39
那需不需要在开平仓前面加上IF ISLASTBAR判断来过滤,以免一直下单
共24 条记录, 每页显示 10 条, 页签: [1] [2][3]


Powered By Dvbbs Version 8.3.0
Processed in 0.03101 s, 3 queries.