bbqute 發表於 16-7-12 12:22

EA 程式完成後 執行沒反應

各位高手
小弟我剛開始學寫程式,就用很簡單的比大小程式來測試結果寫完 除錯都沒問提了,但執行時卻不動
有沒有人可以幫幫我,我的程式出了什麼問題

intstart()
{
   int ticket, total;
   double lots;
   double O0;
   double C0;
   double M1,M2,M3,M4,M5,M6,M7,M8,M15;
   double B0,B1,B2,B3,B4,ES;
   int kind;//3B 5S 7O

    lots=0.1;
    O0= iOpen(NULL,0,0);
    C0= iClose(NULL,0,0);
    M1= (iOpen(NULL,1,0)+ iClose(NULL,1,0))/2;
    M2= (iOpen(NULL,2,0)+ iClose(NULL,2,0))/2;
    M3= (iOpen(NULL,3,0)+ iClose(NULL,3,0))/2;
    M4= (iOpen(NULL,4,0)+ iClose(NULL,4,0))/2;
    M5= (iOpen(NULL,5,0)+ iClose(NULL,5,0))/2;
    M6= (iOpen(NULL,6,0)+ iClose(NULL,6,0))/2;
    M7= (iOpen(NULL,7,0)+ iClose(NULL,7,0))/2;
    M8= (iOpen(NULL,8,0)+ iClose(NULL,8,0))/2;
    M15= (iOpen(NULL,15,0)+ iClose(NULL,15,0))/2;
    B0= iOpen(NULL,0,0)- iClose(NULL,0,0);
    B1= iOpen(NULL,1,0)- iClose(NULL,1,0);
    B2= iOpen(NULL,2,0)- iClose(NULL,2,0);
    B3= iOpen(NULL,3,0)- iClose(NULL,3,0);
    B4= iOpen(NULL,4,0)- iClose(NULL,4,0);
    ES=B0+ B1+ B2+ B3+ B4;

   total=OrdersTotal();
   while(total<1)
   {
      // no opened orders identified
      kind=7;
      if(AccountFreeMargin()<(1000*lots))
      {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);
      }
      // check for long position (BUY) possibility
      if(M15<M1 && M15<M2 && M15<M3 && M15<M4 && M15<M5 && M15<M6 && M15<M7 && M15<M8 )
      {
         ticket=OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,Ask+500*Point,NULL,NULL,0,Green);
         if(ticket>0)
         {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"B order price : ",OrderOpenPrice());
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=3;}
         }

         else
         {Print("Error opening BUY order : ",GetLastError());
         return(0);
         }
       }
      // check for short position (SELL) possibility
      if(M15>M1 && M15>M2 && M15>M3 && M15>M4 && M15>M5 && M15>M6 && M15>M7 && M15>M8 )
      {
         ticket=OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,Bid-500*Point,NULL,NULL,0,Red);
         if(ticket>0)
         {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time::",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"S oder price : ",OrderOpenPrice());
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=5;}
         }

         else
         {Print("Error opening SELL order : ",GetLastError());
         return(0);
         }
      }
   }

   while(total>1)
   {
   while(kind==5)
       {
         if(ES<=-0.009)
          {
         ticket=OrderClose(OrderTicket(),lots,Ask,3,Violet);
            if(total<1)
                {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"profit:",AccountProfit());
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=7;}
                }


          }               
         if(M15<M1 && M15<M2 && M15<M3 && M15<M4 && M15<M5 && M15<M6 && M15<M7 && M15<M8 )
          {
            if(M1<M3 )
            {
             Print("S not close to B,","TIME:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute());
            }
            else
            {
            ticket=OrderClose(OrderTicket(),lots,Ask,3,Violet);
            if(total<1)
                {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"profit:",AccountProfit());
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=7;}
                }


            }
          }
       }
   while(kind==3)       {
         if(ES>=0.009)
          {
          ticket=OrderClose(OrderTicket(),lots,Ask,3,Violet);
            if(total<1)
                {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"profit:",AccountProfit());
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=7;}
                }


          }               
         if( M15>M1 && M15>M2 && M15>M3 && M15>M4 && M15>M5 && M15>M6 && M15>M7 && M15>M8 )
          {
            if(M1>M3 )
            {
             Print("B not CLose to sell,","Time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute());
            }
            else
            {
             ticket=OrderClose(OrderTicket(),lots,Ask,3,Violet);
            if(total<1)
                {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("time:",Year(),"/",Month(),"/",Day(),Hour(),":",Minute(),"profit:",AccountProfit());
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) {kind=7;}
                }


            }
          }
       }

   }
    return(0);   
}


頁: [1]
查看完整版本: EA 程式完成後 執行沒反應