I need help for a EA code on MT4.
Below is the details:
1. MT4 should not execute any deal if there is any missing bar in the past data set, EA should check it against any probability of a problem to be lived in the DSL connection.
2. EA will work on more than 30 pairs simultaneously
3. It shold never add to a position if there is already an open position in a pair.
4. EA should a have portfolio risk constraint that it should have more than
Assuming that bid price is processed by the EA
5. long order at the bar T+1
Enter price: Minimum of (the Close Price of the bar T and the Typical Price (HLC/3) of the bar T) + typical spread for the relevant currency
Initial Stop Loss Price: (Lowest Low of the T,T-1 and T-2) – 1 tick
Condition:
a. if Close of the bar T > Highest Close of last 13 bars before the bar T (from T-1 to including T-13)
b. Ratio of: (Initial Stop Loss Price) / Enter Price >= 0.9970
c. Ratio of: ([Highest High of the T,T-1 and T-2] + spread + 1 tick) / Enter Price <= 1.0045
d. Ratio of: (Close of the bar T)/Enter Price >= 0.9970
Initial Target Price to halfen the position: enter price * 1.0045
Second Target Price to close the deal all: enter price * 1.0090
Trailing Stop: maximum of the following
a. High price of the actual bar (say it bar Z) * 0.9955
b. Close price of the bar (Z-1) * 0.9970
c. (Lowest Low of the Z-1, Z-2 and Z-3) – 1 tick
In case that 7 bars have passed after the signal bar and the trailing stop did not become bigger than the enter price price still then EA should close the position immediately.
6. short order at the bar T+1
Enter price: Maximum of (the Close Price of the bar T and the Typical Price (HLC/3) of the bar T)
Initial Stop Loss Price: (Highest High of the T,T-1 and T-2) + typical spread for the relevant currency + 1 tick
Condition:
a. if Close of the bar T < Lowest Close of last 13 bars before the bar T (from T-1 to including T-13)
b. Ratio of: (Initial Stop Loss Price) / Enter Price <= 1.0030
c. Ratio of: ([Lowest Low of the T,T-1 and T-2] – 1 tick spread) / Enter Price >= 0.9955
d. Ratio of: (Close of the bar T)/Enter Price <= 1.0030
Initial Target Price to halfen the position: enter price * 0.9955
Second Target Price to close the deal all: enter price * 0.9910
Trailing Stop: minimum of the following
a. Low price of the actual bar (say it bar Z) * 1.0045
b. Close price of the bar (Z-1) * 1.0030
c. (Highest High of the Z-1, Z-2 and Z-3) + spread + 1 tick
In case that 7 bars have passed after the signal bar and the trailing stop did not become lower than the enter price price still then EA should close the position immediately.