Finding it difficult to send orders. - page 3

 
Well looks like CT Trade it is.
 
It doesn't like the dynamic lot size?? It works with ct trade, when I use a fixed lot size.
 
MetaNt:
It doesn't like the dynamic lot size?? It works with ct trade, when I use a fixed lot size.

CTrade is a wrapper to OrderSend().

You wrote that it doesn't work with a volume à 0.07 or even 1. How are you defining this ? Lot=0.07 ?

 
angevoyageur:

CTrade is a wrapper to OrderSend().

You wrote that it doesn't work with a volume à 0.07 or even 1. How are you defining this ? Lot=0.07 ?

I wasn't sure if I had written Mqlrequest and Mqlresult correctly and so I used CTrade instead, I found that it worked if I used fixed volumes, and now I have found that I may multiply the fixed volumes by integers, but if I attempt to alter the volumes with fractions I get errors such as invalid lotsize, the result of the modified lot size is printed with the error [invalid volume].
 
It's decimals of certain complexity, I will try normalize double.
 
MetaNt:
It's decimals of certain complexity, I will try normalize double.
Normalize double is provided a fix for the complex decimals, I'll try it on my dynamic lot.
 
MetaNt:
Normalize double is provided a fix for the complex decimals, I'll try it on my dynamic lot.

Fixed.

 

Looks like it was one of my scaling factors from some equations that lay outside of the CT Buy/Sell.  It wasn't an issue that I had encountered in mql4 so it took me a while to locate it, I'll have to watch out for that if mql4 updates again.

 For anyone else with this problem use 2 for the digit part of the NormalizeDouble() function. 

 

007 you say ?

You should perhaps ask Mr Bond ;-) 

 

I seem to be running into the same problem here. I have confirmed that the lot size meets the SYMBOL_VOLUME_MIN, SYMBOL_VOLUME_MAX and SYMBOL_VOLUME_STEP requirements.

For example I get this:

2014.04.07 14:49:35    2014.04.04 16:00:00   CTrade::OrderSend: instant sell 0.53 EURUSD at 1.36934 sl: 1.37434 tp: 1.35934 [invalid volume]

While backtesting EA with this symbol and  these specifications:


Here code I am using to send order:

int    losses=1;
int    DecimalPoints=2;
double Risk=0.03;
double Inc=0.1;
my_symbol=Symbol();
leverage=AccountInfoInteger(ACCOUNT_LEVERAGE);
contract=SymbolInfoDouble(my_symbol,SYMBOL_TRADE_CONTRACT_SIZE);
min_lot=SymbolInfoDouble(my_symbol,SYMBOL_VOLUME_MIN);
max_lot=SymbolInfoDouble(my_symbol,SYMBOL_VOLUME_MAX);
trade_size=equity*(Risk/100)*leverage;
trade_size/=contract;
trade_size+=losses*Inc;
NormalizeDouble(trade_size,DecimalPoints);
  if(trade_size<min_lot)
    {
     trade_size=min_lot;
    }
  else if(trade_size>max_lot)
    {
     trade_size=max_lot;
    }
trade.Sell(trade_size,my_symbol,price,0,price-tp,"Expert Sell");

EDIT:

I can of course manually place trades with this exact lot size.

 
Candles:

I seem to be running into the same problem here. I have confirmed that the lot size meets the SYMBOL_VOLUME_MIN, SYMBOL_VOLUME_MAX and SYMBOL_VOLUME_STEP requirements.

For example I get this:

2014.04.07 14:49:35    2014.04.04 16:00:00   CTrade::OrderSend: instant sell 0.53 EURUSD at 1.36934 sl: 1.37434 tp: 1.35934 [invalid volume]

While backtesting EA with this symbol and  these specifications:


Here code I am using to send order:

EDIT:

I can of course manually place trades with this exact lot size.

This line is without effect :

NormalizeDouble(trade_size,DecimalPoints);

You have to affect the result to a variable, see documentation of NormalizeDouble.

trade_size=NormalizeDouble(trade_size,DecimalPoints);
Reason: