code for trailing stop

 

hi, can somebody help me code trailing stop EA, the rule pic below

thanks

Files:
Trailing.png  31 kb
 
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

  2. Until you can state your want in concrete terms it can not be coded.

    1. “positif 20 pips” is meaningless; Bid twenty pips above OrderOpenPrice is not.
    2. “Trailing Stop 2pips from OP” is meaningless; that is a constant. At a profit of 20 pips move SL to BE+2pips is not.
    3. “After reach next 20 pips, SL move up 12 pips” is meaningless? Are you trailing by 28 pips (except for the initial move to break even+2)? Are you moving SL in steps?
    4. “Do something if” is meaningless.
    5. This can be coded.

      if OSL < OOP and market - OOP > 12 pips move SL to OOP+2 pips
      new SL = Bid - 28 pips; if new SL > OOP move SL to new SL

  3. PIP, Point, or Tick are all different in general.
              What is a TICK? - MQL4 programming forum 2014.08.03

    Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points), and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 programming forum 2017.02.09
              Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum 2018.01.15

 
William Roeder:
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

    We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
              No free help 2017.04.21

  2. Until you can state your want in concrete terms it can not be coded.

    1. “positif 20 pips” is meaningless; Bid twenty pips above OrderOpenPrice is not.
    2. “Trailing Stop 2pips from OP” is meaningless; that is a constant. At a profit of 20 pips move SL to BE+2pips is not.
    3. “After reach next 20 pips, SL move up 12 pips” is meaningless? Are you trailing by 28 pips (except for the initial move to break even+2)? Are you moving SL in steps?
    4. “Do something if” is meaningless.
    5. This can be coded.

      if OSL < OOP and market - OOP > 12 pips move SL to OOP+2 pips
      new SL = Bid - 28 pips; if new SL > OOP move SL to new SL

  3. PIP, Point, or Tick are all different in general.
              What is a TICK? - MQL4 programming forum 2014.08.03

    Unless you manually adjust your SL/TP for each separate symbol, using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points), and metals. Compute what a PIP is and use it, not points.
              How to manage JPY pairs with parameters? - MQL4 programming forum 2017.02.09
              Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum 2018.01.15

thanks for idea, this is my code :

<Deleted>

the first idea (after reach 20 pips start trailing 2 pips) already work, but second idea after reach next 20 pips (total 40 pips) should be SL move to 12 pips (Trailing step + BEP+ 2pips)not work yet.

 
Please edit your post and use the code button (Alt+S) when pasting code.
EDIT your original post, please do not just post the code correctly in a new post.
 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.

thanks your information keith