Adjust to lot step, then min and max.
Thank you for your response. I tried what you suggest but I get the same error. Any other ideas?
I also tried the code as shown below (without using the intermediary variables), but I get the same error.. Are there any other checks in regaredds to volume limitations that I am missing?
void executeSell() { // check if enough free margin double margin; if(OrderCalcMargin(ORDER_TYPE_SELL,inpSymbol,Firstlot_adjusted,BidPrice,margin)&& margin > AccountInfoDouble(ACCOUNT_MARGIN_FREE)) { Print("Not enough margin to open sell position"); return; } // making sure not get invalid volume error Firstlot_adjusted = (int)(Firstlot_adjusted/SymbolInfoDouble(inpSymbol,SYMBOL_VOLUME_STEP))* SymbolInfoDouble(inpSymbol,SYMBOL_VOLUME_STEP); Firstlot_adjusted = MathMin(Firstlot_adjusted,SymbolInfoDouble(inpSymbol,SYMBOL_VOLUME_MAX)); Firstlot_adjusted = MathMax(Firstlot_adjusted,SymbolInfoDouble(inpSymbol,SYMBOL_VOLUME_MIN)); Firstlot_adjusted = MathMin(Firstlot_adjusted,SymbolInfoDouble(inpSymbol,SYMBOL_VOLUME_LIMIT)); Trade.Sell(Firstlot_adjusted,inpSymbol,BidPrice,0,0,TradeComment); }
Thank you for your response. I tried what you suggest but I get the same error. Any other ideas?
I also tried the code as shown below (without using the intermediary variables), but I get the same error.. Are there any other checks in regaredds to volume limitations that I am missing?
I removed the check for SYMBOL_VOLUME_LIMIT and now I get no error messages. Thought I would share in case someone else has the same issue..
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
2019.06.28 04:54:04 failed instant sell 0.41 XAUUSD at 1423.09 [Invalid volume]
However, I do run checks to look at size and lotstep before sending order.
Can anyone see what I do wrong?