Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Follow Last Candle EA (Follow Last Candle EA) - MT4/MT5 Resources

author EAcpu | 2 reads | 0 comments |
First: I will update this initial post (if possible) to keep it current.

The Follow the Last Candle EA is a reaction to Robinho's "Follow the monthly candle, take profit" - thread.
When I first heard about this trading strategy, I was skeptical of its effectiveness. But since its ruleset is simple, I decided to make an EA to backtest it.

While I saw very promising backtest results, forward testing showed very different results.

However, if you want to try a similar strategy,

  1. Open a pending order in the direction of the last candle (follow the last candle)
  2. Follow the last candle, but only if the candle body is large enough (e.g. greater than 70% of the entire candle size)
  3. Follow the last candle, but only if the last candle on the larger time frame went in the same direction
  4. Follow the last candle, but only if the last candle on the larger timeframe went in the same direction and also had a large enough body
  5. Set pending orders in two directions (for example, above and below the last candle)
  6. Set pending orders only on specific days/times (e.g. only on Thursdays between 1am and 7am)
  7. Money management settings (fixed lot size or maximum risk percentage)



set up

Trade options
Trade Review <br> This will be added to every trade placed by the EA. It will be visible in the transaction history.

Transaction Frequency <br> Your trading schedule. Trading will occur based on this time frame.
Possible settings are: Daily, Weekly, Monthly

Wider time range <br> If necessary, you can refer to a larger time frame.

For example: If you want to track daily candles, but only when monthly candles have the same direction, you have to set the options as follows:
Transaction frequency = daily <br> Larger time frame = monthly <br> Trading Style = " Follow the last candle if the larger time frame has the same direction "

Possible settings are: Daily, Weekly, Monthly

Reference price <br> Here you can select the exact price to refer to when placing new pending orders.
Possible settings are:

  1. last candle close
  2. The opening price of the current candle
  3. Current price (bid=short, ask=long)
  4. High and low prices of the last candle
  5. The high and low of the current candle


Transaction methods <br> Possible settings are:

  1. Focus on the last candle <br> Set a pending order in the direction of the last candle.
  2. Focus on the last larger time frame <br> Place a pending order in the direction of the last candle in the larger time frame.
    For example: Larger time frame = monthly , trading frequency = daily . If the last monthly candle was long, now you will receive new pending long orders every day.
  3. If the larger timeframe has the same direction, follow the last candle <br> Place a pending order in the direction of the last candle, but only if it is the same direction as the last candle of the larger timeframe.
  4. Short and long, only trade the first hit (not implemented!)
    I don't have time to complete this option.
  5. Go short and long, trade simultaneously <br> This option places orders in both directions.


Adjust prices if necessary <br> Sometimes, pending orders cannot be opened due to gaps. Here you can define whether the reference price should be adjusted in this case.
Possible settings:

  1. No price adjustment
  2. The opening price of the current candle
  3. Current price (bid=short, ask=long)
  4. The high and low of the current candle


SL, TP and PointsAway formats <br> It is necessary to know the number of digits after the comma in the price. But the EA should recognize it automatically. However, if you find that your TP and SL are nowhere near where they should be, you may want to manually adjust this option.

" TP ", " SL " and " far point "
Take Profit (TP) and Stop Loss (SL) should be clear.
" Far Point " defines how far from the reference price a new pending order will be placed.
For example: a long trade with reference to price " Last Candle High Low " and a PointAway of 10 would place a pending order 10 points above the last candle's high. This avoids your order being activated by only one point.

Minimum candle body percentage and minimum greater TFBodyPercent
Here you can define the minimum percentage of the last candle's body size. This way you avoid getting stuck with candles that have no clear direction.

Expiry time of pending order (minutes)
If you don't want the pending order to exist forever, you can set a certain number of minutes here so that it will be deleted if it is not yet active.

Wait for the next candle to trade <br> This option causes the EA to wait for opening orders until a new candle starts within the trading time frame. This is an important option for real accounts and it should behave this way!
So if you want the EA to place orders immediately when you activate it, then you must set this option to " False "!!!

Money management
Use fixed order size <br> Use " true " if you want a fixed order size.
Use " Error " if you want to use the dynamic lot size calculated by the EA (based on your account equity).

Fixed order size <br> If you use a fixed lot size, you can set the lot size here.

Order size percentage <br> If you use dynamic lot size, you can set the percentage of account equity used for stop loss here.

Minimum order size and maximum order size <br> Manually set minimum and maximum lot size. It only applies if you set the next option to "False".

Get minimum and maximum lot size from broker <br> If "True", the EA will get the minimum and maximum lot size for the current chart from the broker.

Whole lot size <br> If you use dynamic lot size, you can choose here whether the calculated lot size is rounded up or down.
Why? Because you cannot trade 0.018472 lots and the EA has to decide whether to use 0.01 or 0.02. This can make a big difference.
Possible settings: Round up, Round down, Round up or Round down

EA settings
Execute EAOn
Define whether the EA is executed on every price change or periodically.
Possible options: tick, timer

Second timer <br> You can set the interval (in seconds) here if you want to execute the EA on " timer ".

magic number offset
The way the EA identifies short and long trades is very ugly; it just provides them with magic numbers 100 and 1000. If this interferes with another EA you have, you can change the magic number by adding a MagicNumberOffset to the magic number.

Replacement Order <br> You will most likely want to turn this option off. If turned on, no new pending orders will be placed if there are already active pending orders.

Maximum Slippage <br> Set the maximum allowed slippage. Please note that this feature may not work if your Broker does not support this feature (i.e. Brokers default method is Market Execution )

Supports ECN brokers <br> If set to " real " SL and TP will be set individually after placing an order, ECN brokers are supported.

market time
Use manual market time <br> Set it to " Real " if you want to use manual trading time.
IMPORTANT: The format must be exactly "00:00-00:00", otherwise the EA will exit with an error message on launch.

Debug messages <br> If something is not performing as expected, debug messages can help understand what the EA is doing. You can see them in the "Experts" tab of the terminal.
If the EA is executed on every Tick, I strongly recommend not to open PrintStillAliveMessage. It attempts to write a message on every tick, which may slow down your computer significantly.

BTW: the whole EA is based on another EA with very old legacy code that is very annoying to use.
I plan to make a new EA from scratch in the next few months with a maintainable code base. But I can’t commit for sure because my life is filled with uncertainty.

And all I know is that there is a non-trivial bug in the latest version, use it at your own risk and for demonstration purposes only , I disclaim any responsibility for what you do with it!

Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG
Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG
Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG
Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG
Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG
Closing Candle Bear SELL.JPGClosing Candle Bull BUY.JPG

Attachment to original post (1)

Verification code Refresh