交易者工具网 全系列交易软件

初级突破策略

策略原理:
取开盘之后到0945之前的最高跟最低,作为上下轨,当后面的行情突破上轨买入,突破下轨卖出,收盘前平仓出场,没设止损,每天限制买或者卖出只有一次。策略比较适合单边行情商品。
测试商品股指IF,周期为5 min。
 
源码如下:
Input:Btime(0945),Etime(1500);     
//定义输入型参数,开始跟结束时间
var:Thigh(0),Tlow(0),mp(0),x(0),y(0);  
//定义变量,上轨高点,下轨低点,持仓,x,y进出场几次控制
if date<>date[1]then begin
    mp=0;
    x=0;
    y=0;
    Thigh=0;
    Tlow=0;
end;
//每天给变量重新赋值
 
if time=Btime then begin
   Thigh=highD(0);
   Tlow=lowD(0);
end;
//取到开盘后0945之前的最高跟最低值,作为上下轨,当后续行情突破上轨买入,突破下轨卖出,收盘平仓,
 
mp=marketposition;
if mp[1]<>1 and mp=1 then begin
   x=1;
end;
//定义x值限制开仓次数
if mp[1]<>-1 and mp=-1 then begin   
   y=1;
end;
//定义y值,限制开仓次数


if time>Btime and time
if marketposition=0 and x<1 and close
crosses above Thigh then buy ("b1")next bar at Thigh+1 stop;
//条件满足未持仓且突破上轨则开多单
if marketposition=0 and y<1 and close
crosses below Tlow then sellshort("s1")  
next bar at Tlow-1 stop;
//条件满足未持仓且突破下轨则开空单
end;
 
if time>=1455 and marketposition<0 then
buytocover next bar at market;
if time>=1455 and marketposition>0 then
sell next bar at market;
//在1455(收盘前)平仓出场语句

浏览:1768
编辑: 管理员 2021/02/23

网站介绍 联系我们 免责条款 需求留言 移动版 备案号:粤ICP备2020139393号 公安部备案号:44030402004391 版权所有@深圳磊金量化科技有限公司