Download MetaTrader 5

Demo testing error

To add comments, please log in or register
Luciano Ola
1007
Luciano Ola  

During my demo testing I have received this error 4051, after checking my ordersend() lines I have come to the conclusion that everything is in order.

Please note that I added the clr before the colour names as this was suggested by the new mql4 syntax.

OrderSend(Symbol(),OP_BUY,LotSize/8,Ask,7,0,0,NULL,MagicNumber,0,clrGreen);
.
.
.
.
OrderSend(Symbol(),OP_SELL,LotSize/8,Bid,7,0,0,NULL,MagicNumber,0,clrRed);
qjol
3243
qjol  
LotSize/8.0

remember to check MODE_MINLOT & MODE_LOTSTEP

Luciano Ola
1007
Luciano Ola  
qjol:

remember to check MODE_MINLOT & MODE_LOTSTEP


I've been printing the Lotsize and it says I'm trying to buy zero lots?? this is just happening immediately after the EA initialises. I could wait a couple of days and see if it happens again.
Luciano Ola
1007
Luciano Ola  
No I just checked the conditions and it should have made orders by now.
Luciano Ola
1007
Luciano Ola  
Min lot and max lot are part of my comment()s.
qjol
3243
qjol  
MetaNt:
Min lot and max lot are part of my comment()s.

but not in the calculation of the LotSize
Luciano Ola
1007
Luciano Ola  
qjol:

but not in the code


What I meant was that the minlot is 0.01 the maxlot is 100 (as calculated and commented on the chart) the volume of the trade is well within these limits (as calculated and commented on the chart)

qjol
3243
qjol  

are you sure the returning error code 4051 is from OrderSend ?

try:

ResetLastError

OrderSend(....

GetLastError();

Luciano Ola
1007
Luciano Ola  
Ah fixed it, it was an initialisation issue, I needed to define Lotsize during initialisation.
qjol
3243
qjol  

regardless (or not) why use a calculation (LotSize/8) inside OrderSend function

especially when it can cause problems such as error 131

Luciano Ola
1007
Luciano Ola  
qjol:

regardless (or not) why use a calculation (LotSize/8) inside OrderSend function

especially when it can cause problems such as error 131


Just further scaling it's part of the strategy, there is most likely a better alternative.
12
To add comments, please log in or register