Restructure Repairs
- Get link
- X
- Other Apps
08/01/25 1:28 pm
Not much happening the last couples days, still working through getting all the code functioning properly after the validation restructure. Momentum calcs totaly malfunctioned so fixing that but also putting in code to ensure everything is working the way it should be working since it is becoming more complex with the layers of validation there needs to be checks to maintain functionality consistently.
3:24 pm
This is the thread I was talking about... If you have some time it is a good read.... One thing also I have found that is common is to have the lot size set as a % of total balance so it increases exponentially as it progresses....
Success! I've been working on this EA for about a month and I finally got the max drawdown under 10% . Back test results are starting from $1000.00 at 50:1 leverage on the EURUSD from Jan 2022 - today. Thoughts?
Update: After following suggestions from other members in the thread I extended the back test to 14 years instead of 2 years and it still performs. Photos in thread.
All reactions:
202043 comments
Like
Comment
Send
Share
Most relevant
Edward Przepiora
I have been working on similar strategies for DAX also for a while. Tough cookie it is.
- Like
- Reply
- Share
Thomas Trejo
Author
Edward Przepiora yea sir. I actually applied the ADX to this strategy to see if it would help. I set it to filter the trades where they would only trigger if the ADX was over a set value, such as 25,50,75 etc ... It would only minimize the trades in one way or another without ever improving the performance. I ended up using a filter found in a random book. The 2 period RSI with thresholds at 80 and 20. Worked like a charm.
- Like
- Reply
- Share
Edward Przepiora
Thomas Trejo so you smoothly switch from range to trend I take it by testing price action. I have worked on a strategy that adds to decreasing PnL side in anticipation that goes on increasing, similar to a traditional way of buying dips, also works upto a point.
- Like
- Reply
- Share
Thomas Trejo
Author
Edward Przepiora yes sir. I'm thinking of using the current days range in comparison to the previous days average true range to come up with a filter that triggers between this logic and a range logic.
- Like
- Reply
- Share
Edward Przepiora
It noticed you can write these things either for a range or trend. As one can work the other won't. The bit which switches from one to another is usually the most important and difficult. We'll done.
- Like
- Reply
- Share
Thomas Trejo
Author
Edward Przepiora precisely. You could not be more correct on that one. This one doesn't even take trades unless the Intraday trend is strong. It over looks ranges or exits immediately if the trend is week, which is what keeps the drawdown under 10. I actually made an adjustment to it since I submitted this post days ago, and now the draw down is under 7 percent. I think I will build a version for ranges this week and then combine them.
- Like
- Reply
- Share
Dimitar Shterev
There are few things that I don't like in the results. Leaving them aside more important thing is that 3 years backtests is not enough. Just pick another 3 years span between 2010 and will you see that probably the results will vary much in drawdown as in performance.
- Like
- Reply
- Share
- Edited
4'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint1_radial_15251_63610)'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint2_radial_15251_63610)' fill-opacity='.5'/%3E%3Cpath d='M7.3014 3.8662a.6974.6974 0 0 1 .6974-.6977c.6742 0 1.2207.5465 1.2207 1.2206v1.7464a.101.101 0 0 0 .101.101h1.7953c.992 0 1.7232.9273 1.4917 1.892l-.4572 1.9047a2.301 2.301 0 0 1-2.2374 1.764H6.9185a.5752.5752 0 0 1-.5752-.5752V7.7384c0-.4168.097-.8278.2834-1.2005l.2856-.5712a3.6878 3.6878 0 0 0 .3893-1.6509l-.0002-.4496ZM4.367 7a.767.767 0 0 0-.7669.767v3.2598a.767.767 0 0 0 .767.767h.767a.3835.3835 0 0 0 .3835-.3835V7.3835A.3835.3835 0 0 0 5.134 7h-.767Z' fill='%23fff'/%3E%3Cdefs%3E%3CradialGradient id='paint1_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(90 .0005 8) scale(7.99958)'%3E%3Cstop offset='.5618' stop-color='%230866FF' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%230866FF' stop-opacity='.1'/%3E%3C/radialGradient%3E%3CradialGradient id='paint2_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(45 -4.5257 10.9237) scale(10.1818)'%3E%3Cstop offset='.3143' stop-color='%2302ADFC'/%3E%3Cstop offset='1' stop-color='%2302ADFC' stop-opacity='0'/%3E%3C/radialGradient%3E%3ClinearGradient id='paint0_linear_15251_63610' x1='2.3989' y1='2.3999' x2='13.5983' y2='13.5993' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2302ADFC'/%3E%3Cstop offset='.5' stop-color='%230866FF'/%3E%3Cstop offset='1' stop-color='%232B7EFF'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E)
Thomas Trejo
Author
Dimitar Shterev I've been building for about seven years now... and you will find a time period where any strategy fails if you look back far enough. This one is profitable with minimal drawdown for over 1000 trades on two different assets. I figured I would deploy it and then adjust it if it breaks below 10% drawdown at some point.
- Like
- Reply
- Share
Dimitar Shterev
Did you set and include any commissions for the backtest result?
- Like
- Reply
- Share
Thomas Trejo
Author
Dimitar Shterev I'm trading through OANDA and IG from the US and I don't pay commissions on trades...I pay the spread for each trade...so I set the back test spread to 2 pips even though the spread on EURUSD is typically under 1 pip, just to put some pressure on the performance. So In theory, it will do a even better with a realistic spread.
- Like
- Reply
- Share
- Edited
Dimitar Shterev
Ok, I understand. Paying the 2-pip spread is much cheaper than what I pay to EU brokers. Anyway, the strategy seems amazing. There is only one period in 2020 with negative performance lasting for a year, but that's understandable since it was during COVID. There aren't any other negative performing years, are there?
- Like
- Reply
- Share
Thomas Trejo
Author
Dimitar Shterev I was looking at that as well and I thought about going to that year and curve fitting but I stopped myself lol. That type of thinking is likely to screw up a long term profitable strategy. I think it's time to hit the deploy button, and close my lap top, and check it at the end of the year. Do they allow us to post videos? I can post a video of the back test that might be better?
- Like
- Reply
- Share
Samuel-Dean McMurran
Kudos for sharing this openly. Never easy and this is the way you’ll learn.
- Like
- Reply
- Share
2'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint1_radial_15251_63610)'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint2_radial_15251_63610)' fill-opacity='.5'/%3E%3Cpath d='M7.3014 3.8662a.6974.6974 0 0 1 .6974-.6977c.6742 0 1.2207.5465 1.2207 1.2206v1.7464a.101.101 0 0 0 .101.101h1.7953c.992 0 1.7232.9273 1.4917 1.892l-.4572 1.9047a2.301 2.301 0 0 1-2.2374 1.764H6.9185a.5752.5752 0 0 1-.5752-.5752V7.7384c0-.4168.097-.8278.2834-1.2005l.2856-.5712a3.6878 3.6878 0 0 0 .3893-1.6509l-.0002-.4496ZM4.367 7a.767.767 0 0 0-.7669.767v3.2598a.767.767 0 0 0 .767.767h.767a.3835.3835 0 0 0 .3835-.3835V7.3835A.3835.3835 0 0 0 5.134 7h-.767Z' fill='%23fff'/%3E%3Cdefs%3E%3CradialGradient id='paint1_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(90 .0005 8) scale(7.99958)'%3E%3Cstop offset='.5618' stop-color='%230866FF' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%230866FF' stop-opacity='.1'/%3E%3C/radialGradient%3E%3CradialGradient id='paint2_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(45 -4.5257 10.9237) scale(10.1818)'%3E%3Cstop offset='.3143' stop-color='%2302ADFC'/%3E%3Cstop offset='1' stop-color='%2302ADFC' stop-opacity='0'/%3E%3C/radialGradient%3E%3ClinearGradient id='paint0_linear_15251_63610' x1='2.3989' y1='2.3999' x2='13.5983' y2='13.5993' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2302ADFC'/%3E%3Cstop offset='.5' stop-color='%230866FF'/%3E%3Cstop offset='1' stop-color='%232B7EFF'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E)
Thomas Trejo
Author
Samuel-Dean McMurran Thank you. Building ATPs is my passion. I've been doing it for many years now and I'm just happy I found this group so that I can commune with people that understand my language!
- Like
- Reply
- Share
2'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint1_radial_15251_63610)'/%3E%3Cpath d='M16.0001 7.9996c0 4.418-3.5815 7.9996-7.9995 7.9996S.001 12.4176.001 7.9996 3.5825 0 8.0006 0C12.4186 0 16 3.5815 16 7.9996Z' fill='url(%23paint2_radial_15251_63610)' fill-opacity='.5'/%3E%3Cpath d='M7.3014 3.8662a.6974.6974 0 0 1 .6974-.6977c.6742 0 1.2207.5465 1.2207 1.2206v1.7464a.101.101 0 0 0 .101.101h1.7953c.992 0 1.7232.9273 1.4917 1.892l-.4572 1.9047a2.301 2.301 0 0 1-2.2374 1.764H6.9185a.5752.5752 0 0 1-.5752-.5752V7.7384c0-.4168.097-.8278.2834-1.2005l.2856-.5712a3.6878 3.6878 0 0 0 .3893-1.6509l-.0002-.4496ZM4.367 7a.767.767 0 0 0-.7669.767v3.2598a.767.767 0 0 0 .767.767h.767a.3835.3835 0 0 0 .3835-.3835V7.3835A.3835.3835 0 0 0 5.134 7h-.767Z' fill='%23fff'/%3E%3Cdefs%3E%3CradialGradient id='paint1_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(90 .0005 8) scale(7.99958)'%3E%3Cstop offset='.5618' stop-color='%230866FF' stop-opacity='0'/%3E%3Cstop offset='1' stop-color='%230866FF' stop-opacity='.1'/%3E%3C/radialGradient%3E%3CradialGradient id='paint2_radial_15251_63610' cx='0' cy='0' r='1' gradientUnits='userSpaceOnUse' gradientTransform='rotate(45 -4.5257 10.9237) scale(10.1818)'%3E%3Cstop offset='.3143' stop-color='%2302ADFC'/%3E%3Cstop offset='1' stop-color='%2302ADFC' stop-opacity='0'/%3E%3C/radialGradient%3E%3ClinearGradient id='paint0_linear_15251_63610' x1='2.3989' y1='2.3999' x2='13.5983' y2='13.5993' gradientUnits='userSpaceOnUse'%3E%3Cstop stop-color='%2302ADFC'/%3E%3Cstop offset='.5' stop-color='%230866FF'/%3E%3Cstop offset='1' stop-color='%232B7EFF'/%3E%3C/linearGradient%3E%3C/defs%3E%3C/svg%3E)
Mindaugas Bene
Use date since 2010 as minimum. Too short period of time.
- Like
- Reply
- Share
Thomas Trejo
Author
Mindaugas Bene Dimitar Shterev I expanded my trigger to 4H and back tested to 2010 like you guys recommended. Thank you for the suggestion by the way... It returned a little over 2000% but who wants 80% a year ?
I guess if you have 100, 000.00 in capital that might be a good return for side income.

- Like
- Reply
- Share
Tane Wallace
To me that's super impressive for a months work. Been building them for a while have you?
- Like
- Reply
- Share
View 1 reply
Chibuike Azubuike
Is it a Martingale or Antimartingale Strategy?
- Like
- Reply
- Share
Thomas Trejo
Author
Chibuike Azubuike I've personally never used or believe in martingale money management. This build simply risks .025% of current balance per trade and each trade uses a stop loss size of the 5M ATR14.
- Like
- Reply
- Share
Carlos Ortega
Watch out for the z-score; the z-score is very important.
- Like
- Reply
- Share
- Like
- Reply
- Share

FOREXTRADERS.COM
Using The Z-Score to Determine Position Size
- Like
- Reply
- Share
Charles Umani
Where are robustness tests ?
- Like
- Reply
- Share
Thomas Trejo
Author
Charles Umani do you mean emulating slippage? I've run them and they don't harm the performance. Sometimes it even improves the performance actually. I've also doubled and tripled the spread to an unrealistic amount on the back test and it still performs well.
- Like
- Reply
- Share
Thomas Trejo
Author
Red Blue correct. The algorithm does not attempt to choose the right direction or entry. It places trades and exits them immediately when they show weakness, while allowing them to run when they move into the right direction. It's the only strategy style that I've found to maximize profit and keep drawdowns very small over long time periods.
- Like
- Reply
- Share
Red Blue
Thomas Trejo but it chooses when to enter and whether to go long or short, and if it doesn’t confirm, it exits, right? Are you trading momentum or levels (mean reversion, trend following..)?
- Like
- Reply
- Share
- Edited
Thomas Trejo
Author
Momentum. When the ATR of a certain time frame starts to rise, it places two buy orders and two sell orders a certain multiple of the ATR above and below the price. On competition of every new bar, the orders are deleted and replaced immediately with the newest volatility data. Eventually if the momentum breaks in either direction fast enough, it will trigger an order before it gets deleted. When this happens, statistically the momentum continues in that direction for a certain amount of time (not distance). A time based exit is used to take profit instead of a price level but I will keep that little part to myself as it took many years to discover 

Anyway, that is the basic premise. I gave up trying to time the markets turning points with different automation tactics because none of it works long term. I look at the market like a wild animal now. No one knows what it's going to do next so I just lay traps for it so that I can profit when it goes crazy.
- Like
- Reply
- Share
Red Blue
Thomas Trejo If you have identified a momentum duration that has been confirmed with statistical calculations, that's excellent.
Probabilistic models are always the best.
- Like
- Reply
- Share
Red Blue
Thomas Trejo you can use kelly creterion to define your exposure and your risk management
With your results I think your kelly creterion will be around 0.4 so half kelly or even 0.75 kelly will be a good part to reinvest :
If you don't put sl I recommand to set it, you can use the worst observed (or 0,05 percentile to eliminate noise) or find the best that optimize ur results
- Like
- Reply
- Share
Thomas Trejo
Author
Red Blue agreed. This EA allocates .25% current balance per trade. To be completely honest... I've been doing this for seven years now and I could not tell you how to manually calculate lot size because I always have my EA do a percent based allocation lol
- Like
- Reply
- Share
Red Blue
But the curve you showed, is it with compounding or fixed lot size ? It looks linear rather than exponential. 



- Like
- Reply
- Share
Thomas Trejo
Author
Red Blue every position risks .25 of current balance. The algorithm chooses the closest lot size to that percentage. It compounds, it just looks linear. The 14 year back test returns 2.6 million from an initial balance of 1,000.00 at 12% drawdown. The 14 year balance curve has the accelerated curve that you are expecting to see.
- Like
- Reply
- Share
Thomas Trejo
Author
Red Blue there are many ways to set money management for an algorithm but I always stick to % of balance as you can see from this screen shot
- Like
- Reply
- Share
Red Blue
Thomas Trejo It’s quite strange, the effect of compounding seems slow to me.
To give an example of my strategy for a single year, like 2024, with 1 Nasdaq lot, I make $90,000.
If I activate compounding, I reach $400 Millions in the same year.
If I apply it since 2018, I reach several trillions (on paper 

).



Of course, it's not realistic since I can't guarantee entry prices for thousands of lots, but nevertheless, the effect of compounding is remarkable.
Knowing that I have a profit factor and Sharpe ratio close to yours, 2.8 and 7, with an initial investment of $5,000,
perhaps it's due to the win rate over the period.
In any case, you have great results; I think you could be more aggressive in your risk management.
- Like
- Reply
- Share
Red Blue
I found the reason: your flat periods are quite long, and the losses are severe, which breaks the momentum of compounding. That’s why
.

The problem with compounding is that a significant loss makes it take a lot of time to return to the previous balance all-time high (ATH).
So I agree .25 is a good risk ratio
Good luck and many thanks for sharing that
- Like
- Reply
- Share
Thomas Trejo
Author
Red Blue yes sir! You are correct about the lengthy but shallow drawdown periods. Thank you for your contribution and happy building!
- Get link
- X
- Other Apps
Comments
Post a Comment