查看: 2552|回复: 2

[公式] TB代码如何转换成易盛程序化语言BarsSinceEntry == 1

[复制链接]
发表于 2014-9-11 15:55:25 | 显示全部楼层 |阅读模式
vIf(BarsSinceEntry== 1)
v{
v  HigherAfterEntry = AvgEntryPrice;
v  LowerAfterEntry = HigherAfterEntry;
v}ElseIf(BarsSinceEntry > 1)
v{
v  HigherAfterEntry =Max(HigherAfterEntry[1],High[1]);
v  LowerAfterEntry =Min(LowerAfterEntry[1],Low[1]);
v}
vCommentary("HigherAfterEntry="+Text(HigherAfterEntry));
vCommentary("LowerAfterEntry="+Text(LowerAfterEntry));





 楼主| 发表于 2014-9-11 15:56:29 | 显示全部楼层
//------------------------------------------------------------------------
// 简称:Keltner_Channel
// 名称:肯特纳通道(KC)
// 类别: 交易指令
// 类型: 用户应用
//------------------------------------------------------------------------
Params
        Numeric Length(20);
        Numeric NumATRs(1);
Vars
        NumericSeries TPrice;
        Numeric AvgValue;
        NumericSeries ShiftValue;
        Numeric UpperBand;
        Numeric LowerBand;       
        Numeric MyPrice;
Begin
        TPrice = (High[1]+Low[1]+Close[1])/3;
        AvgValue = AverageFC(TPrice,Length);
        ShiftValue = NumATRs*AvgTrueRange(Length);
        UpperBand = AvgValue + ShiftValue[1];
        LowerBand = AvgValue - ShiftValue[1];       
      If(MarketPosition!=1 && High >= UpperBand)
        {
                MyPrice = UpperBand;
                If(Open > MyPrice) MyPrice = Open;
                Buy(1,MyPrice);
                Return;
        }       
        If(MarketPosition!=-1 && Low <= LowerBand)
        {
                MyPrice = LowerBand;
                If(Open < MyPrice) MyPrice = Open;
                SellShort(1,MyPrice);
                Return;
        }
        If(BarsSinceEntry == 1)
        {
                HigherAfterEntry = AvgEntryPrice;
                LowerAfterEntry = HigherAfterEntry;
        }Else If(BarsSinceEntry > 1)
        {
                HigherAfterEntry = Max(HigherAfterEntry[1],High[1]);
                LowerAfterEntry = Min(LowerAfterEntry[1],Low[1]);
        }
        Commentary("HigherAfterEntry="+Text(HigherAfterEntry));
        Commentary("LowerAfterEntry="+Text(LowerAfterEntry));
        If(MarketPosition==1)
        {
                If(Low <= HigherAfterEntry - TrailingStop*MinPoint)
                {
                        MyPrice = HigherAfterEntry - TrailingStop*MinPoint;
                        If(Open < MyPrice) MyPrice = Open;
                        Sell(1,MyPrice);
                }
        }Else If(MarketPosition == -1)
        {
                If(High >= LowerAfterEntry + TrailingStop*MinPoint)
                {
                        MyPrice = LowerAfterEntry + TrailingStop*MinPoint;
                        If(Open > MyPrice) MyPrice = Open;
                        BuyToCover(1,MyPrice);
                }
        }
       

        PlotNumeric("UpperBand",UpperBand);
        PlotNumeric("LowerBand",LowerBand);
        PlotNumeric("MidLine",AvgValue);
       
End
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-9-11 15:57:01 | 显示全部楼层
编译无法通过
回复 支持 反对

使用道具 举报

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

本版积分规则

易家网  ©2015-2023  郑州期米信息技术有限公司版权所有  豫公网安备 41010502005136号 豫ICP备16010300号