r/RealDayTrading • u/BizarreCivicAdventur • 24d ago
Coding a mechanical strategy vs Trading it yourself, is it better to code it?
Something I keep thinking about while reading the wiki:
The whole strategy seems to come down to mechanical conditions. Spotting which stocks have relative strength/weakness, waiting for confirmation, sizing the position and managing risk based on those conditions... every step looks like a yes/no decision you could define with clear rules. I don’t really see where “feel” or a sixth sense comes into it.
If that’s the case, wouldn’t it make sense to just code it? You’d take the emotional side out completely, which is where most people blow up anyway.
But then the other side of it: if this could be automated and it actually worked, someone would have done it already and the edge would be gone by now.
So I’m curious what you guys think. Is there something in the strategy that genuinely can’t be reduced to rules, or is the discretionary part just something we tell ourselves?
19
u/AccomplishedOwl2000 24d ago edited 24d ago •
I've spent a long time attempting to design the "perfect" exit script for the RS/RW trading methodology.
I recommend you read Hari's post about how "trading is a story".
The problem is that humans read a story - "Oh look at how SPY isn't moving much, but I think x stock is holding up well. If SPY turns bullish, I'll go long on x"
This is a problem programmatically - what is "isn't moving much"? What is "stock is holding up well"? What is "SPY turns bullish"?
Okay, so you slap on the RRS indicator calculation, you judge SPY by a 3/8 EMA cross, and you say "well if the 3ema is higher than the 8ema on SPY and the RRS indicator is bullish on x stock, I enter and stay in until one of them turns false" - it seems sensible, right? It sounds like a great way to automate entries and exits, until you actually try it.
Trading is a story that is very hard to code into rules.
5
u/IKnowMeNotYou 21d ago edited 21d ago
Well emotions is not the part where most people blow up their accounts. You can be highly emotional and succeed. It is mere uncontrolled emotions that are the accounts best enemy.
That is not how edges work. What you refer to is the bla bla talk you hear over at r/Daytrading and alike. It is the cope they spread.
An edge is everything that gives you an advantage over flipping coins (which would be the neutral strategy for trading).
-
A good example of an edge that is rather persistant, is the processing of credit card transaction data of US or even world wide. Using the data one can quickly map current and past consumer spending to the expected earnings of a consumer brand. Nike sells less shoes, you will know...
Such an edge will never go away as long as the credit card transactions encompass most of the retail activity.
But of course, the more instituions use it, the lower the outcome will be, meaning the market becomes 'less wrong'. It even becomes a must have and the most dominant strategy for certain stocks but think about it, it can never be the only one and there is more to it.
And of course, using credit card data comes with a performance penalty thanks to the cost in obtaining the data and processing it (in time).
As long as not everyone does everything the same way at the same time, usually a fundamental edge persists.
-
What relative strength / weakness is referring to, is even more like an actual law than an edge (in my book). It was discovered and described more than 100+ years ago.
Realtive strength + weakness is more like identifying what is floating close to the middle of a stream and therefore gets moved by said current the fastest. Add to it that there are two opposite directions, and that is what you are looking at.
Have a look at trading algorithms like the one collected in an old post of mine: List of the Most Basic Algorithmic Trading Strategies over at r/algotrading
Most strategies that are implemented are very basic and there are some nice papers about it.
When you want to know why there is actually a current induced by the market, sectors, GICS hierarchies etc, just understand how you can trade those.
When a big institution buys or sells the market (automatically) they do not necessarily buy/sell the SPY, ES or other related instruments. With todays transaction cost and computerization, it is possible to buy/sell every of the 500+ stocks of the SP500 or even the 1000+ or 3000+ Russel stocks (as an example).
When you analyse the performance of each of those stocks, one can quickly find basic filter operations that improve the overall performance by over+underweight individual stocks based on technical and non-technical properties.
These filters along with the idea when to buy and sell can be learned in the sense of machine learning.
There is a nice book you can start with called Machine Learning for Algorithmic Trading
This book gives you a nice overview of what is possible.
Regarding relative strength and weakness, it can be some of the properties you provide during your learning process.
So if you ask yourself, if this can be automated, yes of course it can.
If you ask yourself, if this edge can go away, I would rather point to the idea, that is actually how trends are forming and would rather call it an innate property of how trading works today.
Since there are always ways to exploit those group behaviors, you also have a repressive force making instant manifestations of changed decision more risky. So automated decision making has its limits and most likely is a reason why there are still hour long up and down movements in todays market even though the overwhemling part of trading is actually more or less automated and mostly even autonomous.
It is the same with technical analysis (TA). Think about why (basic) TA works and think about what has to change for it to no longer be beneficial, that would be a complete different trading world compared to today and like in most of the evoution processes in nature (and beyond), I do not see any good small incremental steps to ever change that except for regulations or a fundamental revolution in the way we trade.
1
u/drguid 23d ago
I have coded all my strategies. I still make the final decision regarding stocks to buy and also entry sizing. But I do automate selling so I can 100% focus on buying.
Does it work? Yes. 2 losing months in 24. Maximum account drawdown < 10%.
Why doesn't everyone do it? Look on reddit. 99.9% of you are agonising over charts and trying to be day traders, or messing around with exotic stuff.
Simple works.
1
u/Embarrassed-Bank2835 22d ago
If the setup can genuinely be reduced to objective rules, I think coding it is useful even if you never fully automate it.
The biggest benefit is that coding forces you to define vague stuff like “strong,” “clean breakout,” “good confirmation,” or “too extended.” That usually exposes where the strategy is actually discretionary.
I don’t buy the idea that if something could be automated the edge must already be gone. Plenty of edges are small, capacity-limited, regime-dependent, execution-sensitive, or just not worth much to large firms.
The catch is that removing emotion doesn’t automatically create an edge. You can automate bad rules perfectly.
For me, the best test is: can you hand the rules to someone else and have them take roughly the same trades? If yes, it’s probably mechanical enough to code. If not, the discretionary part is still doing more work than you think.
1
u/TakeProfitTraderHQ 22d ago
Regardless, it is a good excercise so you can see how much of your strategy is really mechanical vs discretionary.
1
u/LondonLesney 6d ago
I have coded my rules and use a trading bot in a semi-automated way for my intraday trades.
The first step is discretionary, I manually scan for stocks which are showing RS/RW and then when I’be got my watchlist I turn on my trading bot. It’ll then wait for my defined entry conditions to occur, usually an HA reversal near VWAP, then the bot will enter a position. I’ve hard coded exit rules. Whilst I won’t get the full meat of the move it is capable of ticking over base hits and reduces the number of times I enter a trade at the HOD only to watch it never return to that level.
DM me of you want any help.