MQL5 Checking whether the pending order has been executed or not

60 Views Asked by At

I am using MQL5 in Borsa Istanbul. I trade in futures markets. In our exchange, just like in cryptocurrency exchanges, buyers and sellers place market maker orders, and this is how the market is formed. There is no spread like the FX markets, instead the buyer and seller meet at the best price and give a commission to the brokerage firm.

enter image description here

For example, the best buy order here is: 36,01 and the best sell order: 36,46


In this case, I place a buy order at the price of 36,05 now the best buy order here is: 36,05 and the best sell order: 36,46. If anyone sells it to me at 36.05, I can buy it. If anyone doesn't sell it to me, I can't buy it.

I trade futures contracts of AKBNK stock, the symbols for this stock's October and November futures are: F_AKBNK1023 and F_AKBNK1123.  If the price difference in the F_AKBNK1023 and F_AKBNK1123 contracts falls to 2% or less, I simultaneously open a sell transaction for the F_AKBNK1023 contract and a buy transaction for F_AKBNK1123. When the difference exceeds 4%, I do the opposite. Instead of buying the contract I want to make directly from the market, I want to buy it as a market maker. Based on the example above, if my pending buy order for the F_AKBNK1123 contract at a price of 36.05 is executed, I want to simultaneously sell the F_AKBNK1023 contract at the market price. 

How can I do that? Thank you for your help.

I can buy from the market and sell to the market without any problems. But I can't do it with a pending order.

0

There are 0 best solutions below