MQL5: Limitations of Limit Orders

 

For buy limit order, we buy at the price lower than current market price; for sell limit order, we sell at the price higher than current market price.

So my question is, can we actually write a code that places a buy limit order at a price higher than the current market price and a sell limit order at a price lower than the current market price?

I am not asking for the code, I just want to know if it is even possible.

Thank you very much!

Documentation on MQL5: Standard Library / Trade Classes / CTrade
Documentation on MQL5: Standard Library / Trade Classes / CTrade
  • www.mql5.com
CTrade - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Adam:

While a stop limit order (a stop order for placing limit order) can be made manually in metaTrader, I see no function as such in CTrade. I wonder if there is a way we can automate it using mql5?

I am not asking for code, I just want to know if it is even possible. Thank you very much.

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

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

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


Thank you for your answer! I knew ctradebuylimit and ctradeselllimit, but they are not the kinds of orders I am looking for.

For ctradebuylimit, we buy at the price lower than current market price; for tradeselllimit, we sell at the price higher than current market price.

I wonder if we can actually place a buy limit order at a price higher than the current market price and a sell limit order at a price lower than the current market price.

Sorry for not making my question clearer (I have also updated my post for clarification). 

 
Adam:


Thank you for your answer! I knew ctradebuylimit and ctradeselllimit, but they are not the kinds of orders I am looking for.

For ctradebuylimit, we buy at the price lower than current market price; for tradeselllimit, we sell at the price higher than current market price.

I wonder if we can actually place a buy limit order at a price higher than the current market price and a sell limit order at a price lower than the current market price.

Sorry for not making my question clearer (I have also updated my post for clarification). 

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

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

do you mean buy stop/sell stop? limit is as long as the price is greater/lesser than price +- stop level

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().
 
Sardion Maranatha:

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

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

do you mean buy stop/sell stop? limit is as long as the price is greater/lesser than price +- stop level

Sardion, thank you for being keen to help!

No, I do not mean buy/sell stop, I mean buy/ sell limit order.

Let me quote the documentation of MetaTrader 5 to clarify:

  • Buy Limit – a trade request to buy at the Ask price that is equal to or less than that specified in the order. The current price level is higher than the value in the order. Usually this order is placed in anticipation of that the security price, having fallen to a certain level, will increase.
  • Buy Stop – a trade order to buy at the "Ask" price equal to or greater than the one specified in the order. The current price level is lower than the value in the order. Usually this order is placed in anticipation of that the security price, having reached a certain level, will keep on increasing.
  • Sell Limit – a trade order to sell at the "Bid" price equal to or greater than the one specified in the order. The current price level is lower than the value in the order. Usually this order is placed in anticipation of that the security price, having increased to a certain level, will fall.
  • Sell Stop – a trade order to sell at the "Bid" price equal to or less than the one specified in the order. The current price level is higher than the value in the order. Usually this order is placed in anticipation of that the security price, having reached a certain level, will keep on falling.             

Types of Orders - Trading Principles - MetaTrader 5 iPhone/iPad Help
Types of Orders - Trading Principles - MetaTrader 5 iPhone/iPad Help
  • www.metatrader5.com
The MetaTrader 5 mobile platform allows users to prepare and issue requests for the broker to execute trading operations. In addition, the platform allows to control and manage open positions. For this purposes, several types of trade orders are used. An order is an instruction of a brokerage firm's client to conduct a trade operation. In the...
 
Adam:

For buy limit order, we buy at the price lower than current market price; for sell limit order, we sell at the price higher than current market price.

So my question is, can we actually write a code that places a buy limit order at a price higher than the current market price and a sell limit order at a price lower than the current market price?

I am not asking for the code, I just want to know if it is even possible.

Thank you very much!

Technically there is no restriction. It is MT5/4 that makes it impossible to put a Buy Limit at a higher price or Sell Limit at lower price.

There are brokers that provide a workaround for this limitation. It is not possible to do this with code from within the Terminal as the restriction is in the Terminal itself.

 
Enrique Dangeroux:

Technically there is no restriction. It is MT5/4 that makes it impossible to put a Buy Limit at a higher price or Sell Limit at lower price.

There are brokers that provide a workaround for this limitation. It is not possible to do this with code from within the Terminal as the restriction is in the Terminal itself.

Thank you for your answer! I wonder why do they impose restrictions as such...

Speaking about the brokers that provide a workaround, I will be grateful if can you suggest any of them. Thank you again.

 
Adam:

Thank you for your answer! I wonder why do they impose restrictions as such...

Speaking about the brokers that provide a workaround, I will be grateful if can you suggest any of them. Thank you again.

Recommendations about brokers is not allowed. You have to do your own research. But to steer you in the right direction. Look for brokers that provide service for traders. These are the brokers without bonus programs/ib programs or any other crap that has nothing to do with providing best trading conditions.

 
Enrique Dangeroux:

Recommendations about brokers is not allowed. You have to do your own research. But to steer you in the right direction. Look for brokers that provide service for traders. These are the brokers without bonus programs/ib programs or any other crap that has nothing to do with providing best trading conditions.I

Oh I'm new here and didn't know about that rule. Thank you for your guidance tho - it does help me a lot!

 
Adam: Oh I'm new here and didn't know about that rule.

When you registered you agreed to Metaquotes' rules.
          General rules and best pratices of the Forum. - MQL5 programming forum 2017.10.27

Think about who is MetaQuotes' customers. It is not us users.