如果是走完k线下单模式那么就这样写
if c>o then buy......;
if holding>0 and close<enterprice then begin
sell........;
buyshort......;
end
if c<o then buyshort.......;
if holding<0 and close>enterprice then begin
sellshort.........;
buy......;
end
如果是固定时间间隔模式那么就这样写
if h>o then buy......;
if holding>0 and l<enterprice then begin
sell........;
buyshort......;
end
if l<o then buyshort.......;
if holding<0 and h>enterprice then begin
sellshort.........;
buy......;
end
说明 |
交易系统之开多操作 |
语法 |
BUY(COND,V,Type,P);表示当COND条件成立时, 买入V股(手)当前品种,TYPE表示买入类型, P表示买入价格,所有参数均可以省略。 V:买入股(手)数或买入资金百分比(N%),若为0或者省略表示100%; TYPE:可以是本周期收盘(THISCLOSE),市价(MARKET), 限价单(LIMIT),停损单(STOP)等交易方式控制符; P:对于限价单、停损单需要指定的买入价格 |
参数 |
|
备注 |
该函数仅在逐K线计算模式下有效 |
示例 |
BUY(C>O ,1000,THISCLOSE);表示收阳线则在本周期收盘价上买入1000股(手)。 BUY(C>0,50%,LIMIT,CLOSE-0.2);表示在指定限价CLOSE-0.2元位置下买入限价单, 若价格达到或低于该价格则用50%资金买入。 |
所属函数组 |
交易系统 |
if h>o then buy(C>O ,1000,THISCLOSE);
if holding>0 and l<enterprice then begin
sell(C<O ,1000,THISCLOSE);
buyshort(C<O ,1000,THISCLOSE);
end;
if l<o then buyshort(C<O ,1000,THISCLOSE);
if holding<0 and h>enterprice then begin
sellshort(C>O ,1000,THISCLOSE);
buy(C>O ,1000,THISCLOSE);
end;
您这种是选用2楼固定轮询的写法,为什么又掺杂了走完K的(c>o,c<o),
我把它换成了holding=0,holding<0,holding>0的判断
平多后立马开空 或平空后立马开多就叫反手
if h>o then buy(holding=0 ,1000,THISCLOSE);
if holding>0 and l<enterprice then begin
sell(holding>0 ,1000,THISCLOSE);//平多
buyshort(holding=0 ,1000,THISCLOSE);//反手开空
end;
if l<o then buyshort(holding=0 ,1000,THISCLOSE);
if holding<0 and h>enterprice then begin
sellshort(holding<0 ,1000,THISCLOSE);//平空
buy(holding=0 ,1000,THISCLOSE);//反手开多
end;
老师我的意思是每一根k线都要有信号,谢谢。
比如当根K线开盘上涨做多,下一根K线如果继续上涨还是做多直至有一根K线下跌就反手做空。
把holding持仓判断换成1,只有if 条件成立 就会开平仓,每根k都有信号
if h>o then buy(1,1000,THISCLOSE);
if holding>0 and l<enterprice then begin
sell(1 ,1000,THISCLOSE);//平多
buyshort(1 ,1000,THISCLOSE);//反手开空
end;
if l<o then buyshort(1 ,1000,THISCLOSE);
if holding<0 and h>enterprice then begin
sellshort(1 ,1000,THISCLOSE);//平空
buy(1,1000,THISCLOSE);//反手开多
end;