你的太在乎 发表于 2011-12-3 04:39:26

EA测试时只开一单,找不到原因,求帮助

近期想把一个指标做成EA,看看效果如何,但是运行好好的指标变成EA后,测试智能交易系统时,只开一次buy单,就再也不下单,也不平仓了。找不出原因来,卡壳好些天了。各位老大们给看看错在哪里。
   

extern double TakeProfit = 50;
extern double Lots = 0.1;
int cnt, ticket, total,lastnumber;
datetime lastopentime=0;
int i=1,Mark=0;
extern int s=20;   //ATR指标的周期数
extern double n=4; //ATR指标的系数

double Zhu[],Fu[];
double Mid;
int Limit,Shift;

int start()
    {
   int counted_bars=IndicatorCounted();
   Limit=Bars-counted_bars;
   
   if(i=0;Shift--)
       {
       if(Mark==0)
      {
            if(High>High)
             {
            Mark=1;
            Zhu=High;
            Fu=High-Mid;
             }
            if(LowZhu)
            {
               Zhu=High;
               Fu=High-Mid;
               }
            else if((Low)lastopentime)
                  {
                   closebuy();
                   lastnumber=sell(1,0,0,Symbol()+\"sell\",0);
                   if(lastnumber>0)
                  {
                   if(OrderSelect(lastnumber,SELECT_BY_TICKET,MODE_TRADES)==true)
                     {
                      lastopentime=OrderOpenTime();
                     }
                  }
                }
                  }
               else
                     {
                      Zhu=Zhu;
                      Fu=Zhu-Mid;
                     }
         }
      else if(Mark==-1)
          {
            if(LowMid)
                  {
                   Zhu=High;
                   Fu=High-Mid;
                   Mark=1;
                  
                   if(iTime(Symbol(),0,Shift)>lastopentime)
                  {
                   lastnumber=buy(1,0,0,Symbol()+\"buy\",0);
                   if(lastnumber>0)
                  {
                  closesell();
                  if(OrderSelect(lastnumber,SELECT_BY_TICKET,MODE_TRADES)==true)
                     {
                      lastopentime=OrderOpenTime();
                     }
                  }
                }
                  }
               else
                  {
                     Zhu=Zhu;
                     Fu=Zhu+Mid;
                  }
         }
       }
   return(0);
    }
   
int buy(double Lots,double sun,double ying,string comment,int magic)
    {
   int kaiguan=0;
   for(int i=0;i0)
       {
   if(OrderSelect(ticket, SELECT_BY_TICKET)==true)
       {
      if((sun!=0)&&(ying!=0))
      {
      OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-sun*MarketInfo(Symbol(),MODE_POINT),OrderOpenPrice()+ying*MarketInfo(Symbol(),MODE_POINT),0,Red);
      }
      if((sun==0)&&(ying!=0))
      {
      OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderOpenPrice()+ying*MarketInfo(Symbol(),MODE_POINT),0,Red);
      }
      if((sun!=0)&&(ying==0))
      {
      OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-sun*MarketInfo(Symbol(),MODE_POINT),0,0,Red);
      }
       }
       }
   return(ticket);
   }
    else
   {
      return(0);
   }
    }
int sell(double Lots,double sun,double ying,string comment,int magic)
      {
       int kaiguan=0;
   for(int i=0;i0)
   {
       if(OrderSelect(ticket, SELECT_BY_TICKET)==true)
      {
       if((sun!=0)&&(ying!=0))
      {
         OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+sun*MarketInfo(Symbol(),MODE_POINT),OrderOpenPrice()-ying*MarketInfo(Symbol(),MODE_POINT),0,Red);
      }
       if((sun==0)&&(ying!=0))
      {
         OrderModify(OrderTicket(),OrderOpenPrice(),0,OrderOpenPrice()-ying*MarketInfo(Symbol(),MODE_POINT),0,Red);
      }
       if((sun!=0)&&(ying==0))
      {
         OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+sun*MarketInfo(Symbol(),MODE_POINT),0,0,Red);
      }
      }
   }
   return(ticket);
      }
   else
      {
    return(0);
      }
    }
   
   
   
void closebuy()
   {
       for(int i=0;i

谢了好兄弟 发表于 2012-11-22 00:05:51

帮你顶,人还是厚道点好

zhoukhme 发表于 2012-11-22 00:05:51

嘿嘿

combo18 发表于 2012-11-22 00:05:51

今天无聊来逛逛

伊人146 发表于 2012-11-22 00:05:51

楼主有没有好的EA推荐

夏天的风 发表于 2012-11-22 00:05:51

我十目一行也还是看不懂啊

dqrhteny 发表于 2012-11-22 00:05:51

来几句吧

逸兴壮思飞 发表于 2013-5-8 13:09:58

周期不对

cuuxzquj 发表于 2015-1-7 02:05:20

今天黄金怎么操作

hothotka 发表于 2015-1-7 02:05:24

研究研究
页: [1] 2 3
查看完整版本: EA测试时只开一单,找不到原因,求帮助