How to check if an order has been closed for stop loss - page 5

 
honest_knave:

Although I have undermined my own argument for an "acceptable range", because best possible price may well be outside the deviation parameter inside the EA.

Nevertheless, it could be positive slippage. 

In theory yes. But I have never seen a positive slippage on a stoploss (in Forex at least). Did you ?

The liquidity is so high that either your position is closed a stoploss price, or at a worst price. 

Anyway, it's doesn't really matter. 

 
Alain Verleyen:

Yes but my question was about spread/deviation, not slippage.

So yes theoretically it becomes a market order, but certainly not filled at best possible price. But that's not the problem discussed here. 

The problem with MT5 is the current stoploss is not available in history. As stated by Jose, the initial stoploss is available, but it you change it later, there is no way to know.

So once you position is close, there is no way to know from history what was the stoploss, you can of course know the close price, but with what will you compare it to check if a stoploss was triggered ?

I don't have enough knowledge of MQL5 to know whether Roberto's suggestion is capable of retrieving a subsequently changed SL. I'll leave that to you guys to figure out.

But if the SL is set and not modified, there is clearly a mechanism to work from. Which is where my (admittedly far-from-ideal) idea for an acceptable range came from i.e. using the deviation parameter. Of course, a huge market gap is going to break any concept of acceptable range.

 

Alain Verleyen:

So yes theoretically it becomes a market order, but certainly not filled at best possible price. But that's not the problem discussed here. 

Agreed OT but intriguing - a Market Order that will not be filled at the best possible price? Have I understood you correctly?
 
Alain Verleyen:

An order to modify SL/TP is not saved in the history at all. So not sure what you mean here ?

That's the problem. I refer to these orders:


I think they should be saved in history with their POSITION_ID. They all would appear using HistorySelectByPosition(), and not only the orders that open and close the position. It would solve the question easily.


Alain Verleyen:

And the order which actually results from the SL/TP triggered doesn't contain the SL/TP.


Yes, I know.

Regards-.

 
honest_knave:

I don't have enough knowledge of MQL5 to know whether Roberto's suggestion is capable of retrieving a subsequently changed SL. I'll leave that to you guys to figure out.

That's funny we have a 5 pages topic with a lot of people just guessing  And it's just going too fast...

 But if the SL is set and not modified, there is clearly a mechanism to work from. Which is where my (admittedly far-from-ideal) idea for an acceptable range came from i.e. using the deviation parameter. Of course, a huge market gap is going to break any concept of acceptable range.

The problem is there NO WAY to know if the SL/TP was changed. Honestly I don't understand your deviation/range idea.

Agreed OT but fascinating - a Market Order that will not be filled if the slippage is positive? Have I understood you correctly?

It's not what I said, see my other post.

 
Jose Francisco Casado Fernandez:

That's the problem. I refer to these orders:


I think they should be saved in history with their POSITION_ID. They all would appear using HistorySelectByPosition(), and not only the orders that open and close the position. It would solve the question easily.



Yes, I know.

Regards-.

Ok but that's from the Strategy Tester.

Of course we can invent all kind of solutions. The topic was "flooded" so fast, there is no way to post a comprehensive answer  

 
Alain Verleyen:

In theory yes. But I have never seen a positive slippage on a stoploss (in Forex at least). Did you ?

The liquidity is so high that either your position is closed a stoploss price, or at a worst price. 

Anyway, it's doesn't really matter. 

I totally agree. That's what I was going to answer to  @honest_knave
 
Alain Verleyen:

It's not what I said, see my other post.

No, I realised that and edited my previous post but it must have been while you were typing your response. My apologies for the misquote.

Alain Verleyen:

That's funny we have a 5 pages topic with a lot of people just guessing  And it's just going too fast...

And that is different from normal how? ;-)

Alain Verleyen:

The problem is there NO WAY to know if the SL/TP was changed. Honestly I don't understand your deviation/range idea.

Not disputed. I was merely contending that == was too simplistic, as was >= or <=

And rather than just give problems, I proposed a slightly better approach (IMHO) albeit still flawed for the reasons we don't disagree upon.

Alain Verleyen:

In theory yes. But I have never seen a positive slippage on a stoploss (in Forex at least). Did you ?

Jose Francisco Casado Fernandez:
I totally agree. That's what I was going to answer to  @honest_knave

No I haven't. But I also haven't had an OrderSelect ever fail but I still test for it. 

 

Alain Verleyen:

The topic was "flooded" so fast, there is no way to post a comprehensive answer

I think we all have a lot of free time this afternoon, hahaha.

 
honest_knave:

No, I realised that and edited my previous post but it must have been while you were typing your response. My apologies for the misquote.

And that is different from normal how? ;-)

Not disputed. I was merely contending that == was too simplistic, as was >= or <=

And rather than just give problems, I proposed a slightly better approach (IMHO) albeit still flawed for the reasons we don't disagree upon.

No I haven't. But I also haven't had an OrderSelect ever fail but I still test for it. 

Ok I clearly understood your point now.

So of course you are right, we can't just use == (which I already said sooner :-D). I propose to close the discussion about this point. Roberto will study and fix his mind  

The main problem with mql5 is you have nothing to compare too (using only history). 

 
Jose Francisco Casado Fernandez:

I think we all have a lot of free time this afternoon, hahaha.