Job finished
Specification
Expert Advisor needed for MetaTrader4
System essentially looks for a large price movement, followed by a retracement to an EMA(x) line where a Limit Order has now been placed. The order direction – long or short – follows the direction of the original large movement.
Following use of the EA for backtesting, it will be necessary to finalize the EA to work on a real account, placing all of the necessary checks, standard handling of simple errors (requotes, invalid stops, etc).
EMA(x) and EMA(y) shown on 1hr
candlestick chart.
Rules of trade entry:
1.
When price diverges from EMA(x) by +
or – PIPS(xx)
on a 1hr chart, judged at the opening of the following 1hr bar (in order to
prevent EMA(x)
movement in real-time).
AND
When on the following 1hr candle there is at least PIPS(yy) gap between EMA(x) and the
Low (for going Long) or the High (for going Short) of the new candle…
Then place a Limit Order on EMA(x) in same direction as original PIPS(xx) + or
– movement. This Limit Order position will need to move as the EMA(x) is
re-drawn (re-accessed perhaps every 15 mins).
2.
Once that Limit Order trade is enacted by the price
touching EMA(x),
immediately place a StopLoss at PIPS(sl) and TakeProfit at PIPS(tp).
3.
Cancelling Limit Order: If the price/EMA(x) touch
has not occurred within further HOURS(z) candles then cancel Limit Order without placing
the trade.
4. Possible further order after initial EMA(x) trade. Ordinarily only one trade placed at a time. However, a second trade may be entered if the first trade is live AND price touches EMA(y). The same rules as above apply and this trade can only happen if there is a live EMA(x) initiated order in place
Rules of trade exit:
1. StopLoss hit.
2. TakeProfit hit.
3. Time/date (if end of trading period if specified) is reached.
Interface for backtest
When you run the Expert Advisor, it should attach the used indicators with the specified parameters. So for example, in order to assess the EA performance, indicators like arrows should appear on the chart showing where the PIPS(yy) decision was made, where the Limit Order is placed and where the StopLoss & TakeProfit are located.
The information on the opening/closing of positions and of modifications of the SL should be stored in the Journal;
If there are any errors, it must print a message describing the error.
IMPORTANT NOTE: I want to use this algorithm
both to backtest and trade and so the backtest must work as accurately to
trading reality as possible. In particular judgements over the gap between the
EMA(x)
and price are to be made looking at the 1hr chart. However, the actual
execution including StopLoss and TakeProfit
must be judged in real-time (1 minute is probably ok) in order to match
reality.
For testing Lot Size will be 1, but the EA should contain logic to increase Lot Size depending on retained profit from the strategy for use when actually trading.
For reference the system will run with an IG Index Spread MT4 account.
I hope to work with you for a long time, but either way I will want the source code and will own the rights.
Adjustable Testing Parameters:
1hr chart could be another time frame, but calculations must always be real-time tick by tick.
EMA(x) and EMA(y)
PIPS(xx)
HOURS(z)
PIPS(sl)
PIPS(tp)
Market open times (open & close time/date)
Market indicator being tested obviously