opening pending orders

 

HI,

MT4 EA...

I have created an EA that opens market orders, but I now want to open a Pending order + the market order.

here is my version, but i get error, not sure what is wrong.


 ticket = OrderSend(Symbol(), OP_BUY, NormalizeLots(_lots, Symbol()), Ask, 3, SL, TP, EA_Comment, MagicNumber, 0);  //Market order
ticket = OrderSend(Symbol(), OP_SELLSTOP, NormalizeLots(_lots, Symbol()),Ask-
10 ,3, SL, TP, EA_Comment, MagicNumber,300);  //pending order

The first line is fine and places the Market order.

No Pending order opens

300= 300seconds expiration



Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of...
 

1.sel price uses bid price not ask

2. it should be something like this ....Bid-10*Point....

 
Kristina Suh:

HI,

MT4 EA...

I have created an EA that opens market orders, but I now want to open a Pending order + the market order.

here is my version, but i get error, not sure what is wrong.


The first line is fine and places the Market order.

No Pending order opens

300= 300seconds expiration



 ticket = OrderSend(Symbol(), OP_BUY, NormalizeLots(_lots, Symbol()), Ask, 3, SL, TP, EA_Comment, MagicNumber, 0);  //Market order
ticket = OrderSend(Symbol(), OP_SELLSTOP, NormalizeLots(_lots, Symbol()),Ask-10*Point() ,3, SL, TP, EA_Comment, MagicNumber,300);  //pending order
 
You buy at the Ask and sell at the Bid.
  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.
 
William Roeder:
You buy at the Ask and sell at the Bid.
  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using the Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spread widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY (OANDA) shows average spread = 26 points, but average maximum spread = 134.

THanks


So would this be correct.


 
ticket = OrderSend(Symbol(), OP_BUY, NormalizeLots(_lots, Symbol()), Ask, 3, SL, TP, EA_Comment, MagicNumber, 0);  //Market order
      ticket= OrderSend(Symbol(),OP_SELLSTOP,NormalizeLots(_lots,Symbol()),Bid-10,3,SL,TP,EA_Comment,MagicNumber,300);  // Open Pending SellStop



AND


      ticket = OrderSend(Symbol(), OP_SELL, NormalizeLots(_lots, Symbol()), Bid, 3, SL, TP, EA_Comment, MagicNumber, 0);//  Open Market order
         ticket= OrderSend(Symbol(),OP_BUYSTOP,NormalizeLots(_lots,Symbol()),Ask+10,3,SL,TP,EA_Comment,MagicNumber,300);   //  Open Pending BuyStop

I also added (300) at the end, which is suppose to expire the Pending order for 5min / 300 sec.


Is that correct?

 
In future please post in the correct section
I will move your topic to the MQL4 and Metatrader 4 section.

 
Kristina Suh:

THanks


So would this be correct.


I also added (300) at the end, which is suppose to expire the Pending order for 5min / 300 sec.


Is that correct?

No , not

 
Ahmet Metin Yilmaz:

No , not

Can you help with the correct syntax?

Reason: