Yet another ordersend error 131 or 130

 

Hello everyone. I have been trying to solve the errors that occurs to me but the interesting part is on my strategy tester and I used 3 different brokers and all those testers have not given me any errors.

So I tried to submit it to automated tester in order to make my expert advisor available in the market. Well, the results are PASSED with flying colors which is great.

Now, the hard part.

When the moderator test my ea in their sophisticated strategy tester, all goes south, immediately. Suddenly errors coming up to their result page and thus halted my ea to be in market.

I tried to fix the error but the errors just keep coming to them while in my tester and automated tester doesn't even produce any errors.

It have come to a point that the moderator assuming that I am basically ignoring their point to fix the errors occurred and have a made a word of denying me to be in the market altogether at all.

So, I am practically stuck now. I don't know what is wrong with my coding (I am not from a programming background though) and therefore, could someone pointed me what is wrong with my codes?


Below is the code snippet from my ea 

               LotsBcheck1=LotsB;

               if(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)==1)LotsBcheck2=NormalizeDouble(LotsBcheck1,1);
               if(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)==0.1)LotsBcheck2=NormalizeDouble(LotsBcheck1,1);
               if(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)==0.01)LotsBcheck2=NormalizeDouble(LotsBcheck1,2);
               if(LotsBcheck2<SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN))
                  LotsBcheck2=NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN),2);
               if(LotsBcheck2>SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX))
                  LotsBcheck2=NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX),2);

               if(AccountFreeMarginCheck(Symbol(),OP_BUY,LotsBcheck2)>0)
                 {
                  if(OrderSend(Symbol(),OP_BUYSTOP,LotsBcheck2,BuyPrice,slippage,0,TPpipbs,(string)MagicNumberB+" | MayaHFT-B1-"+Symbol(),MagicNumberB,0,CLR_NONE))
                    {gvs("bcheck",0);Print(LotsBcheck2," | ",BuyPrice," | 7B1");}
                 }
               else status1="Not enough free margin | 7B1";

LotsB is the external input.

If let say I put 0.2123, the ea will properly convert the LotsB input into 0.21 BUT in the moderator's tester, it will not do the conversion and will plainly used the inputs directly, that is 0.2123, which is of course will throw out those errors.

Please check the attachment error_1.png to see the error.

I also attached sc1.png from my strategy tester.


I hope somebody have a say to this. Thank you.

Files:
error_1.png  19 kb
sc1.PNG  117 kb
 
Syed Naufal Gaddafi:
 

I hope somebody have a say to this. Thank you.

Your code isn't reliable. If the volume step is equal to e.g. 0.05 (I've never seen it but...) then you get unpredictable result.

In your case (the same result what you probably wanted) try normalizing volume by this code:

   double volume=0.2163;
   double volumeStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   double volumeMin=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   double volumeMax=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
   double volumeNormalized=round(volume/volumeStep)*volumeStep;
   volumeNormalized=volumeNormalized<volumeMin?volumeMin:(volumeNormalized>volumeMax?volumeMax:volumeNormalized);

But if you want to your normalized volume would never be greater than your non-normalized volume you should try this code and you have to check if the normalized volume isn't equal to zero (if non-normalized volume is less than volume min):

   double volume=0.2163;
   double volumeStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   double volumeMin=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   double volumeMax=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
   double volumeNormalized=int(volume/volumeStep)*volumeStep;
   volumeNormalized=volumeNormalized<volumeMin?0.0:(volumeNormalized>volumeMax?volumeMax:volumeNormalized);
 
Petr Nosek:

Your code isn't reliable. If the volume step is equal to e.g. 0.05 (I've never seen it but...) then you get unpredictable result.

In your case (the same result what you probably wanted) try normalizing volume by this code:

But if you want to your normalized volume would never be greater than your non-normalized volume you should try this code and you have to check if the normalized volume isn't equal to zero (if non-normalized volume is less than volume min):

Thank you for your codes.

I have implemented it and of course it would run smoothly in the mt4 strategy tester. Unfortunately, in automated tester, it produce EURUSD,H1: invalid lots amount for FreeMarginCheck function

The default lot is 0.01 though and for some reason, 0.01 becomes invalid in the automated tester. LOL. Very impressive.

Below is the implemented codes:-

               double volume=LotsB;
               double volumeStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
               double volumeMin=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
               double volumeMax=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
               double volumeNormalized=int(volume/volumeStep)*volumeStep;
               volumeNormalized=volumeNormalized<volumeMin?0.0:(volumeNormalized>volumeMax?volumeMax:volumeNormalized);

               if(AccountFreeMarginCheck(Symbol(),OP_BUY,volumeNormalized)>0)
                 {
                  if(OrderSend(Symbol(),OP_BUYSTOP,volumeNormalized,BuyPrice,slippage,0,TPpipbs,(string)MagicNumberB+" | MayaHFT-B1-"+Symbol(),MagicNumberB,0,CLR_NONE))
                    {gvs("bcheck",0);Print(volumeNormalized," | ",BuyPrice," | 7B1");}
                 }
               else status1="Not enough free margin | 7B1";
 
Syed Naufal Gaddafi:

Unfortunately, in automated tester, it produce EURUSD,H1: invalid lots amount for FreeMarginCheck function

As I said you have to check if the normalized volume isn't equal to zero (if non-normalized volume is less than volume min).

               double volume=LotsB;
               double volumeStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
               double volumeMin=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
               double volumeMax=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
               double volumeNormalized=int(volume/volumeStep)*volumeStep;
               volumeNormalized=volumeNormalized<volumeMin?0.0:(volumeNormalized>volumeMax?volumeMax:volumeNormalized);
               if(volumeNormalized>0.0)
                 {
                  if(AccountFreeMarginCheck(_Symbol,OP_BUY,volumeNormalized)>0)
                    {
                     if(OrderSend(_Symbol,OP_BUYSTOP,volumeNormalized,BuyPrice,slippage,0,TPpipbs,(string)MagicNumberB+" | MayaHFT-B1-"+_Symbol,MagicNumberB,0,CLR_NONE))
                       {gvs("bcheck",0);Print(volumeNormalized," | ",BuyPrice," | 7B1");}
                    }
                  else status1="Not enough free margin | 7B1";
                 }
               else status1="Too small volume, don't trade | 7B1";
 
Petr Nosek:

As I said you have to check if the normalized volume isn't equal to zero (if non-normalized volume is less than volume min).

When I implemented it, of course, mt4 tester doesn't have any errors but in the automated tester, it throws out no trading operations error.

So, I strip everything to the bone and do some manual lot inputs until I finally get passed in the automated tester. Turns out that automated tester doesn't like anything below 1 lot.

My default lot is 0.01 and it seems whatever we put to normalized the volume, doesn't get to the automated tester minimum volume of 1 lot.

Now, how to determine the minimum lot required by the automated tester while the other mt4 tester just simply accept minimum lot of 0.01?

 
As I have the same problem you all can't test my mighty products.
 
Syed Naufal Gaddafi:

When I implemented it, of course, mt4 tester doesn't have any errors but in the automated tester, it throws out no trading operations error.

So, I strip everything to the bone and do some manual lot inputs until I finally get passed in the automated tester. Turns out that automated tester doesn't like anything below 1 lot.

My default lot is 0.01 and it seems whatever we put to normalized the volume, doesn't get to the automated tester minimum volume of 1 lot.

Now, how to determine the minimum lot required by the automated tester while the other mt4 tester just simply accept minimum lot of 0.01?

I'm sorry I don't understand what  you mean by the MT4 tester and by the automated tester. I suppose you're talking about the Strategy tester in MT4 (mt4 tester).

The allowed minimum size of volume depends on a broker and on a symbol. You should check it before you set the trade volume fix to 0.01 (the min volume could be 0.1 or 1.0 for the symbol at the broker).

I also don't know how your LotsB is calculated. Imagine that volumeMin=0.01 and LotsB=0.009999999999999999 (it seems to be 0.01) but in this case LotsB is less than volumeMin ==> no trade.

 
Petr Nosek:

I'm sorry I don't understand what  you mean by the MT4 tester and by the automated tester. I suppose you're talking about the Strategy tester in MT4 (mt4 tester).

The allowed minimum size of volume depends on a broker and on a symbol. You should check it before you set the trade volume fix to 0.01 (the min volume could be 0.1 or 1.0 for the symbol at the broker).

I also don't know how your LotsB is calculated. Imagine that volumeMin=0.01 and LotsB=0.009999999999999999 (it seems to be 0.01) but in this case LotsB is less than volumeMin ==> no trade.

MT4 tester is the standard broker strategy tester. Automated tester is not a broker tester but actually is mql5.com specialized tester designed to do automated testing before any product seller of this site can sell their product in the market.

Therefore, since automated tester is not a broker strategy tester, I don't know how to make the ea determined the minimum lot required by this automated tester, which I said earlier where standard MT4 strategy tester doesn't produce any errors but once submitted to automated tester, all hell break loose.

So, I strip everything to the bone and do some manual lot inputs until I finally get passed in the automated tester. Turns out that automated tester doesn't like anything below 1 lot.

My default lot is 0.01 and it seems whatever we put to normalized the volume, doesn't get to the automated tester minimum volume of 1 lot.

Now, how to determine the minimum lot required by the automated tester while the other mt4 tester just simply accept minimum lot of 0.01?

 
Syed Naufal Gaddafi:

MT4 tester is the standard broker strategy tester. Automated tester is not a broker tester but actually is mql5.com specialized tester designed to do automated testing before any product seller of this site can sell their product in the market.

Therefore, since automated tester is not a broker strategy tester, I don't know how to make the ea determined the minimum lot required by this automated tester, which I said earlier where standard MT4 strategy tester doesn't produce any errors but once submitted to automated tester, all hell break loose.

So, I strip everything to the bone and do some manual lot inputs until I finally get passed in the automated tester. Turns out that automated tester doesn't like anything below 1 lot.

My default lot is 0.01 and it seems whatever we put to normalized the volume, doesn't get to the automated tester minimum volume of 1 lot.

Now, how to determine the minimum lot required by the automated tester while the other mt4 tester just simply accept minimum lot of 0.01?

I haven't an experience with the "automated tester" and therefore I can't help you with this. Maybe this automated tester try to find out if your code is applicable to different broker's conditions. And one of these conditions could be that the allowed minimum volume is e.g. 1.0.
If you aren't sure you should ask the provider of the automated tester for help.
 
Syed Naufal Gaddafi:

MT4 tester is the standard broker strategy tester. Automated tester is not a broker tester but actually is mql5.com specialized tester designed to do automated testing before any product seller of this site can sell their product in the market.

Therefore, since automated tester is not a broker strategy tester, I don't know how to make the ea determined the minimum lot required by this automated tester, which I said earlier where standard MT4 strategy tester doesn't produce any errors but once submitted to automated tester, all hell break loose.

So, I strip everything to the bone and do some manual lot inputs until I finally get passed in the automated tester. Turns out that automated tester doesn't like anything below 1 lot.

My default lot is 0.01 and it seems whatever we put to normalized the volume, doesn't get to the automated tester minimum volume of 1 lot.

Now, how to determine the minimum lot required by the automated tester while the other mt4 tester just simply accept minimum lot of 0.01?

If you want to be a seller, you should be able to fix your code, or to hire someone who is able to do it for you.

If you have questions about automatic validation, ask the moderator of your product.

You already got all needed answers and explanation.