以多头图表为例:
[PEL] 复制代码
//建议运行在小周期线,周线的数据通过调用获取
w_c_1:callstock('',vtclose,7,-1);//上周收盘价
w_o_1:callstock('',vtopen,7,-1);//上周开盘价
价差:abs(w_o_1-w_c_1);//价差绝对值
kp:ref(isweekend=1,1);//当前是本周第一个k
//开多
if kp and holding=0 then buy(1,1,limitr,o);
if c-avgenterprice>=价差 then 止盈:sell(1,0,MARKETR);
if avgenterprice-c>=价差 then 止损:sell(1,0,MARKETR);
//本周最后一个交易日 尾盘清仓
if isweekend=1 and time=CLOSETIME(0) then 本周清仓:sell(1,0,marketr);
建议是运行在小周期上,否则在大周期上不好区分最高最低先出现,这会影响到图表止盈止损信号出现的顺序。 |