Need expert help to add some function in this EA

 
To all MQL4 programmers,

I really need your help in adding & changing some function in this EA.

Have been applied this to MT4 chart for several months and found out that some adjustment have to be made to this EA in order to replace my manual trading.

Basic of this EA is Moving Average Crossover.

There are 2 adjustment to be made :

Example condition :
MA1 = Moving average with lower period (exp : MA 20)
MA2 = Moving average with higher period (exp : MA 50)
Timeframe : 15 minutes
Currency : Gbp/Usd
Spread between BID & ASK price : 4 point

1 ) This EA will open new position in the opening price of new candle whenever there is confirmation of MA1 cross MA2 in the current candle (basic MA crossover)

I need you to change this into :

*) This EA will open pending order (BUY/SELL limit) in the position of MA1/MA2 of new candle whenever there is confirmation of MA1 cross MA2 in the current candle (the MA1/MA2 option should be able to be choose in the EA setting).

*) The pending order will be adjusted accordingly to the MA1/MA2 level every new candle is created (this is needed when in the first new candle, the pending order is not executed).

*) And the pending order will be canceled if after X candle is not executed ( X is the candle count (exp : 1,2,3, etc) this should also be arranged in the EA setting)

*) When this pending order executed, it will triggered the EA to place Take Profit, Stop Loss & Trailing Stop (as per EA setting).

Example :
In the current candle, MA1 cross up MA2 and closed....(this is confirmation for opening BUY order in the new candle)
New candle condition : Open price 1.5000, MA1 position 1.4975, MA2 position 1.4950....All of this price is BID price as seen on MT4 chart.

In this 1st new candle, EA will place pending order (in this case Limit Buy at 1.4979 (BID price of MA1 position at 1.4975 + 4 point spread)) if in the EA setting I choose to open pending order at MA1 position.

when this pending order executed in the 1st new candle, then EA will place Take Profit, Stop Loss & Trailing Stop (as per my earlier setting, it would be fix point for all position made by this EA)

If in this 1st new candle, the pending order is not executed. Then in the next candle (which is the 2nd new candle) EA will change the pending order to the new MA1 position (when 2nd candle is created).

This "If" scenario will apply several times (according to my X candle setting explained above)


2) "Problem" that I found out during my time using this EA is :

When there is still open position (Take Profit, Stop Loss & Trailing Stop is in place and haven't been hit) and signal change (new signal triggered by MA1 cross MA2 in the opposite direction), this EA is only closed open position in the new candle & not executed new open position according to the new signal.

I need you to change this into :

*) This EA will close open position directly after confirmation of signal change in the new candle when Take Profit, Stop Loss & Trailing Stop haven't been hit (as done by this EA before)

*) And this EA will place new pending order according to new signal (as per condition you change in point 1)


Hopefully my above explanation is sufficient enough for your consideration.

Really need your help in changing this EA.

Awaiting reply.
Files:
Reason: