how to close all position except the most old one? - page 2

 
GHH_tug77 #:

okey okey I changed the code and inserted it. Please check it? Is it correct? Now it leaves the most old position?

No. There is no guarantee the last (or first depending in which direction you are "looking") index would be the oldest position.
 
Alain Verleyen #:
No. There is no guarantee the last (or first depending in which direction you are "looking") index would be the oldest position.

okey how to change the code for correct solution?

 
GHH_tug77 #:

okey how to change the code for correct solution?

Check the date/time of all the positions, record the ticket of the oldest one. Then exclude this ticket from the positions to close.
 
Alain Verleyen #:
Check the date/time of all the positions, record the ticket of the oldest one. Then exclude this ticket from the positions to close.

pls help me. I am very newbie in Mql5. Checking date/time, recording ticket is very hard to me. Pls

 
GHH_tug77 #:

pls help me. I am very newbie in Mql5. Checking date/time, recording ticket is very hard to me. Pls

Please help you yourself.

  • Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
  • 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).
  • Finally, you also have the option to hire a programmer in the Freelance section.
  •  
    Alain Verleyen #:

    Please help you yourself.

  • Usually people who cannot code do not receive free help on this forum, although it could happen if you are lucky. Be patient.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community.
  • 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).
  • Finally, you also have the option to hire a programmer in the Freelance section.
  • okey okey pls give me example of checking date/time, recording ticket and exclude ticket which is oldest.

     
    GHH_tug77 #:

    okey okey pls give me example of checking date/time, recording ticket and exclude ticket which is oldest.

    Quickstart for newbies: https://www.mql5.com/en/articles/496
    and: https://www.mql5.com/en/articles/100
    cookbook: https://www.mql5.com/en/search#!keyword=cookbook
    or https://www.mql5.com/en/search#!keyword=Tips%20from%20a%20professional%20programmer&module=mql5_module_articles

    Quick Start: Short Guide for Beginners
    Quick Start: Short Guide for Beginners
    • www.mql5.com
    Hello dear reader! In this article, I will try to explain and show you how you can easily and quickly get the hang of the principles of creating Expert Advisors, working with indicators, etc. It is beginner-oriented and will not feature any difficult or abstruse examples.
    Reason: