Ordersend error while testing EA

 

Hir Friends

I am facing issue while sending order can anybody help me with this. FYI lot is calculated based on % of account freee margin. Can you help me to know what is wrong.

Thanks,

Kcfve123

Files:
kcfve123.mq4  12 kb
 
Please try executing it on EURUSD daily time frame
 
kcfve123:

Hir Friends

I am facing issue while sending order can anybody help me with this. FYI lot is calculated based on % of account freee margin. Can you help me to know what is wrong.

Thanks,

Kcfve123


what error message or numbers are you getting?
 
OrderSend returns an integer. If there's no error it's the ticket number. It there's an error it gives -1, and you can get the error code using GetLastError().
 

Hi Friends,

Can you please try executing my EA in test mode on eurusd daily chart. As I may be able to provide error after 12 hours as I am working in office & do not have access to MT4 now :)))

 
kcfve123:

Hi Friends,

Can you please try executing my EA in test mode on eurusd daily chart. As I may be able to provide error after 12 hours as I am working in office & do not have access to MT4 now :)))


will you bake me a cake?
 
yep : )
 

Hi Friend,

I am getting below errors while testing my EA.

1)Invalid lots amount for order send function.

2)Order send error 4051

Please help me to get out of these errors.

Thanks

Kcfve123

 
kcfve123:

Hi Friend,

I am getting below errors while testing my EA.

1)Invalid lots amount for order send function.

Read this: https://www.mql5.com/en/forum/143966
 

Hi Raptor,

I am not professional coder can you please help me to correct my ea . Considering your expertise I know it will take 1 minute for you to do this change.

Thanks for the help.

Kcfve123

 
kcfve123:

Hi Raptor,

I am not professional coder can you please help me to correct my ea . Considering your expertise I know it will take 1 minute for you to do this change.

After these lines . . .

BLots = (((AccountFreeMargin()*Risk )/100)/(BStopLoss*Current));
SLots = (((AccountFreeMargin()*Risk )/100)/(SStopLoss*Current));

add these . . .

double   minLot  = MarketInfo(Symbol(), MODE_MINLOT),
         lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);

BLots = MathFloor(MathMax(0, BLots) / lotStep) * lotStep;
SLots = MathFloor(MathMax(0, SLots) / lotStep) * lotStep;
Reason: