Download MetaTrader 5
To add comments, please log in or register
All articles are available from MetaTrader 5. Contribute your own one!
Luciano Ola
1007
Luciano Ola 2014.04.01 23:06 

I keep getting the error "invalid volume", the account balance is 10 000 and the lot size is 0.07.

 

 

This is my code, I think it might not be the volume tbh. 

 

MqlTradeResult StageOneBuyRes={0};
MqlTradeRequest StageOneBuy={0};

StageOneBuy.action=TRADE_ACTION_DEAL;  
StageOneBuy.magic=MagicNumber;  
StageOneBuy.symbol=_Symbol;            // symbol
StageOneBuy.volume=Lot;
StageOneBuy.price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
StageOneBuy.sl=0;                  // Stop Loss is not specified
StageOneBuy.tp=0;                 // Take Profit is not specified 
StageOneBuy.deviation =7;  
StageOneBuy.type=ORDER_TYPE_BUY; // order type
StageOneBuy.type_filling = ORDER_FILLING_FOK;
StageOneBuy.comment = "test";
 

MqlTradeResult StageOneSellRes={1};
MqlTradeRequest StageOneSell={1};

StageOneSell.action=TRADE_ACTION_DEAL;  
StageOneSell.magic=MagicNumber;  
StageOneSell.symbol=_Symbol;            // symbol
StageOneSell.volume=Lot;
StageOneSell.price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
StageOneSell.sl=0;                  // Stop Loss is not specified
StageOneSell.tp=0;                 // Take Profit is not specified 
StageOneSell.deviation =7;  
StageOneSell.type=ORDER_TYPE_SELL; // order type
StageOneSell.type_filling = ORDER_FILLING_FOK;
StageOneSell.comment = "test";
Alain Verleyen
Moderator
30260
Alain Verleyen 2014.04.01 23:11  
MetaNt:

I keep getting the error "invalid volume", the account balance is 10 000 and the lot size is 0.07.

 

 

This is my code, I think it might not be the volume tbh. 

 

What is the minimum volume allowed by your broker for this symbol ?
Luciano Ola
1007
Luciano Ola 2014.04.01 23:18  
angevoyageur:
What is the minimum volume allowed by your broker for this symbol ?
0.01.
Snelle Moda
601
Snelle Moda 2014.04.01 23:27  
MetaNt:

I keep getting the error "invalid volume", the account balance is 10 000 and the lot size is 0.07.

 

 

This is my code, I think it might not be the volume tbh. 

 

I had a similar problem with my EA (got the same error). The traded volume was lower than the minimum allowed trading size of my broker or the increment/step size was to small. 

(Check the minimum volume size of your broker, maybe the minimum trading size or increment/step size is larger than your 0.07)  "already done"

Is the variable "Lot" of the double type?

Luciano Ola
1007
Luciano Ola 2014.04.01 23:29  
snelle_moda:

I had a similar problem with my EA (got the same error). The traded volume was lower than the minimum allowed trading size of my broker or the increment/step size was to small. 

Check the minimum volume size of your broker, maybe the minimum trading size or increment/step size is larger than your 0.07.

Is the variable "Lot" of the double type?

It's of the double type, I haven't set an increment.

 

I tried to use 1 as the order Lot value earlier to see if it would work, and the error persisted, I'll try and use 10 now. 

Luciano Ola
1007
Luciano Ola 2014.04.01 23:32  
It didn't work.
Snelle Moda
601
Snelle Moda 2014.04.01 23:33  

Use

ZeroMemory(StageOneBuy);

ZeroMemory(StageOneSell);


Before you fill in the request and send the order.

Alain Verleyen
Moderator
30260
Alain Verleyen 2014.04.01 23:40  
snelle_moda:

Use

ZeroMemory(StageOneBuy);

ZeroMemory(StageOneSell);


Before you fill in the request and send the order.

It's already done with {0}. Exactly the same.
Luciano Ola
1007
Luciano Ola 2014.04.02 00:08  
angevoyageur:
It's already done with {0}. Exactly the same.
Initially both were 0 but I changed the sell one to 1 to see if that would solve the problem, which is why it says one in the code I posted.
Luciano Ola
1007
Luciano Ola 2014.04.02 00:13  
MetaNt:
Initially both were 0 but I changed the sell one to 1 to see if that would solve the problem, which is why it says one in the code I posted.
Btw when I ran print to get the error code I was getting error code 4756, this is an invalid entry error, so it was not much help.
Luciano Ola
1007
Luciano Ola 2014.04.02 00:44  
Any suggestions?
/ /1234
To add comments, please log in or register