Spread issues

 
Hi everyone i hope you are all doing well, i have an issue regarding an ea, it is high frequency trading ea that put 2 pending orders close to the current price, it contains a tight sl with a consideration of a broker min sl level and an aggressive trailing stop, the issue is it is sensitive to spread, how can i solve this ? 
thank you
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 

First thing to remember is that ...

  • A “buy” position opens at the Ask price and closes at the Bid price.
  • A “sell” position opens at the Bid price and closes at the Ask price.

Second, you should remember that there is always slippage (and delays) and the spread can change at any moment. So having to constantly adjust a pending order, or a position's stops to compensate, is going to cause extra network communication which broker's don't like (and it also adds lag). They may even ban you if you keep overloading their servers with so much traffic.

It is better to use Market orders, and to track changes locally and only issue the final position close order when the it is appropriate to do so according to your exit rules. You can still keep hard broker-side stops at a further distance for risk safety, but you should manage the "the high-frequency" adjustments on the client side only.