Triple moving average filter
Forums › ProRealTime English forum › General trading discussions › Triple moving average filter
- This topic has 8 replies, 4 voices, and was last updated 9 months ago by robertogozzi.
-
-
03/01/2024 at 1:18 PM #229028
hey all!
I have tried to add a triple moving average filter to one of my systems. The system only takes short positions on the DAX40 and I want the filter to allow trades when the moving averages are all below each other. The basic code I am trying to use is:
123456timeframe(5 minute, updateonclose)ma1 = VolumeAdjustedAverage[m1](close)ma2 = VolumeAdjustedAverage[m2](close)ma3 = VolumeAdjustedAverage[m3](close)trendOK = ma1 < ma2 and ma2 < ma3The isssue is this. When I backtest the system appears to be taking orders when the moving averages are not below each other and trending downwards, as specified in the code. In fact it is placing orders when the averages are all above each other, trending upwards!
Can anyone help an idiot? Is the code not suffiecent to act as a triple moving average filter, or is something else going wrong? I can happily post the code and the backtest results if it helps.
Thanks
Jim
03/01/2024 at 1:28 PM #229030Is your backtest results showing this …
1trendOK = ma3 > ma2 and ma2 > ma1Put in a way different to what you say in your post … above is what your code is saying.
1 user thanked author for this post.
03/01/2024 at 2:29 PM #229034Hi Grahal
Thanks for the prompt reply! 🙂
The backtest results show that it takes trades anywhere, regardless of the filter. The system just doesn’t respect the filter.
Not sure what is going on. Having a few issues with V12. Maybe its a software issue? Sometimes it does strange things when backtesting… not recognising variables in the optimiser window, etc.
Jim
03/01/2024 at 2:34 PM #229036Jim, put this at the end of your code.
123graph ma1graph ma2graph ma3Then you will probably see what GraHal means. I have the same “feeling”, but it depends on your m1, m2 and m3 and which is the smallest and which is the largest.
You will see …03/01/2024 at 2:37 PM #229037Hi Peter
yes, of course. These are the values, m1 the smallest always and m3 the largest always.
m1 = 25, m2 = 45, m3 = 60
03/01/2024 at 3:20 PM #229038not recognising variables in the optimiser window, etc.
I’ve experienced above also … well weird bug that is!
Somehow though – and I can’t even say how – I’ve found a work-around as it hasd not happened to me for a few weeks, thankfully!03/01/2024 at 8:08 PM #229056strange for sure….
I just can’t figure out why the filter isn’t working and thought maybe it was a similar problem like a bug….
03/01/2024 at 10:25 PM #229061why the filter isn’t working
A screenshot showing the filter not working might help us to suss out why.
A snippet of code including how / where you use trendok might also help us to help you. 🙂
03/06/2024 at 11:42 AM #229332It works like a charm to me (as from attached pic), on both an indicator and a strategy.
Strategy:
Strategy12345678timeframe(5 minute, updateonclose)ma1 = VolumeAdjustedAverage[25](close)ma2 = VolumeAdjustedAverage[45](close)ma3 = VolumeAdjustedAverage[60](close)trendOK = ma1 < ma2 and ma2 < ma3timeframe(default)buy at -close limitgraph trendOKindicator:
12345ma1 = VolumeAdjustedAverage[25](close)ma2 = VolumeAdjustedAverage[45](close)ma3 = VolumeAdjustedAverage[60](close)trendOK = ma1 < ma2 and ma2 < ma3RETURN trendOK as "trendOK" -
AuthorPosts
Find exclusive trading pro-tools on