[EA development] Christmas present (MQL5 source)
Hello. This is 2pay.
Today is Christmas Eve, so a programmer Santa came up to deliver an EA.
With this, even people who have no plans to go out to town can spend time at home with a warm partner (the PC) and not get bored (verification).
Now, this time we prepared an EA that enters near round numbers (trend-following).
Recently, while thinking about the effectiveness of logic using round-number touches, I happened to read an article about an EA that uses round numbers.
To summarize the key points noted in it:
“Tokyo 24:00 (summer 23:00), that is, at the NYOpCut time, options are exercised at a round price, so liquidity increases near round numbers.”
That seems to be the case.
In USDJPY, if during that time (one-hour expiry) it touches a round number (increments of 1 yen, 0.5 yen, etc.), it would reverse-trade, and a six-year test confirmed effectiveness.
I had been validating approaches to round numbers for a long time, but I couldn’t make it work, so I was skeptical about the article’s content.
At that time I hadn’t thought of narrowing by time, so if I remake it, it might work.
・Currency: USDJPY
・Buy & Sell
・Tokyo 24:00 (summer 23:00): If EET/EEST, then 16:30 (prepare before the event)
・Entry allowed time: 1 hour
・Maximum holding time: 1 hour
・SL,TP: 1000.0 pips (kept far away from reachable positions, practically free)
・Round number: 0.5 yen (50.0 pips) increments
・Lot: fixed 0.01 (simple interest)
Round numbers do not have a width; when reaching (or breaking) a milestone, enter in reverse (counter-trend).
・Hit the milestone just below the current price: Buy
・Hit the milestone just above the current price: Sell
For discretionary traders, this logic might seem like scalping, but will it work as a quantitative logic?
USDJPY 2020-2025 M5 (variable spreads)
Result ↓
Not only did it not win, it lost.
I will change the entry time from 16:30 to the event start time (17:00).
Result ↓
It lost even more severely. Which part did you cut to think you could win?
When a logic has no edge, after deducting fees from profits and losses, it tends to settle near zero, but in this case it seems to lose even more significantly.
According to my calculation data, Gaitame’s average spread from 17:00 for one hour (outside campaign period) is 0.5 pips, so
Roughly calculating the fees: 775 trades * 5 yen = 3,875 yen
Total P/L -19,947 - (-3,875) = -16,072 yen
Perhaps reversing Buy and Sell (trend-following) might work.
// ---
※ Below is the EA we will give you this time (a version that makes the above content trend-following).
I’ll note a few rule changes when converting it to trend-following.
・Removed hold time limit (in this logic, applying time-based settlement tended to make profits random).
・Since there is no time-based settlement, changed SL, TP to practical values (some adjustments were made, but no optimization).
・Enter 2.0 pips before reaching the round number (just before approaching a milestone, it tends to move in the direction of the trend).
Result ↓
It became positive. Moreover, the growth curve looks fairly nice.
Below are the aggregated results at the entry time. (Backtest report is based on close time)
(The year 2020 is low because the historical data starting point is after mid-October 2020)
// ---
10-year test (2015-2024)
// ---
That was a long explanation, but once again this time I present the source code of this logic (MQL5) and the responsibilities that come with its use.
optimization has not been done yet, so please try various things.
The Sharpe ratio exceeds 2.0, so ""on the indicator side"" it is statistically significant (not a coincidence). (Please verify causality estimates individually.)
If you can interpret the trends of the aggregated results, there is plenty of room to improve performance.
If you can reduce unnecessary entries, the PF will improve.
I’m distributing it as a "verification" item, so if you plan to use it practically, I recommend strengthening position management.
Since I did not assign a magic number, using it in parallel with discretionary trading might cause discretionary positions to be settled automatically.
The source is simple, so if you want a simple level of magic assignment, I think someone would take on the task.
Copyright-free, but commercial use as-is is prohibited.
Please enjoy.
Thank you for reading to the end.
// ---
↓ Distribution materials are here ↓