How to detect TP SL in Current each order when already open

I’ve known it can be use Notification Metaquote ID to mobile.

But I want to know in 'Code MQL4 ’

How to detect current TP and SL’s booked and When user change TP SL Manual it will show.

I tried everything but it’s not response
This I’ll try

          printf("NEW SL %s",newSL);
          Print("OrderSelect returned the error of ",GetLastError());

How to solve it

I don’t use or work with mobile devices. To be able to tell what someone on a device did is a challenge.
What I would suggest is that you encode the TP and SL in the Comment and/or Magic.
If they change it and change it back, it will look like nothing has happened, which may not be what you want.

If your OrderOpenPrice = 1.23456 you can write this into the Comment.
This is something we had to do with grids so we did not replace a grid in live trading because it shifted to a different price due to slippage.

You may want to not use the magic as you have other plans for it.

Here is a snip of code:

			sText = StringConcatenate(G2BSMagic, DoubleToStr(currentLevel, Digits), sBlank);

			SendOrder(G2BSEngine, dLots, currentLevel, dSL, dTP, sText, G2BSMagic);

Here the code is putting sText into the OrderSend().
Later the Magic number is parsed off by keeping them all a set number of integers long.
The currentLevel (for this it is the price of the pending order) is encoded, which is the price for this example but you could do the same for TP and/or SL.

for (int i = 0; i < OrdersTotal(); i++)
			if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
				if (OrderComment() == sText  &&  OrderType() == OP_BUYSTOP)
					if (ssssss)

This is not the full answer but I hope it gets you an idea if you think this will work.

1 Like