wywdgd 发表于 2016-8-6 07:24:06

请帮我看下为什么总是出现交易讯号消失

请帮我看下为什么总是出现交易讯号消失,导致您的持仓不匹配呢

Params
    Numeric Lots(1);
 Numeric ExitOnCloseMins(14.59);  
 Numeric maLen1(10);
    Numeric maLen2(30);   
Vars      
       Numeric ma1;  
       Numeric ma2;  
        Numeric TakeProfit(1);
        Numeric TakeProfit2(2);
        Numeric MinPoint;
        Numeric MyEntryPrice;
        Numeric MyExitPrice;

        NumericSeries HighestAfterEntry; //  开仓后出现的最高价
       NumericSeries LowestAfterEntry; //  开仓后出现的最低价
        Numeric StopLine(0);
        
Begin
        ma1 = Average(Open,maLen1);
       ma2 = Average(Open,maLen2);   
        MyEntryPrice = AvgEntryPrice;   
        HighestAfterEntry = Close;
       LowestAfterEntry = Close;
        Commentary("ma1: "+Text(ma1));
        Commentary("ma2: "+Text(ma2));
        
     If(CurrentBar > maLen2)
     {   
        If(MarketPosition==0)
            {   
               if((Open>=ma1)&&(ma1>ma2))
                   {   
                       MyEntryPrice==open;
                       Buy(lots,MyEntryPrice);
               HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);
                   LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);
                      Return;
                   }
                   if((Open<ma1)&&(ma1<ma2))
                   {   
                       MyEntryPrice==open;
                       SellShort(lots,MyEntryPrice);
                           HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);
                           LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);
                       Return;
                   }  
                   HighestAfterEntry = Max(HighestAfterEntry,High);  
                  LowestAfterEntry = Min(LowestAfterEntry,Low);  
                  
            }        
                 
        If(MarketPosition==1)//多仓
            {  
               
                   If(High>=ma1&&(High>HighestAfterEntry))//增仓
                   {  MyEntryPrice=Open;
                          Buy(Lots,Open);
                          HighestAfterEntry=High;
                          Commentary("增仓: "+Text(Open));
                   }
                   If(High>=ma1&&(High<HighestAfterEntry))//未突破前期高位反手
                    {  
                          MyEntryPrice=Open;
                          SellShort(1,MyEntryPrice);
                    }
                   If(Low<ma1&&(Low<LowestAfterEntry))//止损并反手
                    {
                         MyExitPrice=Open;
                          Sell(0,Open);
                          
                          MyEntryPrice=MyExitPrice;
                          SellShort(1,Open);
                          LowestAfterEntry=Low;
                   }
                  
                   If(Low<ma1&&(Low>LowestAfterEntry))//未突破前期低位增仓
                    {
                          MyEntryPrice=Open;
                          Buy(1,MyEntryPrice);  
                   }
           }else If(MarketPosition==-1)//空仓
            {   
               
                   If(Low<ma1&&(Low<LowestAfterEntry))//增仓
                    {
                          MyEntryPrice=Open;
                          SellShort(1,Open);
                          LowestAfterEntry=Low;
                   }
                   If(Low<=ma1&&(Low>LowestAfterEntry))//未突破前期高位反手
                    {
                          MyEntryPrice=Open;
                          Buy(1,MyEntryPrice);
                    }  
                   If(High>=ma1&&(High>HighestAfterEntry))//止损并反手
                    {
                          MyExitPrice=Open;
                          BuyToCover(0,Open);
                          
                          MyEntryPrice=MyExitPrice;
                          Buy(1,Open);  
                          HighestAfterEntry=High;
                    }
                        
                   If(High>=ma1&&(High<HighestAfterEntry))//未突破前期低位增仓
                    {
                          MyEntryPrice=Open;
                          SellShort(1,MyEntryPrice);   
                    }
                  
           }
           
     }
         

xnmpf168 发表于 2016-8-8 16:45:21

大哥,是你吗?把这个不能用的换了我那个能用的:lol
页: [1]
查看完整版本: 请帮我看下为什么总是出现交易讯号消失