请老师办我看下多级止盈要怎么实现,第一个程序的一级可以正常实现,第二个程序的多级止盈实现不了

Params

Numeric StartWinPoint(180);        //启动止盈跳数
    Numeric WinRetracementPoint(180);  //盈利回撤跳数
    Numeric WinRetracementRate(0.3);   //盈利回撤比例

Vars

Series<Numeric> StopLossPrice;
    Series<Numeric> HigherAfterEntry;
    Series<Numeric> LowerAfterEntry;
    Series<Numeric> myEntryPrice;
    Series<Numeric> RetracementPoint;
    Series<Numeric> RetracementRate;
    Series<Numeric> MinPoint;       //1跳点位
    Series<Numeric> MaxWinPoint;

Events

//开始跟踪止盈
        //记录入场后的最高价和最低价
        //------------------------------------------------------------------------------------------------
        If(MarketPosition == 1 && BarsSinceentry >=1)
        {
            HigherAfterEntry = Highest(High,BarsSinceentry);    
            //PlotNumeric("HigherAfterEntry",HigherAfterEntry);
            
        }else If(MarketPosition == -1 && BarsSinceentry >=1)
        {    
            LowerAfterEntry = Lowest(Low,BarsSinceentry);
            //PlotNumeric("LowerAfterEntry",LowerAfterEntry);        
        }
        If(BarsSinceentry>0)
        {
            Commentary("MinPoint:"+Text(MinPoint)+"点");
            //myEntryPrice=EntryPrice;
            Commentary("myEntryPrice:"+Text(myEntryPrice) );
            Commentary("BarsSinceentry:"+Text(BarsSinceentry) );
            If (MarketPosition == 1) Commentary("HigherAfterEntry:"+Text(HigherAfterEntry[1]) );
            If (MarketPosition ==-1) Commentary("LowerAfterEntry:"+Text(LowerAfterEntry[1]) );
        }
        
        //计算盈利回撤跳数和回撤比例
        If(MarketPosition == 1 && BarsSinceentry >0 )
        {
            MaxWinPoint=(HigherAfterEntry[1]-myEntryPrice)/ MinPoint;
            RetracementPoint = (HigherAfterEntry[1]-Low)/ MinPoint ;
            RetracementRate =RetracementPoint/MaxWinPoint;
            Commentary("MaxWinPoint:"+Text(MaxWinPoint) );
            Commentary("RetracementPoint:"+Text(RetracementPoint));
            Commentary("RetracementRate:"+Text(RetracementRate));
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate) And MaxWinPoint>=StartWinPoint)
            
            {
                Commentary("多头止盈");
                Sell(0,Low);    //多头止盈
                LongCurrentContracts=0;
                
                //反手操作
                If (LotsBackhand>0 And Not CloseBefore)
                {
                    LotsIni=LotsBackhand;
                    Commentary("多头止盈后反手做空");
                    SellShort(LotsIni,Low);
                    myEntryPrice=Low;
                    LowerAfterEntry=Low;
                    ShortCurrentContracts=LotsIni;
                    Return;
                }
            }
            
            
        }else If(MarketPosition == -1 && BarsSinceentry >0)
        {
            MaxWinPoint=(myEntryPrice-LowerAfterEntry[1])/ MinPoint ;
            RetracementPoint = (High-LowerAfterEntry[1])/ MinPoint;
            RetracementRate =RetracementPoint/MaxWinPoint;
            Commentary("MaxWinPoint:"+Text(MaxWinPoint));
            Commentary("RetracementPoint:"+Text(RetracementPoint));
            Commentary("RetracementRate:"+Text(RetracementRate));    
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate) And MaxWinPoint>=StartWinPoint )
            {
                Commentary("空头止盈");
                
                BuyToCover(0,High);    //空头止盈
                ShortCurrentContracts=0;
                //反手操作
                If (LotsBackhand>0 And Not CloseBefore)
                {
                    LotsIni=LotsBackhand;
                    Commentary("空头止盈后反手做多");
                    Buy(LotsIni,High);
                    myEntryPrice=High;
                    HigherAfterEntry=High;
                    LongCurrentContracts=LotsIni;
                    Return;
                }
            }
        }
        //跟踪止盈结束
 上面的一止盈正常,下面的4级止盈不能正常止盈,请老师帮忙看下。  

 

 

 

Params

Numeric StartWinPoint1(30);        //启动止盈跳数
    Numeric WinRetracementPoint(180);  //盈利回撤跳数
    Numeric WinRetracementRate1(0.9);   //盈利回撤比例
    Numeric StartWinPoint2(60);        //启动止盈跳数
    Numeric WinRetracementRate2(0.7);   //盈利回撤比例
    Numeric StartWinPoint3(120);        //启动止盈跳数
    Numeric WinRetracementRate3(0.5);   //盈利回撤比例
    Numeric StartWinPoint4(200);        //启动止盈跳数
    Numeric WinRetracementRate4(0.3);   //盈利回撤比例

Vars

Series<Numeric> StopLossPrice;
    Series<Numeric> HigherAfterEntry;
    Series<Numeric> LowerAfterEntry;
    Series<Numeric> myEntryPrice;
    Series<Numeric> RetracementPoint;
    Series<Numeric> RetracementRate;
    Series<Numeric> MinPoint;       //1跳点位
    Series<Numeric> MaxWinPoint;

Events

//开始跟踪止盈
        //记录入场后的最高价和最低价
        //------------------------------------------------------------------------------------------------
        If(MarketPosition == 1 && BarsSinceentry >=1)
        {
            HigherAfterEntry = Highest(High,BarsSinceentry);    
            //PlotNumeric("HigherAfterEntry",HigherAfterEntry);
            
        }else If(MarketPosition == -1 && BarsSinceentry >=1)
        {    
            LowerAfterEntry = Lowest(Low,BarsSinceentry);
            //PlotNumeric("LowerAfterEntry",LowerAfterEntry);        
        }
        If(BarsSinceentry>0)
        {
            Commentary("MinPoint:"+Text(MinPoint)+"点");
            //myEntryPrice=EntryPrice;
            Commentary("myEntryPrice:"+Text(myEntryPrice) );
            Commentary("BarsSinceentry:"+Text(BarsSinceentry) );
            If (MarketPosition == 1) Commentary("HigherAfterEntry:"+Text(HigherAfterEntry[1]) );
            If (MarketPosition ==-1) Commentary("LowerAfterEntry:"+Text(LowerAfterEntry[1]) );
        }
        
        //计算盈利回撤跳数和回撤比例
        If(MarketPosition == 1 && BarsSinceentry >0 )
        {
            MaxWinPoint=(HigherAfterEntry[1]-myEntryPrice)/ MinPoint;
            RetracementPoint = (HigherAfterEntry[1]-Low)/ MinPoint ;
            RetracementRate =RetracementPoint/MaxWinPoint;
            Commentary("MaxWinPoint:"+Text(MaxWinPoint) );
            Commentary("RetracementPoint:"+Text(RetracementPoint));
            Commentary("RetracementRate:"+Text(RetracementRate));
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate1) And (MaxWinPoint>=StartWinPoint1 And MaxWinPoint<=StartWinPoint2))
            
            {
                Commentary("多头止盈1");
                Sell(0,Low);    //多头止盈
                LongCurrentContracts=0;
                
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate2) And (MaxWinPoint>=StartWinPoint2 And MaxWinPoint<=StartWinPoint3))
            
            {
                Commentary("多头止盈2");
                Sell(0,Low);    //多头止盈
                LongCurrentContracts=0;    
                
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate3) And (MaxWinPoint>=StartWinPoint3 And MaxWinPoint<=StartWinPoint4))
            
            {
                Commentary("多头止盈3");
                Sell(0,Low);    //多头止盈
                LongCurrentContracts=0;        
                
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate4) And MaxWinPoint>=StartWinPoint4)
            
            {
                Commentary("多头止盈4");
                Sell(0,Low);    //多头止盈
                LongCurrentContracts=0;        
                
                //反手操作
                If (LotsBackhand>0 )
                {
                    LotsIni=LotsBackhand;
                    Commentary("多头止盈后反手做空");
                    SellShort(LotsIni,Low);
                    myEntryPrice=Low;
                    LowerAfterEntry=Low;
                    ShortCurrentContracts=LotsIni;
                    Return;
                }
            }
            }
            }
            }
            
        }else If(MarketPosition == -1 && BarsSinceentry >0)
        {
            MaxWinPoint=(myEntryPrice-LowerAfterEntry[1])/ MinPoint ;
            RetracementPoint = (High-LowerAfterEntry[1])/ MinPoint;
            RetracementRate =RetracementPoint/MaxWinPoint;
            Commentary("MaxWinPoint:"+Text(MaxWinPoint));
            Commentary("RetracementPoint:"+Text(RetracementPoint));
            Commentary("RetracementRate:"+Text(RetracementRate));    
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate1) And (MaxWinPoint>=StartWinPoint1 And MaxWinPoint<=StartWinPoint2))
            {
                Commentary("空头止盈1");
                
                BuyToCover(0,High);    //空头止盈
                ShortCurrentContracts=0;
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate2) And (MaxWinPoint>=StartWinPoint2 And MaxWinPoint<=StartWinPoint3))
            {
                Commentary("空头止盈2");
                
                BuyToCover(0,High);    //空头止盈
                ShortCurrentContracts=0;    
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate3) And (MaxWinPoint>=StartWinPoint3 And MaxWinPoint<=StartWinPoint4))
            {
                Commentary("空头止盈3");
                
                BuyToCover(0,High);    //空头止盈
                ShortCurrentContracts=0;
            If ((RetracementPoint>=WinRetracementPoint Or RetracementRate>=WinRetracementRate4) And MaxWinPoint>=StartWinPoint4)
            {
                Commentary("空头止盈4");
                
                BuyToCover(0,High);    //空头止盈
                ShortCurrentContracts=0;    
                //反手操作
                If (LotsBackhand>0 )
                {
                    LotsIni=LotsBackhand;
                    Commentary("空头止盈后反手做多");
                    Buy(LotsIni,High);
                    myEntryPrice=High;
                    HigherAfterEntry=High;
                    LongCurrentContracts=LotsIni;
                    Return;
                }
            }
        }
        }
        }
        }
        //跟踪止盈结束

账户手工开仓后,怎样利用开拓者平台对该手工仓单进行止盈止损(对于止盈最好能实现浮动止盈)
TB可以实现程序模型与交易者的交互吗?
程序化交易的时候,也想手动加仓,让程序来管理,怎么实现?
怎么实现不了立即开仓
请问老师:隐藏订阅的图层,用代码怎么实现
策略交易里面想增加自定义字段,请问是否可以写程序实现?
请问老师如何实现输出
用代理算法同时要双向持仓 怎么实现
请问可以怎么实现账户止盈呢?
用程序化怎么实现买入后,马上下止盈止损单