Help to create EA with two pending orders MQL4

 

Hello.



I am trying to implement a strategy to an EA ,  is based on fundamental news ,  opening 2 pending orders before the news BUY and SELL with stop loss of 6 pips and TAKE PROFIT (open), , lets say the event is at 13:00;00 GMT but I want the EA open these 2 pending orders at 12:59:45


If the  price moves up 10 pips from the price at 12:59:45. we activate the buying position and cancelled the selling pending order


If the  price moves down 10 pips from the price at 12:59:45. we activate the buying position and cancelled the buying pending order


Sorry for my english hope someone can help.


Regards/


Andy
 
ancarsa1075:

Hello.

I am trying to implement a strategy to an EA ,  is based on fundamental news ,  opening 2 pending orders before the news BUY and SELL with stop loss of 6 pips and TAKE PROFIT (open), , lets say the event is at 13:00;00 GMT but I want the EA open these 2 pending orders at 12:59:45

If the  price moves up 10 pips from the price at 12:59:45. we activate the buying position and cancelled the selling pending order 

If the  price moves down 10 pips from the price at 12:59:45. we activate the buying position and cancelled the buying pending order

You can't place an order based on a price at a specific time unless there is a tick at that time.  If there is a tick at 12:59:40 and the next one at 12:59:49 which price will you use ?
 

Using date and time function (https://docs.mql4.com/dateandtime), check if time is equal at the hour and equal and more at the minute - forget the second.

When time is meet, open Buy Stop above current price and save the ticket number, and open Sell Stop below current price and save the ticket number as well.

Using those tickets and OrderSelect() (https://docs.mql4.com/trading/OrderSelect) , check if the value of OrderType() (https://docs.mql4.com/trading/OrderType) has change to buy or sell.

If it has change, using the other ticket number and OrderDelete() (https://docs.mql4.com/trading/OrderDelete), delete the other pending.

Trading the news like this is a little bit risky, spread can be so big that both pendings may get opened :( 

 
phi.nuts:

Using date and time function (https://docs.mql4.com/dateandtime), check if time is equal at the hour and equal and more at the minute - forget the second.

When time is meet, open Buy Stop above current price and save the ticket number, and open Sell Stop below current price and save the ticket number as well.

Using those tickets and OrderSelect() (https://docs.mql4.com/trading/OrderSelect) , check if the value of OrderType() (https://docs.mql4.com/trading/OrderType) has change to buy or sell.

If it has change, using the other ticket number and OrderDelete() (https://docs.mql4.com/trading/OrderDelete), delete the other pending.

Trading the news like this is a little bit risky, spread can be so big that both pendings may get opened :( 

Thank you my friend.



I appreciatte your help.

 
phi.nuts:

Using date and time function (https://docs.mql4.com/dateandtime), check if time is equal at the hour and equal and more at the minute - forget the second.

When time is meet, open Buy Stop above current price and save the ticket number, and open Sell Stop below current price and save the ticket number as well.

Using those tickets and OrderSelect() (https://docs.mql4.com/trading/OrderSelect) , check if the value of OrderType() (https://docs.mql4.com/trading/OrderType) has change to buy or sell.

If it has change, using the other ticket number and OrderDelete() (https://docs.mql4.com/trading/OrderDelete), delete the other pending.

Trading the news like this is a little bit risky, spread can be so big that both pendings may get opened :( 


Yes, PHI.NUTS is a little be risky but i think the best way to trade is with a fundamental analysis, I do not believe in technical factors, sooner or later you end up with your Account destroyed, I have the same tought about the slippage, i want to try this kind of strtaegy since is designed to follow the trend just for a short period of time.


I will keep you informed

 
RaptorUK:
You can't place an order based on a price at a specific time unless there is a tick at that time.  If there is a tick at 12:59:40 and the next one at 12:59:49 which price will you use ?


Hello Raptor.


I will use 12:59:49

 
phi.nuts:

Using date and time function (https://docs.mql4.com/dateandtime), check if time is equal at the hour and equal and more at the minute - forget the second.

When time is meet, open Buy Stop above current price and save the ticket number, and open Sell Stop below current price and save the ticket number as well.

Using those tickets and OrderSelect() (https://docs.mql4.com/trading/OrderSelect) , check if the value of OrderType() (https://docs.mql4.com/trading/OrderType) has change to buy or sell.

If it has change, using the other ticket number and OrderDelete() (https://docs.mql4.com/trading/OrderDelete), delete the other pending.

Trading the news like this is a little bit risky, spread can be so big that both pendings may get opened :( 


Hello Phi.nuts.


You r talking about Spread or slippage??

 

He was talking about the Spread. Once the market reaches the pending price (the larger the spread the closer it becomes) the pending becomes a market order with whatever slippage exists. If the market gaps you may be open far higher than intended.

 
ancarsa1075:

Hello Raptor.

I will use 12:59:49


So you have changed your requirement ? you said you wanted to use 12:59:45
 
RaptorUK:

So you have changed your requirement ? you said you wanted to use 12:59:45

Hello Raptor.



Sorry I mistyped,

Hello.

I am trying to implement a strategy to an EA ,  is based on fundamental news ,  opening 2 pending orders before the news BUY and SELL with stop loss of 6 pips and TAKE PROFIT (open), , lets say the event is at 13:00;00 GMT but I want the EA open these 2 pending orders at 12:59:45

If the  price moves up 10 pips from the price at 12:59:50. we activate the buying position and cancelled the selling pending order 

If the  price moves down 10 pips from the price at 12:59:50. we activate the selling position and cancelled the buying pending order



Let's say the price at 12:59:50 is  1.2835 and at 12:59:59  the price is in 1.2865 then the system will open a BUYING position at 1.2845 and the SELLING pending order is cancelled.



Hope you can get the point.



Thank you

 
WHRoeder:

He was talking about the Spread. Once the market reaches the pending price (the larger the spread the closer it becomes) the pending becomes a market order with whatever slippage exists. If the market gaps you may be open far higher than intended.


Hello WHroeder.


Yes, you r right, what would be the best broker to trade this way, scalping and news??

Reason: