MT4 Language --> Someone in this forum is able to do that???

 

Hi to all!


My name's Luca;

I've got a big problem;


HMA EA works well but I have to put it on a CENT account;

My cent account has a limit -broker limit- of 100 lots for each order, in cent account 100 lots = 1 standard lot = 100000 usd

So can you change in "hma ea.mq4" the maximun lot for each order to 80 lots and if the order need to be bigger, the ea will place an order for the difference?
Someone is able to do that?

ex.1 for order of 153,6 lots it will place:
1 order of 8 lots
and 1 order of 73,6 lots

ex.2 for order of 307,2 lots it will place:
3 orders of 80 lots
and 1 order of 67,20 lots

ex.3 for order of 1024 lots it will place:
12 orders of 80 lots
and 1 order of 64 lots

ex.4 for order of 204,80 lots it will place:
2 orders of 80 lots
and 1 order of 44,80 lots



As you can see this is the problem:




Also starting from 0.03 lots the problem is the same:





I have made a lot of attempts, but without results,

I don't understand the code, but i've tried to change it as below:




void OpenMarketOrders(){
int cnt=0;
if (myOrderType==1 && ContinueOpening) {
if ((Bid-LastPrice)>=Pips*pt || OpenOrders<1) {
SellPrice=Bid;
LastPrice=0;
if (iTakeProfit==0) { tp=0; }
else { tp=SellPrice-iTakeProfit*pt; }
if (StopLoss==0) { sl=0; }
else { sl=SellPrice+StopLoss*pt; }
if (OpenOrders!=0) {
mylotsi=lotsi;
for(cnt=0;cnt<OpenOrders;cnt++){
if (MaxTrades>12) { mylotsi=NormalizeDouble(mylotsi*multiply,2); }
else { mylotsi=NormalizeDouble(mylotsi*multiply,2); }
}
} else { mylotsi=lotsi; }
if(mylotsi<=80)OrderSend(Symbol(),OP_BUY,mylotsi,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
if(mylotsi>80 && mylotsi<=160){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-80,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>160 && mylotsi<=240){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-160,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>240 && mylotsi<=320){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-240,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>320 && mylotsi<400){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-320,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>=400 && mylotsi<480){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-400,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>=480 && mylotsi<560){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-480,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>=560 && mylotsi<640){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-560.2,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>=640 && mylotsi<720){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-640.2,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}
if(mylotsi>=720 && mylotsi<800){
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,80,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
OrderSend(Symbol(),OP_BUY,NormalizeDouble(mylotsi-720,1),NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor);
}

return(0);
}
}






The result is below:






Someone can Help me please?



My email is:

x823x@email.it


Thanks :)



Files:
hmapea.mq4  45 kb
 

I attach also the indicator needed for the backtests;


Thank you very much

Files:
hma_v07.1.mq4  3 kb
 

https://www.mql5.com/en/articles/1481

Good luck!

 

Someone is able to resolve the problem please?


Thanks

 

We see what you are trying to do in terms of splitting your order into chunks of max lotsize 80. Incidentally, I'd code this in a much more efficient manner using a simple loop.

However, we need more info in order to check your logic - you haven't actually explained how you arrive at that lotsize, by counting existing orders etc.


CB

 
cloudbreaker:

We see what you are trying to do in terms of splitting your order into chunks of max lotsize 80. Incidentally, I'd code this in a much more efficient manner using a simple loop.

However, we need more info in order to check your logic - you haven't actually explained how you arrive at that lotsize, by counting existing orders etc.


CB

Hi cloudbreaker,


thanks for answer


As I told before i don't understand well mq4 code; I wrote something but it may be wrong.

The logic is simple: (multiplicator = 2) so the ea will open trade in this way:


0,01 0,02 0,04 0,08 0,16 0,32 0,64 1,28 2,56 5,12 10,24 20,48 40,96 81,92 163,84

327,68


or

0,03 0,06 0,12 0,24 0,48 0,96 1,92 3,84 7,68 15,36 30,72 61,44 122,88 245,76 491,52 983,04

or

0,05 0,1 0,2 0,4 0,8 1,60 3,20 6,4 12,8 25,6 51,2 102,4 204,8 409,6 819,2 1638,4

or

0,1 0,2 0,4 0,8 1,6 3,20 6,40 12,8 25,6 51,2 102,4 204,8 409,6 819,2 1638,4 3276,8

or

0,15 0,3 0,6 1,2 2,4 4,8 9,6 19,2 38,4 76,8 153,6 307,2 614,4 1228,8 2457,6 4915,2

or

0,3 0,6 1,2 2,4 4,8 9,6 19,2 38,4 76,8 153,6 307,2 614,4 1228,8 2457,6 4915,2 9830,4


it depends by the starting lot;

When the ea required a lotsize bigger than 80 lots it would just split the order in two or more orders (only because i have the limit set of my broker)

Existing order is no problem.


The ea i have posted is locked at the positions you see on the image I don't understand why.... anyway if you can compile tha ea with a code more efficet i will be glad



Thanks

 
/...
#define maxLot=80; // or double maxLot = MarketInfo( Symbol(), MODE_MAXLOT );
while(mylotsi >= 0.01) {
   double lot=MathMin(mylotsi, maxLot)
   if(!OrderSend(...lot...)) {
      Print("OrderSend failed");
      break;
   }
   mylotsi -= lot;
   refreshRates();  // Bid may change between sends
If you'll rather have 60+60+60 than 80+80+20
//...
#define maxLot=80; // or double maxLot = MarketInfo( Symbol(), MODE_MAXLOT );
for(int count=MathCeil(mylotsi/maxLot); count>0; count--) {
   double lot=mylotsi/count;
   if(!OrderSend(...lot...)) {
      Print("OrderSend failed");
      break;
   }
   mylotsi -= lot;
   refreshRates();  // Bid may change between sends
}
 
WHRoeder:

Thanks WHRoeder,



can you rebuild the ea with the modify please?


(i'm unable to insert it on the code)



please....... THANKS

 
hallo 823,

try the following simple WHRoeder's loop insteed yuor long code:

if (mylotsi <=800){ // 800 is the limit

#define maxLot=80; // or double maxLot = MarketInfo( Symbol(), MODE_MAXLOT );
while(mylotsi >= 0.01) {
double lot=MathMin(mylotsi, maxLot)
if(!OrderSend(Symbol(),OP_BUY,lot,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor)) {
Print("OrderSend failed");
break;
}
mylotsi -= lot;
}

}

Good luck,
 
BoDar:
hallo 823,

try the following simple WHRoeder's loop insteed yuor long code:

if (mylotsi <=800){ // 800 is the limit

#define maxLot=80; // or double maxLot = MarketInfo( Symbol(), MODE_MAXLOT );
while(mylotsi >= 0.01) {
double lot=MathMin(mylotsi, maxLot)
if(!OrderSend(Symbol(),OP_BUY,lot,NormalizeDouble(BuyPrice,Digits),slippage*mt,sl,tp,"MyMEFx EA"+MagicNumber,MagicNumber,0,ArrowsColor)) {
Print("OrderSend failed");
break;
}
mylotsi -= lot;
}

}

Good luck,

Hi BoDar and thanks


Can you insert the code on the ea please? ..or someone is able to do this, please?


I'm unable to do it :(



Thank you


if you want to send the ea coded by email: x823x@email.it, or post it here.

 

Have you ANY willingness to learn?


CB