Memaparkan catatan dengan label Forex. Papar semua catatan
Memaparkan catatan dengan label Forex. Papar semua catatan
img
 

string getMAcrossoverSignal()
{
	  string Signal;
      
	  //current chart, current period, 20, no shift, simple, close price
      double SlowMovingAverage = iMA(NULL,0,50,0,MODE_SMA, PRICE_CLOSE, 0);
      
      //current chart, current period, 20, no shift, simple, close price
      double LastSlowMovingAverage = iMA(NULL,0,50,0,MODE_SMA, PRICE_CLOSE, 1);
      
      //current chart, current period, 10, no shift, simple, close price
      double FastMovingAverage = iMA(NULL,0,20,0,MODE_SMA, PRICE_CLOSE, 0);
      
      //current chart, current period, 10, no shift, simple, close price
      double LastFastMovingAverage = iMA(NULL,0,20,0,MODE_SMA, PRICE_CLOSE, 1);
      
       
      if ((LastFastMovingAverage < LastSlowMovingAverage) && (FastMovingAverage > SlowMovingAverage))
         { 
         	Comment ("CrossOver:", "BUY");
            Signal = "BUY";
         }
      
      if ((LastFastMovingAverage > LastSlowMovingAverage) && (FastMovingAverage < SlowMovingAverage))
         { 
         	Comment ("CrossOver:", "SELL");
            Signal = "SELL";
         }
         
       return Signal;
      
}
      

MQL4 - Moving Average Cross Over Signal

im
 //---------------------------------  
 // Close All Trade  
 //--------------------------------  
 void CloseAllTrades()  
 {  
   //go through all open trades  
   for (int i=OrdersTotal(); i>=0;i--)  
   {  
    //select trade  
    if (OrderSelect(i, SELECT_BY_POS)==true)  
    {  
      //check if trade belongs to current chart  
      if(OrderSymbol()== Symbol())  
      {  
       bool Ans = OrderClose(OrderTicket(),OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),5,Red);  
       if (Ans == true)  
       {  
       Print ("Order Close !");  
       }  
      }  
    }  
   }  
 }  

MQL4 - How to Close All Trade