Job finished
Specification
Hi dev,
I want to code a MQL5 EA as described below.
I can provide my custom tradingview pinescript v5 code as a reference.
*** Strategy description ***
The strategy looks for a specific 4 candle pattern to open long or short.
Current candle is candle 0, previous candle is 1 and so on.
For longs: Current candle closes above previous candle’s high (candle 1) and also closes above candle 3 high.
For shorts: Current candle closes below previous candle’s low (candle 1) and also closes below candle 3 low.
The candle pattern is only valid on bar close.
*** Entry conditions ***
Once a pattern is detected we will stop looking for new patterns until the trade is closed or cancelled. If the limit order is not triggered in X number of candles we cancel the limit order and restart looking for candle patterns. If before the trade is triggered we get a contrarian signal we also cancel the trade and open the last one to appear.
Here is the candle detection code in pinescript V5:
bool greenTriangle = close > high[1] and close > high[3] and not prevGreenTriangle
bool redTriangle = close < low[1] and close < low[3] and not prevRedTriangle
When the pattern is detected a limit order is set to X pips above the last candle for longs or under for shorts. This makes sure that the trade will only open if the price actually moves in the direction of the signal. If the price moves in the opposite direction we will end up canceling the order after X candles or a contrarian signal.
That’s all for the trigger conditions.
*** Exit conditions***
For exit we use a fixed stop loss value equal to X pips and a dynamic take profit that is a multiplier of the ATR value (period 7 candles and multiplier 0.7 for instance).
An open position should also be closed if we get an opposing candle pattern.
*** Position size ***
In terms of position size we risk losing 1% of the account per trade. If this results in a value bigger than the whole account we use 90% of the account as position size.
The strategy only keeps one long or one short open per time so there is no pyramiding.
It should be possible to define two time periods for opening trades per day. For instance from 08h00 UTC to 12h30 UTC and again from 14h30 UTC until 21h00 UTC.
Closing trades can be anytime since we defined the stop loss and take profit already.
We should have an icon indicating a long and one for short. Position entry price, stop loss and take profit should also be displayed.
Please see attached image for an idea of what it should do.
Thanks