Take profit and stop loss errors while executing order

 

Hello, 

 I have one query regarding MqlTraderequest.

Here take profit and stop loss must be mentioned as a particular point

example

mrequest.tp = price + (200* Point()) ;

mrequest.sl = price - (100 * Point()); 

When I am executing my EA, if price doesn't match with the exact point mentioned in tp and sl, it won't execute the order though it might have crossed tp or sl level. 

So how to fill the order, is there any way, I can give a range for the tp and sl level. or any other method to resolve this?

 

Thanks,

Pratik 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Trade Request Structure - Documentation on MQL5
 
pratikshah2:

Hello, 

 I have one query regarding MqlTraderequest.

Here take profit and stop loss must be mentioned as a particular point

example

mrequest.tp = price + (200* Point()) ;

mrequest.sl = price - (100 * Point()); 

When I am executing my EA, if price doesn't match with the exact point mentioned in tp and sl, it won't execute the order though it might have crossed tp or sl level. 

So how to fill the order, is there any way, I can give a range for the tp and sl level. or any other method to resolve this?

Thanks,

Pratik 

Hi pratikshah2,

I wrote several MqlTraderequest back then for user phenix (see it here https://www.mql5.com/en/forum/6666) . However I'm a little bit confuse with your statement. You said " if price doesn't match with the exact point mentioned in tp and sl, it won't execute the order though it might have crossed tp or sl level.". I have several questions actually but let me ask just a few. the question are, is this on backtesting or not, and what order you're talking about, is it ORDER_TYPE_BUY, ORDER_TYPE_SELL, or else, and last question, may we see (some part of) your code and what's your broker anyway.

:D 

 

 

 
onewithzachy:

Hi pratikshah2,

I wrote several MqlTraderequest back then for user phenix (see it here https://www.mql5.com/en/forum/6666) . However I'm a little bit confuse with your statement. You said " if price doesn't match with the exact point mentioned in tp and sl, it won't execute the order though it might have crossed tp or sl level.". I have several questions actually but let me ask just a few. the question are, is this on backtesting or not, and what order you're talking about, is it ORDER_TYPE_BUY, ORDER_TYPE_SELL, or else, and last question, may we see (some part of) your code and what's your broker anyway.

:D 

 

 

It's demo account. It could be any order either Buy or Sell. It's happening while backtesting.

Let me elaborate the problem with example.

Pair : EURUSD 

buy order taken at 1.29100 

say you have given a tp = 1.29353

Eventhough when EURUSD market price may cross tp level many times, the order is not executed. The reason i feel for this is, market price may be moving from 1.29351 to 1.29355, and the tp level(1.29353) is not touched here so it won't execute eventhough price maybe moving more than 1.29353 further.

Hope you get the exact nature problem. 

Reason: