Simulating SL and TP indirectly

 

I like, to avoid brokers possible excessive slippage, make a routine that continuously check for my open positions and:

1. if profit of a position is above the wanted profit, close that position with minimal deviation.

    if the position is not successfully closed due to the deviation unachievable, then no problem, the next time my function runs, it will try and close it

2. same logic to exit position if loss above max loss.


Now my question is:

1. is it enough to use CTrade class with such commands as: 

 MyPosition.PositionClose(MyInfoPosition.Ticket(),myMaxDeviation);

  does this work? is the closing price updated automatically be MT5 software so I do not have to precise the level at which i want to exit?

2. or should i instead 

MyTrade.BuyLimit(LotSize,MyPrice,MyPair,MySL,MyTP,ORDER_TIME_GTC,expire,Mynote);

The truth I am confused about placing limit orders: what if they are not fulfilled, shall I continuously update the prices?

what if I update the price and then these orders are filled twice (ie the old one is still in memory, and price reach both prices)?

Thanks.

Reason: