Jon, 1) The first OrderSend() is checked that it was successful by testing that the return value is greater than zero before attempting to place the second order. 2) To identify and process order pairs you could base your code on the following if the order pairs were comprised of different types (however the algorythm would have to be altered if the grouping was more than 2 or if the orders in a group were all of the same type): The sample program "ReportsTrader.mq4" that follows places straddle orders near the issue of reports or news events. A straddle order is comprised of two pending orders above and below the market price. When one pending order hits the market price it is changed into a market order and the other pending
order has to be deleted. So the order pairs require a sequence number to track them.
I don't know if you ever solved this problem Chee Chua, but I got very close to being able to do the same thing.
My system creates pricelevels (based on my inputs at the start) which are then supposed to be permanent, so that if price revisits a pricelevel and an order does not exist an order is placed. These pricelevels are created when each pending order is created using a for loop. The magicnumber is then derived from the pricelevel.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
1) The first OrderSend() is checked that it was successful by testing that the return value is greater
than zero before attempting to place the second order.
2) To identify and process order pairs you could base your code on the following if the order pairs
were comprised of different types (however the algorythm would have to be altered if the grouping
was more than 2 or if the orders in a group were all of the same type):
The sample program "ReportsTrader.mq4" that follows places straddle orders near the issue of
reports or news events.
A straddle order is comprised of two pending orders above and below the market price. When one
pending order hits the market price it is changed into a market order and the other pending
order has to be deleted. So the order pairs require a sequence number to track them.
I don't know if you ever solved this problem Chee Chua, but I got very close to being able to do the same thing.
My system creates pricelevels (based on my inputs at the start) which are then supposed to be permanent, so that if price revisits a pricelevel and an order does not exist an order is placed. These pricelevels are created when each pending order is created using a for loop. The magicnumber is then derived from the pricelevel.
You can see my code here:
https://www.mql5.com/en/forum/306224
My only problem is that sometimes my number comes out 1 digit less than the Pricelevel of the trade which I cannot solve.