May be a mistake in Ctrade include?

 

I am using a Ctrade object for trade execution:

trade_obj.Buy(trade_volume,_Symbol,trade_price,stop_loss,take_profit);

the volume, stop loss, take profit is OK, but the price execution, no matter how I set, it always trade at the current price.

Is it a mistake in Ctrade library, anyone who meet the same problem? Thanks for any help.

 
Hiệp Lê:

I am using a Ctrade object for trade execution:

the volume, stop loss, take profit is OK, but the price execution, no matter how I set, it always trade at the current price.

Is it a mistake in Ctrade library, anyone who meet the same problem? Thanks for any help.

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuystop

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuylimit


these should help you

Documentation on MQL5: Standard Library / Trade Classes / CTrade / BuyStop
Documentation on MQL5: Standard Library / Trade Classes / CTrade / BuyStop
  • www.mql5.com
Successful completion of the BuyStop(...) method does not always mean successful execution of the trade operation. It is necessary to check the result of trade request (trade server return code) using ResultRetcode() and value returned by ResultOrder().
 
roshjardine:

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuystop

https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradebuylimit


these should help you

And for sure, is function PositionOpen(symbol,order_type,volume,price,sl,tp,cmt) in this CTrade class, the price parameter is for nothing, it will trade at market price?

 
Hiệp Lê:

And for sure, is function PositionOpen(symbol,order_type,volume,price,sl,tp,cmt) in this CTrade class, the price parameter is for nothing, it will trade at market price?

it's not for nothing, it's for the order type you want to assign as part of the arguments to that method, ORDER_TYPE_BUY and  ORDER_TYPE_SELL will use market price, other than that read the documentation about stop or limit order