How do i close multiple positions?

 
Hello there!

I'm working on an Expert advisor. I want it to close all positions when there is a 2 pips retracement.

I utilize Ctrade Standard library to open and close positions.

Yes, I'm aware of the SetAsyncMode() method, but it doesn't solve the issue.

I tried orderSendAsync(), it still doesn't fix the issue.

Help please 🥺
 
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
 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
 
Hi
Based on your explanation i think you can use a trailing stop for your expert
 
Mohammadmahmood Pirayeh #:
Hi
Based on your explanation i think you can use a trailing stop for your expert
Hello 👋
 I tried that approach as well, though it work only when I set stop loss to 5pips below entry. When I tried to set it to 2pips I got an error, Invalid stoploss
 
Alfred Nwanokwai #: Hello 👋  I tried that approach as well, though it work only when I set stop loss to 5pips below entry. When I tried to set it to 2pips I got an error, Invalid stoploss

That is probably because you are violating the Stops Level or Freeze Level.

  • Setting the TakeProfit and StopLoss levels within the SYMBOL_TRADE_STOPS_LEVEL minimum level
  • Attempt to modify order or position within the SYMBOL_TRADE_FREEZE_LEVEL freeze level
  • The checks a trading robot must pass before publication in the Market
    The checks a trading robot must pass before publication in the Market
    • www.mql5.com
    Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
    Reason: