A completely simple NAS MACD system
Forums › ProRealTime English forum › ProOrder support › A completely simple NAS MACD system
- This topic has 22 replies, 7 voices, and was last updated 1 year ago by VinzentVega.
-
-
08/03/2023 at 9:20 AM #218518
I created and tweaked this system for fun a long time ago… a beginner’s system as you can see. The joke is, the optimization was in February 2023. And as you can see, it seems to have worked pretty well. I had tried to refine the whole thing with a trailing stop, but the results were probably worse. So it’s a pure ratio system…which I guess isn’t bad at all. The question is, how long should such simplicity be trusted? when does she break down?
1234567891011121314151617181920212223242526272829303132333435363738394041DEFPARAM CUMULATEORDERS = falsedefparam preloadbars = 10000//Risk ManagementPositionSize = 1Timeframe(15minute, updateonclose)//MacdM15MACDLinieLong = MACDline[12,26,9](close) > 0M15MACDHistoLong = MACD[12,26,9](close) crosses over 0Timeframe(default)//TF M5long = M15MACDLinieLong and M15MACDHistoLong// trading windowONCE BuyTime = 140000ONCE SellTime = 210000// position managementIF Time >= BuyTime AND Time <= SellTime THENIf not onmarket and long Then //not onmarket andbuy PositionSize CONTRACTS AT MARKETSET STOP %LOSS 0.42SET TARGET %PROFIT 0.88ENDIFendif//if longonmarket and not M15MACDLinieLong then//sell at market//endifif time >= 220000 and dayofweek=5 thensell at marketexitshort at marketendif5 users thanked author for this post.
08/03/2023 at 9:41 AM #218520GO LONG INDEX + R/R>2
kinda magical formula 🙂
Thanks for sharing!
1 user thanked author for this post.
08/03/2023 at 9:56 AM #21852108/03/2023 at 1:22 PM #218544By nature, it’s “simpler” and more sensible to go long only on indices, since they’re supposed to be in an uptrend, most of the time. With a good risk/reward ratio (above 2, as in this case), you have a traditional setup that should work, provided you get the timing right.
1 user thanked author for this post.
08/03/2023 at 2:44 PM #21855008/04/2023 at 12:48 PM #218586Hi Phoentzs,
Your idea seemed simple and effective to me so I decided to work on it.
Code below:
DAX-40
Timeframe 15 minutes//DAX 40_15 minutes
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 1000daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
PositionSize = 1
M15MACDLinieLong = MACDline[12,26,9](close) > -2
M15MACDHistoLong = MACD[12,26,9](close) crosses over 0long = M15MACDLinieLong and M15MACDHistoLong and (close > average[100,1](close))
cut = (close crosses under average[90,1](close))IF time >= 090000 and time <= 173000 and long AND not daysForbiddenEntry AND NOT ONMARKET THEN
buy PositionSize CONTRACTS AT MARKET
SET STOP pLOSS 35
SET TARGET pPROFIT 115
ENDIFif cut then
sell at market
endifif time >= 180000 and dayofweek = 4 then
sell at market
endif//trailing stop function
trailingstart = 3 //trailing will start @trailinstart points profit
trailingstep = 1 //trailing step to move the “stoploss”//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
ENDIF1 user thanked author for this post.
08/04/2023 at 2:49 PM #21859208/04/2023 at 5:44 PM #21860608/30/2023 at 7:48 AM #220041hi phoentzs,
I have put your system into backtest for all past years with tick data available, and it shows that system would have been in the drawdown from the very beginning (mid of 2010) till end of 2020, and only from end of 2019 it produces very consistent profits every quarter and almost every month (I would say – too consistent). well, seeing that extraordinary performance of recent few years and keeping in mind the 10 years drawdown before, it’s of course fair question to jump on this train or not – and if so, how does one know when to jump off. I think you never know. still, possibly you could implement a simple practical rule for “trading the equity curve”, for example like this: if system is profitable for a quarter “on paper”- you run it live for the next quarter, if it produces losses in a quarter, you stop for a quarter and observe the system performance “on paper”, and so on. it’s just an idea, I cannot tell if it works this way long term, but anyway it might prevent a desaster.
in general your question is major question for each technical system – how “robust” are the results which the backtest is showing? will they continue in similar way in the future or not? I doubt anybody knows the answer, though there are statistical methods to analize robustness. not appying them myself, just checking my systems from following perspective/assumptions:
- if equity curve looks very smooth – the system is probably not robust, I mean it’s probably crap. systems with “bumpy” equity curve rather tend to work. I don’t have a “scientific” criteria for what is “smooth” curve and what is not – just checking/judging it visually. also systems with high hit ratio (let’s say >50%) tend rather to be not robust, while those with low hit ratio (40% 30% or even 15%) might produce lot of small losses and rare but big/very big profitable trades exceeding all the losses and making system very good long term. I would probably never trade system with hit ratio of 60% 70% 80%…
- the simplier the system is the more it’s probably robust (and the more bumpy equity curve it will probably produce 🙂 ).
I assume the number of variables in the system defines it’s “simplicity”. the more variables it contains the more complex it is – and my feeling is that the relation here is not linear. if you have 2 variables and add another 2 the complexity is not doubling but “exploding”. I would say one can generally trust simplicity, but I would not call your presented system “simple” – because it contains the macd inidicator with endless amount of parameter’s combinations, every combination producing different result and definetely some combinations producing “nice” result – with kind of guarantee that those nice results will not continue. I mean it’s probably valid also for all the other so called indicators derived from price series, and the more parameters an indicator has the worse it is. market price indicators are possibly funny playground for matematicians/statisticians/physicists, but for traders they are I would say probably useless.
08/30/2023 at 12:37 PM #220058one thought came into my mind how one can define/identify simplicity of strategy – at least I am doing it/approaching it this way without having it “written down” until now: if one can basically handle/execute a strategy manually, just sitting in front of plain price chart, seeing on the chart pricepoints on which one needs to act, then the strategy is simple. in such strategy there is not so much room for any “optimization”. and opposite – if I need pc for calculating some criteria which I cannot calculate quickly in my head or just “see” it on the chart without putting any additional graphs/lines on the screen, then the strategy is not “simple” anymore. adding such calculations (even if it is simple moving avarage with just one parameter) opens the doore widely for the very nasty monster called optimization/curve-fitting. I believe that complicated/optimized systems will not work. and so much overhyped artificial intelligence will also not create any profitable systems. but lot of such systems and tools were and will be sold for millions and billions to the public.
okay, so what’s the point then to automate the system which one can handle easily manually. there are several reasons, but one of the major reasons for me is diversification, so being able to run multiple strategies at the same time, which I could not do manually at the same time. and not the last reason is – sitting at the pc and executing trades is super boring 😀 I would like rather to invest time in research, thinking of ideas/conscepts/scenarios, code them, test them and let them run in real life.
08/30/2023 at 2:33 PM #220063@Justisan Thank you for your thoughts. I agree with you. The more complex a strategy is, the greater the risk of over-optimization. A big aspect should be the robustness of a system and that is achieved, or so it seems, by simply gaining more than it loses in its raw state without many variables. And… I think only long strategies are the most effective. It is better to stay out of trouble than to try desperately to make a profit in the short direction, for example from the Corona event. It goes wrong automatically. Then wait until the situation has calmed down and then make your profits again in the long direction. The system above is just a simple example… but I’ve been surprised that it’s been consistently profitable to this day.
08/30/2023 at 4:31 PM #220072I have put your system into backtest for all past years with tick data available, and it shows that system would have been in the drawdown from the very beginning (mid of 2010) till end of 2020,
It was developed / backtested from the end of 2020 onwards.
phoentzs will tell if it is not so. 🙂
Thus Yes, it was over-fitted.
Only systems which are not optimized at all, may work throughout with similar performance.Ah wait, you said all that, justisan.
By now I virtually graduated on optimizing, and the whole course could be summarized to simply this :
Have an idea – implement that, and don’t optimize anything.
One exception : Once you have that (net) almost winning system, it is allowed to make more profit per trade by means of optimization. This is related to the Exit – usually by means of better trailing. Now you make profit with a fair chance of your system not being too dependent on the market situation.The systems which work best for me these days (I mean, with my current experience) have a win rate of under 50% – could be close to 40% and a RR preferably of above 1,5 (this follows from the low win rate while winning $ anyway).
if equity curve looks very smooth – the system is probably not robust, I mean it’s probably crap.
But that is not my experience; the opposite. A bumpy curve lives by coincidence, like only two losses in a row instead of 5. Those curves are always out of control, and operate at random (but still may be winning). Below a curve which I call very smooth, which System indeed was based on an idea – and a crazy one at it. You can still see when it was developend (3rd screenshot), but in this case only because of making less good profit per trade (mentioned Trailing thing). For me this is the most extraordinary because I wouldn’t have gone broke when this indeed had started Dec 2020. I can show you examples which *were* optimized with a drawdawn of 100K or whatever nastiness.
Nothing is theory here because this runs in Live from of March 2023. The 4th screenshot kind of tries to show that by means of all the double arrows and such (green/red being the Live, the others from this backtest).
Regarding the first few in the post : notice that this 1 minute system bears ~6 months of backtest data. This is how I can see when it was developed – in March because the dip is 6 months earlier. The same will show for phoentzs’ system, although I did not look into it at all (IIRC he works with 100K of backtest data).
Another thing to learn perhaps : it is clear that thus System did not make “the” money before it’s backtest data. Still it is at 85K when run now, all the way back to the end of 2020, while the past 6 months only bring 45K. This mean that the END of this backtest data – which is from of March till totday – is doing super well and as expected by backtest. The curve of course remains rather linear. However, believe it or not, the slope starts to flatten at … trade 2893 which is at March 23, 2023.
Yep.
So the optimizing on the Trailing stuff also has its influence, but not much.
What should worry me is that there is more than that, because else all should have been a similar curve right from today to the beginning which is Dec 2020. Most probably this is because this System makes use of a feature that minimizes losses or prevents fallback from profit. Yep, that is optimized indeed and would be Market-depended.Being able to look afterwards to what happened and analyze what actually can have caused which, is of great value. And so it takes yeeeeears to get somewhere.
08/30/2023 at 8:12 PM #22009008/31/2023 at 2:30 AM #220098It is agonizing or terrifying or intriguing ? to see how the curves in this topic so far are the most similar. Ask for one and next use the <- and -> arrows to scroll through them and compare. Of course we need imagination for the exact moments in time (the dates) but I am pretty sure these dates we envision in our heads are quite the same.
So compare the very first in tis topic to mine to the currently last from Roger – all regarding the upgoing slope. How is it possible …
… Also knowing that mine is EUR/USD and the others are Nasdaq …All I personally know is that deep down in the kernel I lean on phoentzs’ MACD means. phoentsz knows that too, if he kept track of what I do, including the praise of his means. Maybe this should be exploited further.
I probably like to see ghosts now.
08/31/2023 at 3:59 PM #220138hi phoentzs,
regarding long/short strategies, you are probably right, at least when it comes to equity indices. I think because of economical reasons stocks are long-biased, and so indices. for the same reason it seems to be much more difficult to figure out some profitable short strategies. but I found it very cool to have some in the “strategy portoflio”. I just had some logical mistake in my head in the beginning, I thought that my shorts will be able to compensate longs when these are running poorly. well, it is frequently so, but not always, sometimes both do poorly at the same time.
anyway, I played a bit with your example system, I simplified it following way:
- running simply on 15min charts: no mixing up of 15 and 5
- increased stoploss: I think it’s reasonable to have wider stops when you keep positions over many days
- removed the target: so removed one variable, which was basically limiting your profits. by that you avoid and potential “optimization” and you are in line with the rule of “letting your profits run”.
thoug I made it also a bit more complicated: I excluded the trading in september: for what ever reasons all september months in the last 10 years were making losses. (almost non of my own long strategies are making money during august, therefore I don’t go long on august, just short)
so, outcome being: system is now “above the water” every year in last 10 years except 2018 – but loosing in that year a lot. and the equity curve is much bumpier 😀
I think I made the system a bit more robust 😀 Still I personally would not trade it – as mentioned I do not trade any systems which contain “indicators”. I hope I will be able now to insert the code and the picture of equity curve….
adjusted code123456789101112131415161718192021PositionSize = 1M15MACDLinieLong = MACDline[12,26,9](close) > 0M15MACDHistoLong = MACD[12,26,9](close) crosses over 0long = M15MACDLinieLong and M15MACDHistoLongONCE BuyTime = 140000ONCE SellTime = 210000IF Time >= BuyTime AND Time <= SellTime and month <> 9 THENIf not onmarket and long Thenbuy PositionSize CONTRACTS AT MARKETSET STOP %LOSS 0.80//SET TARGET %PROFIT 0.88ENDIFendifif time = 220000 and dayofweek = 5 thensell at marketendif1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on