打印本文打印本文 关闭窗口关闭窗口

请问老师关于日内多次突破交易的问题

作者:MC 来源:cxh99.com 发布时间:2018年05月04日
  • MC用户求助:

    关于swinghigh函数的用法,您可以先看一下帖子http://forums.icetech.com.cn/for ... &extra=page%3D1,在学习这个帖子的过程中遇到的问题可以直接在该帖子下方回帖。

     

    另外,关于您的这个策略需求,我简单在您的代码中加了几行代码,如下:

    input:btime(0930),etime(1445);

    var:thigh(0),tlow(0),mp(0);

    if date<>date[1] then begin

        mp=0;

        thigh=0;

        tlow=0;

       end;

    if time=btime then begin

        thigh=highd(0);

        tlow=lowd(0);

        end;

    mp=marketposition;

    if time>btime and time<etime then begin

        if mp=0 and close cross above thigh then begin

           buy ("b1")next bar at thigh stop;

            end;

        if mp=1 then sell("sp") next bar at tlow stop;

     

        if mp=0 and close cross under tlow then begin

            sellshort ("s1")next bar at tlow stop;

            end;

        if mp=-1 then buytocover("bp") next bar at thigh stop;

    //增加

        if mp=0 and mp[1]<>0 then begin

                thigh=highd(0);

                tlow=lowd(0);

        end;

    //增加

    {这个地方,是一个即时的代码,也就是当前一根bar上持仓,而当根bar未持仓,那么重新赋值thigh和tlow,后续的进场会根据这两个新的值进行进场和出场了}

    end;

     

  • MC回复讨论一:

    关于swinghigh函数的用法,您可以先看一下帖子http://forums.icetech.com.cn/for ... &extra=page%3D1,在学习这个帖子的过程中遇到的问题可以直接在该帖子下方回帖。

     

    另外,关于您的这个策略需求,我简单在您的代码中加了几行代码,如下:

    input:btime(0930),etime(1445);

    var:thigh(0),tlow(0),mp(0);

    if date<>date[1] then begin

        mp=0;

        thigh=0;

        tlow=0;

       end;

    if time=btime then begin

        thigh=highd(0);

        tlow=lowd(0);

        end;

    mp=marketposition;

    if time>btime and time<etime then begin

        if mp=0 and close cross above thigh then begin

           buy ("b1")next bar at thigh stop;

            end;

        if mp=1 then sell("sp") next bar at tlow stop;

     

        if mp=0 and close cross under tlow then begin

            sellshort ("s1")next bar at tlow stop;

            end;

        if mp=-1 then buytocover("bp") next bar at thigh stop;

    //增加

        if mp=0 and mp[1]<>0 then begin

                thigh=highd(0);

                tlow=lowd(0);

        end;

    //增加

    {这个地方,是一个即时的代码,也就是当前一根bar上持仓,而当根bar未持仓,那么重新赋值thigh和tlow,后续的进场会根据这两个新的值进行进场和出场了}

    end;

打印本文打印本文 关闭窗口关闭窗口