以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  老师,图表怎么修改编写成后台交易的  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=69496)

--  作者:一叶知秋
--  发布时间:2014/9/2 9:46:57
--  老师,图表怎么修改编写成后台交易的

老师 请帮忙改一下,图表交易的转化为后台交易的,应该修改编写

 

 


DIFF := EMA(CLOSE,360) - EMA(CLOSE,1440);
DEA  := EMA(DIFF,160);
macd_M5:= 2*(DIFF-DEA);

 

 MA1:MA(C,60),COLORRED;

 

S:= ABS(MA1-H)<=12*mindiff;

 

n:=10;//加仓次数
x:=3;//建仓手数
w:=5;

 

kong:=S  and macd_m5<0 ;

 

 


if kong then buyshort(holding=0,x,market);

if kong and ENTERPRICE-C>=w*MINDIFF and abs(holding)=x  then  buyshort(1,x,market);

if kong  and  ENTERPRICE-C>=w*MINDIFF and abs(holding)=2*x then  buyshort(1,x,market);

if kong  and  ENTERPRICE-C>=w*MINDIFF and abs(holding)=3*x then  buyshort(1,x,market);

if kong  and  ENTERPRICE-C>=w*MINDIFF and abs(holding)=4*x then  buyshort(1,x,market);

if kong  and  ENTERPRICE-C>=w*MINDIFF and abs(holding)=5*x then  buyshort(1,x,market);
 


 if   macd_m5>0 and holding<0 then sellshort(1,0,market);//平空
 


--  作者:jinzhe
--  发布时间:2014/9/2 9:55:45
--  

前面的不变,后面的修改如下:

if kong then tbuyshort(tholding=0,x,mkt);

if kong and tENTERPRICE-C>=w*MINDIFF and abs(tholding)=x  then  tbuyshort(1,x,mkt);

if kong  and  tENTERPRICE-C>=w*MINDIFF and abs(tholding)=2*x then  tbuyshort(1,x,mkt);

if kong  and  tENTERPRICE-C>=w*MINDIFF and abs(tholding)=3*x then  tbuyshort(1,x,mkt);

if kong  and  tENTERPRICE-C>=w*MINDIFF and abs(tholding)=4*x then  tbuyshort(1,x,mkt);

if kong  and  tENTERPRICE-C>=w*MINDIFF and abs(tholding)=5*x then  tbuyshort(1,x,mkt);
 


 if   macd_m5>0 and tholding<0 then tsellshort(1,0,mkt);//平空


--  作者:一叶知秋
--  发布时间:2014/9/2 9:59:58
--  
老师 问下 后台交易的 是在逐K线计算模式下 还是序列模式
--  作者:jinzhe
--  发布时间:2014/9/2 10:12:49
--  
一般序列,除非有特殊的函数,才会用到逐k
--  作者:一叶知秋
--  发布时间:2014/9/2 14:11:54
--  
老师 就上面那个策略,我放在后台交易,为什么 会开仓了就马上平仓
--  作者:jinzhe
--  发布时间:2014/9/2 14:16:44
--  
平仓 条件满足
--  作者:一叶知秋
--  发布时间:2014/9/2 14:17:20
--  
和图表的对不上
--  作者:一叶知秋
--  发布时间:2014/9/2 14:24:59
--  
图表交易的还没有平仓 ,后台交易的就平仓了,一样的策略
--  作者:jinzhe
--  发布时间:2014/9/2 14:31:34
--  
不要用图表来判断后台
--  作者:jinzhe
--  发布时间:2014/9/2 14:31:57
--  
后台交易说明后台的条件满足了,图表没交易说明图表没出信号