- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- Can someone explain to me, how to get all trades to close at the same place.
- Please fix this indicator or EA
It is a swing based strategy that I'm trying to make autonomous with automation, but clearly it seems that reality does not bend to strategies...strategies must bend to reality.
Sometimes a strategy seems good enough, but it isn't good enough. There are many things that look good enough to the naked eye, but the market is war and randomness, not a utopia. So I'm thinking what you will say is "change the strategy" which...indeed might be the only real solution sometimes. I'm just seeing first of all how far "trade surgery" can come when it comes to profitability.
As far as I can tell from the description, your issues are not directly related to coding of itself, but about the skill and knowledge one gains by actual trading and understanding the markets, as well as statistical analyses.
For one, in quantitative or algorithmic trading, when devising or applying a strategy, one should fully understand the statistical probabilities of the strategy and how its rules affect metrics. It should not be about fumbling about trying to fix deviations in the trades.
Here are some tips:
- Analyse and know the MAE and MFE properties of your basic strategy rules for the symbol and time-frame in question. If the e-ratio is not sufficiently good enough, then no matter how you tinker with trade management, it's not going to improve much. Analyse these properties on the most basic of the strategy's entry and exit rules without any management extras that will hide the true underlying metrics.
For example, if analysing a stop & reverse moving average crossover strategy, then analyse that basic rules, without stops or targets. You should fully analyse if the basic principle of the strategy has merit or not, before trying to fine tune its management.
Also analyse how the MAE and MFE evolves over the life-time of a position, to see if a time based stop, instead of a price based stop, may be beneficial, or if both types should be used.
MAE : Maximum Adverse Excursion
MFE : Maximum Favourable Excursion
e-ratio : Edge Ratio (normalised MFE divided by the normalised MAE)
- Analyse and know what volatility the symbol exhibits at the time-frame you expect to use. Consider both the average of the true-range (ATR) as well as the variance of that average. The average alone is not enough information. You should also consider the average and variance of ranges between swinging points too. One should never place a stop-loss, or apply a trailing-stop, or move to break-even simply based on an arbitrary fixed number of points. It should instead take into consideration the true volatility exhibited by the symbol at that time-frame, and this should adapt to changes as the conditions evolve over time.
- Adjust your position size based on a small percentage of your capital and the maximum drawdown you are willing to accept. For example, if you normally risk 1% per trade, and only accept a maximum of 10% drawdown, then your true risk per trade should be 1% of (10% of your balance), and not merely just 1% of the entire balance. In this way, during a drawdown, as the balance drops, so does the risk, to the point that it becomes 0% at the maximum drawdown allowed. Keep track of your maximum balance, so that you can calculate your current drawdown and adjust the risk accordingly with this method.
There are other methods of money management that take into account the drawdown. The one above is just one that I often use, but there are others. Do some research on various money management methods to find one that best fits your needs and trading style. Here is a starting point ... Money Management Models
And remember that the risk position size is dependant on both the initial stop-loss and the margin requirements, not one or the other alone (edited as per post #5).
- Also, there is no such thing as a trailing take-profit (that is just a gimmick). If all the points described above are sound, then only a trailing stop-loss can be of any use, but only if the metrics demonstrate that it's effective. Conditions that do not demonstrate consistent trending, will not benefit from trailing stops, and can even be detrimental. If you have ever studied "Random Walk" theory, you will have noticed that a trailing stop is detrimental for unbiased random walks. It is only useful during strongly biased random walks.
When applying a trailing-stop or a move to break-even, always base them on both the volatility conditions, as well as the MAE/MFE analysis. Don't just apply them willy-nilly.
PS! Sometimes partial take-profits at various levels can be more effective than a trailing stop. Sometimes a combination of both can also do well. So study the metrics to see which methods to use.
I appreciate the tips. But I should mention that I wanted to test beyond 1% risk, not for a real account, but to test how a strategy might hold with very aggressive position sizing. My goal was/is to push strategies to the limit. I understand that a trailing TP might seem bizarre, but what I mean by a trailing take profit, is to trail the TP against something that moves, for example - an ATR band (MA + ATR * Multiplier). I don't like to have a statically placed take profit. An initial one is fine, but if the TP can move with something, I prefer that. ATR doesn't change too speedily on the price if higher periods are used, and that's why something like band crossovers are possible (also with standard deviation bands).
I will look into designing a more complex breakeven function which isn't based on an arbitrary number of points. I'll see what can be done with ATR variance as well. I guess you can go quite deep with automation.
And remember that the risk is dependant on both the initial stop-loss and the margin requirements, not one or the other alone.
Can you elaborate on this ? Not sure what you mean exactly.
If I want to risk 100$ for example, so if my SL is triggered I will lose 100$, I don't see how the margin requirements influence that. Of course margin requirements are important too, but not for THIS risk.
Yes you are correct, I did not explain it very well. Basically, what I meant to imply was that if you calculate your position size on stop-loss alone, you run the risk of a high deposit load (which could lead to a margin call or even a margin stop-out). For example, this could happen with a very small and tight stop-loss and a high risk appetite, causing the calculated volume to have a very high margin requirement.
Also on some brokers/markets, the required margin is deducted from your equity directly, leaving you with less equity available to cover the stop-loss. Once the position closes the margin is released again. They probably do this as an alternative to the margin call/stop-out method. I am not really sure why they do it this way but I have seen it before, but I can't remember if that was with MetaTrader or another platform.
So, yes it is not a true risk in itself but still "risky" to ignore the margin requirements. My initial wording was inaccurate.
You're talking about the dynamic position sizing, it makes sense, and the function is constructed well. I have that locked down (consistent risk). I'm currently testing 25% consistent risk, this might seem outlandish, but I believe that if a strategy is strict enough, it should succeed with such risk, and statistically have a much higher percentage of wins than losses. But then there is the question...how will you manage it when things go wrong and there's a growing loss? This is the crux of the problem with swing trading on the trend, you end up "hoping" that the market diverges favourable to your position
You're talking about the dynamic position sizing, it makes sense, and the function is constructed well. I have that locked down (consistent risk). I'm currently testing 25% consistent risk, this might seem outlandish, but I believe that if a strategy is strict enough, it should succeed with such risk, and statistically have a much higher percentage of wins than losses. But then there is the question...how will you manage it when things go wrong and there's a growing loss? This is the crux of the problem with swing trading on the trend, you end up "hoping" that the market diverges favourable to your position
tight stop losses until market is confirmed to swing in profit direction.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use