Automated Trading Championship 2010 - page 8

 
Rosh:

Yes. it is right, because we can have several options:

  • 11*15 lot + 1*14.7 lot + 3 pending*0.1 lot
  • 10*15 lot + (1*14.8 lot+2 pending*0.1 lot)+(1*14.9 lot + 1 pending*0.1 lot)
  • 9*5 lot + 3*(14.9 lot +  pending*0.1 lot)
etc.

ありがとう、Rosh.

Now I clearly understood.


How about the second question?

 

I am having difficulty installing MT5 on my computer system. The error is :failed to connect to upload server (usa.cdn.metaquotes.net,read failed(12002).

Pls what can I do to resolve this asap?

Isaac.
 

in my MT4 EAs I use a function to partially close my position by percent, this percent apply to each of my opened orders proportionally depending of there OrderLots. All my orders are in the same direction (no hedging). This is my function :


// ferme partiellement tous les trades ouverts sur le symbole par l'EA, ferme par pourcentage des lots de chaque ordre
int partialPercentClosePosition(string symbol, double percent)
{
   int total=OrdersTotal();
   for(int i=total-1; i>=0; i--)
   {
      OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==symbol && OrderMagicNumber()==MAGIC)
      {
         switch(OrderType())
         {
            // on adapte le nombre de lots à fermer en fonction des règles de steplot
            double nbLots = OrderLots()*percent/100.0;
            double stepLots = MarketInfo(symbol,MODE_LOTSTEP);
            double multiplier = nbLots / stepLots;
            multiplier = NormalizeDouble(multiplier,0);
            nbLots = stepLots * multiplier;
           
            // on ferme la position selon son type
            case OP_BUY:
            {
               OrderClose(OrderTicket(),nbLots,Bid,1*pips2points,CLR_NONE);
               break;
            }
            case OP_SELL:
            {
               OrderClose(OrderTicket(),nbLots,Ask,1*pips2points,CLR_NONE);
               break;
            }
         }
      }
   }

   return(0);

}


With the new system of orders in MT5, will it be possible to do that ?

Rosh:
There is easy way to format code properly.

"Voilà" :)

 
squallmat:

in my MT4 EAs I use a function to partially close my position by percent, this percent apply to each of my opened orders proportionally depending of there OrderLots. All my orders are in the same direction (no hedging). This is my function :




With the new system of orders in MT5, will it be possible to do that ?

"Voilà" :) 

Try this. Not tested. Hope it works.

// ferme partiellement tous les trades ouverts sur le symbole par l'EA, ferme par pourcentage des lots de chaque ordre
int partialPercentClosePosition(string symbol, double percent)
{
   int total=PositionsTotal();
   for(int i=0; i<total; i++)
   {
      if(PositionSelect(symbol) )
         {
            if(PositionGetInteger(POSITION_MAGIC)==MAGIC)
               {
                  
                  // on adapte le nombre de lots à fermer en fonction des règles de steplot
                  double nbLots = PositionGetDouble(POSITION_VOLUME)*percent/100.0;
                  double stepLots = SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP);
                  double multiplier = nbLots / stepLots;
                  multiplier = NormalizeDouble(multiplier,0);
                  nbLots = stepLots * multiplier;
                  
                  if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
                     {
            // on ferme la position selon son type
                        MqlTradeRequest Request;
                        Request.action = TRADE_ACTION_DEAL;
                        Request.magic = MAGIC;
                        Request.symbol = symbol;
                        Request.volume = nbLots;
                        Request.price = NormalizeDouble(SymbolInfoDouble(symbol, SYMBOL_BID), _Digits);
                        Request.type = ORDER_TYPE_SELL; 
                        Request.sl = 0;
                        Request.tp = 0;
                        Request.type_filling = ORDER_FILLING_AON;
                        Request.type_time = ORDER_TIME_GTC;
                        Request.deviation = 3;
                        Request.comment = "Closed Partial Buy Position";
   
                        MqlTradeResult Result;
                           
                        if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)) { Sleep(3000); return(-1); }
                     
                        bool result = OrderSend(Request, Result); 
                        if (result == false) { Print("Buy Close call unsuccessful - error ",GetLastError()); ResetLastError(); }
                        break;
                     }
                        
                  if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
                     {
                        MqlTradeRequest Request;
                        Request.action = TRADE_ACTION_DEAL;
                        Request.magic = MAGIC;
                        Request.symbol = symbol;
                        Request.volume = nbLots;
                        Request.price = NormalizeDouble(SymbolInfoDouble(symbol, SYMBOL_ASK), _Digits);
                        Request.type = ORDER_TYPE_BUY; 
                        Request.sl = 0;
                        Request.tp = 0;
                        Request.type_filling = ORDER_FILLING_AON;
                        Request.type_time = ORDER_TIME_GTC;
                        Request.deviation = 3;
                        Request.comment = "Closed Partial Sell Position";
                  
                        MqlTradeResult Result;
                              
                        if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)) return(-1);
                  
                        bool result = OrderSend(Request, Result); 
                        if (result == false)    { Print("Buy Close call unsuccessful - error ",GetLastError()); ResetLastError(); }
                        break;
                     }
               }
         }
   }

   return(0);

}

 

 

 
wackena:

Try this. Not tested. Hope it works.

 

 

thanks, i'll try it
 
Hi Rosh, my ea have the code like "#include <Trade\Trade.mqh>" , need i upload Trade.mqh for the ATC?
 

Hi,

Do we have to send the source code of EA ? Or it is enough the exe files ?

How many EAs can I send ?

Could the supported sybmbols list be updated by adding EURNZD, NZDUSD ?

thank you 

 
lf8749:
Hi Rosh, my ea have the code like "#include <Trade\Trade.mqh>" , need i upload Trade.mqh for the ATC?
It's the standard MQL library, I don't think you have to send them.
 
 
tektronic:

Hi,

Do we have to send the source code of EA ? Or it is enough the exe files ?

How many EAs can I send ?

Could the supported sybmbols list be updated by adding EURNZD, NZDUSD ?

thank you 

any answer on these questions from metaquotes ?