Request help EA code --- (1) after the specific order closed (2) repeat a block

 
hi there, i am a newbies and having difficulties to write a code about the 2 concepts below into expert advisor,

=================================================================================================================
(Concept 1) Open a new pending long order AFTER a previous order closed (either by stop loss or take profit).

Example 1:


A 0.2lots BUY order of EURUSD (bought at 1.3450, TP=20pips, SL=40pips, we give name as TICKET1) just hit take profit at 1.3470 and just closed.
AT THIS MOMENT, the EA will be triggered to open a BUYLIMIT order at 1.3450 (same price as earlier BUY order, with TP=20pips, SL=40pips, 0.2lots, we give name TICKET2).

*** how can Example 1 be coded into EA?

=================================================================================================================
(Concept 2) Repeat a process (unlimited times, as long as conditions are correct).

Example 2:
(actually it is an extent of Example 1)

A 0.2lots BUY order of EURUSD (bought at 1.3450, TP=20pips, SL=40pips, we give name as TICKET1) just hit take profit at 1.3470 and just closed.
AT THIS MOMENT, the EA will be triggered to open a BUYLIMIT order at 1.3450 (same price as earlier BUY order, with TP=20pips, SL=40pips, 0.2lots, we give name TICKET2).

After 1 hour, the EURUSD price move down and hit the BUYLIMIT TICKET2 at 1.3450. After 2 hours then, TICKET2 is closed after TP is hit at 1.3470.
Then, EA IS TRIGGER AGAIN to open a SAME BUYLIMIT order at 1.3450 (same price as earlier BUY order, with TP=20pips, SL=40pips, 0.2lots, we give name TICKET3 now).

*** Any ideas how to code [repeating CLOSED and TRIGGER a new BUYLIMIT order unlimited times] situation source code?

=================================================================================================================

Thank you very much for your help to solve my difficulties.
Reason: