Is it possible to bypass a broker's minimum TP/SL points?

 

Hey people, the broker I'm using imposes that TPs and SLs should be set a certain points away from the entry price.

Around 2 months ago, I used this code that closes a position based on the profit it generated, I was able to bypass the broker's limitations.

        PositionSelect(_Symbol);
            if (PositionGetDouble(POSITION_PROFIT) >= 0.1){
               trade.PositionClose(PositionGetTicket(0));
            }
                

Now that I'm trying to use it in another EA, it doesn't work and the trades are closed at TP. Could've the broker somehow foundd a way to prevent users from bypassing their limitations? If you have some lines of code that could be helpful, please share them with me. Thanks :D

EDIT: I suspect it's because of the Sleep() function lasting half an hour after a trade is opened, if it is indeed the problem, how can I place an interval of half an hour between each trade all while leaving the EA being executed and thus executing my PositionClose() function?


EDIT2: The problem was indeed because of the Sleep(), I fixed it all while having the features I want by modifying the code like so and removing the Sleep() after a trade's execution. Shouldn't have posted so fast hahah, will this post up for future googelers.

PositionSelect(_Symbol);
            if (PositionGetDouble(POSITION_PROFIT) >= 0.1){
               trade.PositionClose(PositionGetTicket(0));
               Sleep(1800000);
            }
Documentation on MQL5: Common Functions / Sleep
Documentation on MQL5: Common Functions / Sleep
  • www.mql5.com
The function suspends execution of the current Expert Advisor or script within a specified interval. Parameters milliseconds [in]  Delay...
 
Aymane Maizi:

Hey people, the broker I'm using imposes that TPs and SLs should be set a certain points away from the entry price.

Around 2 months ago, I used this code that closes a position based on the profit it generated, I was able to bypass the broker's limitations.

Now that I'm trying to use it in another EA, it doesn't work and the trades are closed at TP. Could've the broker somehow foundd a way to prevent users from bypassing their limitations? If you have some lines of code that could be helpful, please share them with me. Thanks :D

EDIT: I suspect it's because of the Sleep() function lasting half an hour after a trade is opened, if it is indeed the problem, how can I place an interval of half an hour between each trade all while leaving the EA being executed and thus executing my PositionClose() function?


EDIT2: The problem was indeed because of the Sleep(), I fixed it all while having the features I want by modifying the code like so and removing the Sleep() after a trade's execution. Shouldn't have posted so fast hahah, will this post up for future googelers.

you are mixing up market execution with TP & SL.

TP & SL levels often have a minimum distance from current price requirement when placing (broker dependent), but they are just pending orders to be triggered at a given price.

The code you show executes a market order to close the position at current bid/ask  so not the same thing at all as it has nothing to do with SL or TP.

 
Paul Anscombe #:

you are mixing up market execution with TP & SL.

TP & SL levels often have a minimum distance from current price requirement when placing (broker dependent), but they are just pending orders to be triggered at a given price.

The code you show executes a market order to close the position at current bid/ask  so not the same thing at all as it has nothing to do with SL or TP.

Thank you :D

 
You leave TP and SL as 0.0 in the code if there should be no TP or SL. But the caveat is that some brokers do not allow you to have no TP set in automated trading.