How to code simultaneous buy limit order and buy order

 

Hi, I was wondering how can I simultaneously code a buy limit order and a buy market order on MQL4. First, is the syntax below for initiating a buy limit order correct? int ticket = OrderSend(Symbol(),OP_BUYLIMIT,0.10,Ask-60*_Point,3,0,0,NULL,0,0,Green); Second, do we have to put entry conditions in order to launch the buy order at a limit price such as "if(ask<limit) => launch the by limit order" ? Or does the ordersend () function directly predict that if the price of the asset is below the limit, then the order will be released? Finally, I don't understand how ask-60 * _Point, which represents the limit of the order buy limit, is constant. Isn't Ask a variable price? Thank you for your answers! Karl

 
  1. Karl Sawaya: First, is the syntax below 

    Perhaps you should read the manual.
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  2. Karl Sawaya: int ticket = OrderSend(Symbol(),OP_BUYLIMIT,0.10,Ask-60*_Point,3,0,0,NULL,0,0,Green); 

    The command will create a Buy Limit six (6) PIPs below the current market price, assuming that's more than the minimum: MODE_STOPLEVEL * _Point or SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL).
              Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial

  3. Karl Sawaya: "if(ask<limit) => launch the by limit order" ? Or does the ordersend () function directly predict that if the price of the asset is below the limit, then the order will be released? 

    A limit order opens at the specified price or better. For a Buy, that means lower. The Ask must always be above the limit price to create the pending order. After the pending order is created, if the market reaches the pending price, the order becomes an active Buy - there is no prediction. If you want a pending order above the curent price you use a Buy Stop instead.

    You need to start learning before coding:
              Learn Forex Trading at School of Pipsology - BabyPips.com

  4. Karl Sawaya: Finally, I don't understand how ask-60 * _Point, which represents the limit of the order buy limit, is constant. Isn't Ask a variable price? 

    Ask is a variable, the current market buy price. Therefor Ask - 60 * _Point, is also variable. The value is used in the OrderSend when the order created - the price of the order doesn't change after the order is created.

  5. There is no need to create pending orders in code.
    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
    2. Don't worry about it unless you're scalping M1 or trading news.
    3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.
 
William Roeder:
  1. Perhaps you should read the manual.
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  2. The command will create a Buy Limit six (6) PIPs below the current market price, assuming that's more than the minimum: MODE_STOPLEVEL * _Point or SymbolInfoInteger(SYMBOL_TRADE_STOPS_LEVEL).
              Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial

  3. A limit order opens at the specified price or better. For a Buy, that means lower. The Ask must always be above the limit price to create the pending order. After the pending order is created, if the market reaches the pending price, the order becomes an active Buy - there is no prediction. If you want a pending order above the curent price you use a Buy Stop instead.

    You need to start learning before coding:
              Learn Forex Trading at School of Pipsology - BabyPips.com

  4. Ask is a variable, the current market buy price. Therefor Ask - 60 * _Point, is also variable. The value is used in the OrderSend when the order created - the price of the order doesn't change after the order is created.

  5. There is no need to create pending orders in code.
    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)
    2. Don't worry about it unless you're scalping M1 or trading news.
    3. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.


Thank you for your answers.


1. I am currently learning how to code, I am not currently making an EA, I am only learning some simple functions and that's why I asked this question. Please excuse my English if I seemed incomprehensible in my words.

2. Ok, thank you :)

3. How do we activate the pending order on MQL4? OrderSend() is the function to create the buy order but I don't see any functions to activate an order? Will it be activated automatically? If yes, do we have to place conditions to close a buy limit order?

4. Thank you ! So, the OrderSend() function can create a buy limit order and if the market reaches the pending price, then the order will be activated. What if the market reaches the pending price and just after that, it folds up and becomes above the pending price again ? Will the buy limit order be desactivated ? 

5. Okay, so I don't need to create a buy limit order on MQL4.

Thank you for all the answers and for sharing the articles.

 

3) You don't. When the market price reaches the pending order, it opens.

4) An open order can't be a pending order — it is already open. THINK about a time line.

Reason: