设为首页收藏本站

 找回密码
 注册
查看: 2571|回复: 1
打印 上一主题 下一主题

关于系统内置的跟踪止盈止损的程序疑问 [复制链接]

Rank: 1

精华
0
UID
131362
积分
32
帖子
20
主题
9
阅读权限
10
注册时间
2012-7-25
最后登录
2021-1-22
跳转到指定楼层
1#
发表于 2013-8-28 08:55:19 |只看该作者 |倒序浏览
请大侠们帮忙看看这个程序哪里有问题,为什么加载之后很多根K线都出现交易信号?

//------------------------------------------------------------------------
// 简称: A016
// 名称: 结算价
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------

Params//参数
            Numeric Lots(1);
                Numeric para1(4);
                Numeric TStart1(5);
                Numeric TStart2(20);
                Numeric TStop1(1);
                Numeric TStop2(10);
                Numeric SL(10);
               
Vars//变量
        NumericSeries dayavg;//量价加权平均价,即结算价。
                Numeric MinPoint;//最小波动单位
        //出入场变量
                Bool Conbuy1;//多开条件
                Bool Conbuy2;//多开条件
            Bool ConSell;//多平条件
            Bool ConSellShort1;//空开条件
                Bool ConSellShort2;//空开条件
            Bool ConBuyToCover;//空平条件
        //跟踪止损变量
                Numeric MyEntryPrice;   // 开仓价格,本例是开仓均价,也可根据需要设置为某次入场的价格
                Numeric TrailingStart1; // 保本启动
        Numeric TrailingStart2; // 跟踪止损启动设置
        Numeric TrailingStop1;  // 保本设置
        Numeric TrailingStop2;  // 跟踪止损设置
        Numeric StopLossSet;    // 止损设置
        Numeric MyExitPrice;    // 平仓价格
        NumericSeries HighestAfterEntry;        // 开仓后出现的最高价
        NumericSeries LowestAfterEntry;         // 开仓后出现的最低价

Begin
       
        MinPoint = MinMove*PriceScale;
        dayavg = AA001;
    Plotnumeric("结算价",dayavg);
        //开平仓条件
        Conbuy1=(C<dayavg+para1*MinPoint) And C[1]<dayavg[1] And C>dayavg;
        Conbuy2=(C[1]>=dayavg[1]) And (C>=dayavg) And (C<dayavg+para1*MinPoint);
        ConSell=C[1]>dayavg[1] And C<dayavg;
        ConSellShort1=(C>dayavg-para1*MinPoint) And C[1]>dayavg[1] And C<dayavg;
        ConSellShort2=(C[1]<=dayavg[1]) And (C<=dayavg) And (C>dayavg-para1*MinPoint);
        ConBuyToCover=C[1]<dayavg[1] And C>dayavg;
        //交易运行程序
        If(Time>0.0905 And Time<0.1455)
        {
            If(MarketPosition!=1 And (Conbuy1 Or Conbuy2))//多开
            {
                Buy(Lots,O[-1]);
                        PlotString("text","多开",(L-3*MinPoint),White);
            }
                If(ConSell)//多平
            {
                Sell(Lots,O[-1]);
                        PlotString("text","多平",(H+2*MinPoint),White);
            }
            If(MarketPosition!=-1 And (ConSellShort1 Or ConSellShort2))//空开
            {
                    SellShort(Lots,O[-1]);
                        PlotString("text","空开",(H+3*MinPoint),White);
            }
                If(ConBuyToCover)//空平
            {
                BuyToCover(Lots,O[-1]);
                        PlotString("text","空平",(L-2*MinPoint),White);
            }
        }
        //跟踪止盈止损程序
            MyEntryPrice = AvgEntryPrice;
                HighestAfterEntry=Highest(H, BarsSinceEntry);
                LowestAfterEntry=Lowest(L, BarsSinceEntry);
        If(MarketPosition==1) // 有多仓的情况
    {
        If(HighestAfterEntry>= MyEntryPrice + TrailingStart2*MinPoint)   // 第二级跟踪止损的条件表达式
        {
                        MyExitPrice = HighestAfterEntry - TrailingStop2*MinPoint;
                        If(Low <= MyExitPrice)
            {   
                                Sell(Lots,O[-1]);
                                PlotString("text","跟踪多平",(H+2*MinPoint),White);
                        }
            
        }else if(HighestAfterEntry >= MyEntryPrice + TrailingStart1*MinPoint)// 第一级跟踪止损的条件表达式
        {
            MyExitPrice = MyEntryPrice + TrailingStop1*MinPoint;
                        If(Low <= MyExitPrice)
            {   
                                Sell(Lots,O[-1]);
                                PlotString("text","保本多平",(H+2*MinPoint),White);
                        }
        }else if(Low <= MyEntryPrice - StopLossSet*MinPoint)//可以在这里写上初始的止损处理
        {
            Sell(Lots,O[-1]);
                        PlotString("text","多单止损",(H+2*MinPoint),White);
        }
    }else if(MarketPosition==-1) // 有空仓的情况
    {
        If(LowestAfterEntry <= MyEntryPrice - TrailingStart2*MinPoint)   // 第二级跟踪止损的条件表达式
        {
            MyExitPrice = LowestAfterEntry + TrailingStop2*MinPoint;
                        If(High >= MyExitPrice)
            {
                BuyToCover(Lots,O[-1]);
                                PlotString("text","跟踪空平",(L-2*MinPoint),White);
            }
        }else if(LowestAfterEntry <= MyEntryPrice - TrailingStart1*MinPoint)// 第一级跟踪止损的条件表达式
        {
            MyExitPrice = MyEntryPrice - TrailingStop1*MinPoint;
                        If(High >= LowestAfterEntry + TrailingStop1*MinPoint)
            {
               BuyToCover(Lots,O[-1]);
                           PlotString("text","保本空平",(L-2*MinPoint),White);
                               
            }
        }else If(High >= MyEntryPrice + StopLossSet*MinPoint)//可以在这里写上初始的止损处理
        {
            BuyToCover(Lots,O[-1]);
                        PlotString("text","空单止损",(L-2*MinPoint),White);
        }
    }
        //收盘前平仓程序
        If(Time>=0.1458)
        {
            If(MarketPosition==1)
                {
                Sell(Lots,O[-1]);
                        PlotString("text","收盘多平",(H+2*MinPoint),White);
            }
                if(MarketPosition==-1)
                {
                BuyToCover(Lots,O[-1]);
                        PlotString("text","收盘空平",(L-2*MinPoint),White);
            }
        }
End

//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2013/06/18 13:32
// 版权所有        fl1652546
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

Rank: 1

精华
0
UID
170901
积分
26
帖子
18
主题
6
阅读权限
10
注册时间
2013-8-26
最后登录
2016-9-14
2#
发表于 2015-8-12 14:59:27 |只看该作者
我也是同样的疑问,怎么会没有人回答

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-4-26 00:20

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部