[PEL] 复制代码
//定义全局变量并初始化为0. 控制日内突破开仓只开1次variable:num=0;
n1:=barslast(date<>ref(date,1))+1;
preDayLow:=ref(LLv(L,n1),n1); //昨日最低价
Dayopen:=valuewhen(Todaybar=1,o); //当天开盘价
//交易条件
BuyCond:=Dayopen<preDayLow and High>=preDayLow; //开多条件
//下单模块
temp:=todaybar;
if BuyCond and holding=0 and num=0 then
begin
buy(1,1,market);
n:=temp; //记录开仓k线位置
num:=1;
End
ll:=valuewhen(todaybar=n,llv(l,n)); //开盘到开仓时的最低价
//交易条件
SellCond:=low<ll; //平多条件
//下单模块
if SellCond and holding>0 then sell(1,1,market);
//收盘前5分钟平仓
M5:=t0totime(timetot0(closetime(0))-60*5); //收盘前5分钟
if time>=M5 and holding>0 then sell(1,1,market);
if time=closetime(0) then num:=0; //收盘时赋值为0