日内高低点突破交易系统参考

来源:互联网 发布:大数据测试技术 编辑:程序博客网 时间:2024/04/27 14:02
  • 日内高低点突破交易系统

    //------------------------------------------------------------------------
    // 简称: todayHLCross
    // 名称:
    // 类别: 交易指令
    // 类型: 其他
    // 输出:
    //------------------------------------------------------------------------
    /*
            日内开盘区高低点机械突破系统
    */
    Params
            Numeric maxLots(1);//单次开仓手数
            Numeric maxTrad(4);//最大交易次数
            Numeric minSpt(15);//最小开仓间隔bar数
            Numeric splitRate(3); //交易滑点和佣金        
            
            Numeric tradBegin(930); //开仓时间        
            Numeric tradEnd(1430); //开仓截止时间        
            Numeric closeTime(1457); //bar的时间超过此值后平仓,一分钟交易=1457        

    Vars
            Numeric splitDot;        //交易滑点
            
            Bool bc(False);//开多条件
            Bool sc(False);//开空条件
            
            Numeric tradePrice(0);

            NumericSeries hh;
            NumericSeries ll;

    Begin
            splitDot=splitRate*MinMove();
            
            If(BarStatus==0)
            {
                    hh=High;
                    ll=Low;
                    Return;
            }
            
            if(Day !=Day[1])
            {
                    hh=High;
                    ll=Low;                }        
            Else        
            If(Time<0.0001*tradBegin)
            {
                    if(High>hh[1]) hh=High; Else        hh=hh[1];
                    if(Low<ll[1])         ll=Low;  Else        ll=ll[1];               
            }
            Else
            if(Time>=0.0001*tradBegin And Time<=0.1500)
            {
                    hh=hh[1];
                    ll=ll[1];               
                   
                    //穿越模式
                    bc=CrossOver(Open,hh) Or CrossOver(High,hh) Or CrossOver(Low,hh)  Or CrossOver(Close,hh) ;
                    sc=CrossUnder(Open,ll) Or CrossUnder(High,ll) Or CrossUnder(Low,ll) Or CrossUnder(Close,ll);        
                   
                    if(MarketPosition == 0)
                    {
                            // 当前无仓,开始建立多头
                            if(bc)
                            {
                                    if(BarStatus==2)        tradePrice= Q_AskPrice +splitDot; Else tradePrice=hh+splitDot;
                                    Buy(maxLots,tradePrice);
                            }
                            Else
                            // 当前无仓,开始建立空头
                            If(sc )
                            {
                                    if(BarStatus==2)tradePrice= Q_BidPrice -splitDot; Else tradePrice=ll-splitDot;                        
                                    SellShort(maxLots,tradePrice);                                
                            }
                    }
                    //-----------------------------------------------------------------------------
                    Else
                    {
                            if(MarketPosition > 0 )
                            {
                                    // 当前多仓,加仓多头
                                    if(bc And BarsSinceLastEntry>minSpt)
                                    {
                                            if(BarStatus==2)        tradePrice= Q_AskPrice +splitDot; Else tradePrice=hh+splitDot;
                                            Buy(maxLots,tradePrice);
                                    }                        
                                    // 当前多头,要求反转为空头
                                    if(sc)
                                    {
                                            if(BarStatus==2)tradePrice= Q_BidPrice -splitDot; Else  tradePrice=ll-splitDot;                                       

                                            // 平多头开空
                                            SellShort(maxLots,tradePrice);                                       
                                    }                                       
                                    //持仓处理,止损止盈平仓
                                    //........
                            }
                            //-----------------------------------------------------------------------------------------------
                            Else
                            if(MarketPosition < 0 )
                            {        
                                    // 当前空仓,加空头
                                    If(sc And BarsSinceLastEntry>minSpt)
                                    {
                                            if(BarStatus==2)tradePrice= Q_BidPrice -splitDot; Else tradePrice=ll-splitDot;                        
                                            SellShort(maxLots,tradePrice);
                                    }                        
                                    // 当前空头,要求反转为多头
                                    if(bc)
                                    {
                                            if(BarStatus==2)        tradePrice= Q_AskPrice +splitDot; Else  tradePrice=hh+splitDot;                                
                                            //平空头,开多
                                            Buy(maxLots,tradePrice);
                                    }                                
                                    //持仓处理,止损止盈平仓                                
                                    //........
                            }
                    }               
            }
    End

    //------------------------------------------------------------------------
    // 编译版本        GS2004.06.12
    // 用户版本        2008/11/18 18:49
    // 版权所有        fish0451
    // 更改声明        TradeBlazer Software保留对TradeBlazer平台
    //                        每一版本的TrabeBlazer公式修改和重写的权利
    //------------------------------------------------------------------------

     

  • 网友回复: 

    2定义时间段内高低点的函数:


    vars
         NumericSeries TmpHiLine;
    Begin
        If(Date!=Date[1])
        {
            TmpHiLine = InvalidNumeric;
        }else
        {
            TmpHiLine = TmpHiLine[1];
        }

        If(Time >= 0.1100 && Time <= 0.1120)
        {
             If(TmpHiLine  == InvalidNumeric )
                   TmpHiLine = High;
             else
                   TmpHiLine = max(High,TmpHiLine );
        }   
       
       PlotNumeric("MyHighLine",TmpHiLine );
    End




     
  • 一个30分钟突破的日内系统

    这个系统我认为缺乏一个有效的过滤器会造成很多无效突破,在过滤器中最简单有效的是交易时段过滤器正如我前面提到的有效突破总是集中在一天中的某一时段呈正态分布向两边展开。通过时间过滤器可以大大提高系统的成功率和稳定性。希望高手添加一下。



    Params
            Numeric nMins(30);                // N分钟的突破
        Numeric nOffset(3);                // 突破式的价格偏移
    Vars
            NumericSeries HighestOf30Min;
        NumericSeries lowestOf30Min;
        Numeric myPrice;
        Numeric MinPoint;
        Numeric lots(1);
    Begin
            MinPoint = MinMove*PriceScale;
            If(Date <> Date[1])
            {
                    HighestOf30Min = High;
                    lowestOf30Min = Low;
            }Else If(Time < 0.0900+nMins*0.0001)
            {
                    HighestOf30Min = max(high,HighestOf30Min[1]);
                    lowestOf30Min = min(Low,lowestOf30Min[1]);
            }Else
            {
                    HighestOf30Min = HighestOf30Min[1];
                    lowestOf30Min = lowestOf30Min[1];
            }
            
            If(High >= HighestOf30Min + nOffset*MinPoint && MarketPosition != 1)
            {
                    myPrice = HighestOf30Min + nOffset*MinPoint;
                    If(Open > myPrice) myPrice = Open;
                    Buy(lots,myPrice);
            }

            If(Low <= lowestOf30Min - nOffset*MinPoint && MarketPosition != -1)
            {
                    myPrice = lowestOf30Min - nOffset*MinPoint;
                    If(Open < myPrice) myPrice = Open;
                    SellShort(lots,myPrice);
            }

            If(Time >= 0.1459)
            {
                    Sell(lots,Open);
                    BuyToCover(lots,Open);
            }
    End
原创粉丝点击