1.设置股票池代码,然后用股票池进行选择
股票池条件:(ref(ref(hhv(h,todaybar),todaybar),todaybar)>ref(ref(close,todaybar),todaybar)*1.1) or (ref(hhv(h,todaybar),todaybar)>ref(ref(ref(close,todaybar),todaybar),todaybar)*1.1);
2.将选择出的股票池再后台上进行监控,然后用后台交易进行买卖,代码如下:
为了达到引用的目的,需要建立两个策略,第一个为被引用策略,命名为:公式1,这个公式不做后台交易
公式1:
hh:hhv(h,5);
然后另外新建一个策略,这个是实际的交易策略:
if ref(close,todaybar)>stkindi('','公式1.hh',0,6,-2) and open<ref(close,todaybar)*1.1 then tbuy(1,这里写下单数量,mkt);
if tbuyholding(0)>0 and (dynainfo(7)-tenterprice)/tenterprice>0.1 then tsell(1,0,mkt);