Is there a way to do pyramiding in MQL4?

 
Hi,

I'm quite new to MQL4 language. My Expert Advisor use pyramiding strategy, but I still can't figure out how to implement pyramiding strategy in MQL4 language. I've read "Trading functions" documentation, but it seems that MQL4 does not support pyramiding. Could anyone help me with this problem?

Thanks,
Keerati
 
keerati:
Hi,

I'm quite new to MQL4 language. My Expert Advisor use pyramiding strategy, but I still can't figure out how to implement pyramiding strategy in MQL4 language. I've read "Trading functions" documentation, but it seems that MQL4 does not support pyramiding. Could anyone help me with this problem?

Thanks,
Keerati

Keerati,

I am sure you can implement pyramiding strategies with MQL4 language, but you have to write the code by yourself. You must write the decision code for opening new orders. So you have to call 'OrderSend' trading function whenever you want to open an order.

Regards,

Renato.
 

Hi Renato,

Thanks for your reply. But for example, if I send order EUR/USD 10000@1.2800, 5000@1.2810, 2000@1.2820 and after that I want to sell EUR/USD 8000@1.2810, I will get a problem because my orders cannot be mixed to 8000 lots. Anyway, I just figure out that if I send ten orders of 1000@1.2800 instead of one order of 10000@1.2800. I can implement pyramiding strategy. Nevertheless, does anyone know the minimum lots size that can be used in OrderSend function?

Thanks,

Keerati

 
double minLotSize = MarketInfo("EURUSD", MODE_MINLOT);
Best Regards,

Renato.
 
You don't have to sell all the lots in the order. So you can sell 8 lots with a 10,5,2 open.

Simplest is to sell 8 of the ten eg
for(int i=0;i<OrdersTotal();i++)
{ 
    OrderSelect(i,SELECT_BY_POS)
   
    if(OrderLots()==10)
      OrderClose(OrderTicket(),8,....etc)
}
a more generally approach would be,
SellLots = 8;
 
for(int i=0;i<OrdersTotal();i++)
{    
    OrderSelect(i,SELECT_BY_POS)
    if(OrderLots()<SellLots)
    {   SellLots = SellLots - OrderLots();
        OrderClose(OrderTicket(),OrderLots(),...etc
    }
    else
    {   OrderClose(OrderTicket(),SellLots,...etc
        SellLots = 0;
        break;
    }
}
 
if(SellLots>0) Print("Trying to sell more than we owned! Oops");
 
keerati:

Hi Renato,

Thanks for your reply. But for example, if I send order EUR/USD 10000@1.2800, 5000@1.2810, 2000@1.2820 and after that I want to sell EUR/USD 8000@1.2810, I will get a problem because my orders cannot be mixed to 8000 lots. Anyway, I just figure out that if I send ten orders of 1000@1.2800 instead of one order of 10000@1.2800. I can implement pyramiding strategy. Nevertheless, does anyone know the minimum lots size that can be used in OrderSend function?

Thanks,

Keerati


The minimum lot size for FXDD is .10 standard lot (1 mini, 10,000), however you can increment that number by 1,000 after that (i.e. .11 Standard lots 11,000, etc). Other brokers allow .01 standard lots (1,000). The easiest way to tell is to place an order manually and see what it will let you do (demo account, I assume).

I hope this helps.

Scott
 
Thanks a lot everyone :D
I'll try it this weekend.

Keerati
Reason: