Demo testing error

 

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);
 
LotSize/8.0

remember to check MODE_MINLOT & MODE_LOTSTEP

 
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.
 
No I just checked the conditions and it should have made orders by now.
 
Min lot and max lot are part of my comment()s.
 
MetaNt:
Min lot and max lot are part of my comment()s.

but not in the calculation of the LotSize
 
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)

 

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

try:

ResetLastError

OrderSend(....

GetLastError();

 
Ah fixed it, it was an initialisation issue, I needed to define Lotsize during initialisation.
 

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

especially when it can cause problems such as error 131

 
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.
Reason: