15500390629 发表于 2017-7-18 09:23:08

求助 老师

可以帮忙加个止盈吗 分别以开仓价2点4点6点逐步平仓 学生跪谢了
//------------------------------------------------------------------------
// 简称: CL_JailBreakSys_L
// 名称: 基于价格区间突破的交易系统
// 类别: 公式应用
// 类型: 内建应用
// 输出:
// 策略说明:                基于通道突破的判断
// 系统要素:
//                                1. 计算10根k线最高价的区间
//                                2. 计算6根k线最低价的区间
//                               
// 入场条件:
//                            1.价格高于10根K线最高价的区间入场
// 出场条件:
//                                1. 当前价格低于6根K线最低价的区间出场
//                                2. 当前价格低于入场价一定ATR波动率幅度出场
//
//----------------------------------------------------------------------//
Params
        Numeric Length1(10);                                                                //长周期区间参数
        Numeric Length2(6);                                                                //短周期区间参数
        Numeric IPS(4);                                                                                //保护止损波动率参数
        Numeric AtrVal(10);                                                                        //波动率参数
Vars
        NumericSeries ProtectStopL;
        NumericSeries ATR;
        NumericSeries Upperband;
        NumericSeries Lowerband;
        NumericSeries Exitlong;
        NumericSeries Exitshort;
        Numeric L2;
        Numeric L1;
        Numeric Minpoint;
Begin

        // 集合竞价
        If(BarStatus == 2 And IsCallAuctionTime) Return;
       
        Minpoint = Minmove*PriceScale;
    ATR = AvgTrueRange(AtrVal);                                                     //定义ATR
        L1 = Max(Length1,Length2);                                                     //出场周期选择较大的区间参数
        L2 = Min(Length1,Length2);                                                     //出场周期选择较小的区间参数
        Upperband = Highest(High, L1);                                             //长周期最高价区间
        Lowerband = lowest(Low,L1);                                                       //长周期最低价区间
        Exitlong = Lowest(Low,L2);                                                     //短周期最低价区间
        Exitshort = Highest(high,L2);                                             //短周期最高价区间
       
        //系统入场
        If(Marketposition == 0 and High >= Upperband + Minpoint And Vol > 0)             //价格大于长周期最高价区间入场做多
        {
                Buy(0, Max(Open, Upperband + Minpoint));
                ProtectStopL = Entryprice - IPS*ATR;
        }
       
        //系统出场
        If(MarketPosition == 1 and BarsSinceEntry >0 And Vol > 0)
        {
                If( Low <= ProtectStopL and ProtectStopL >= Exitlong)  //价格低于入场价以下一定ATR幅度止损
                {
                        Sell (0,Min(Open,ProtectStopL));
                }
                Else if (Low <= Exitlong - Minpoint)                    //价格低于短周期最低价区间出场
                {
                        Sell(0, Min( Open, Exitlong - Minpoint));
                }
        }

End

15500390629 发表于 2017-7-21 13:24:31

:):)

stillseven 发表于 2017-7-22 14:03:15

这个简单啊。。
页: [1]
查看完整版本: 求助 老师