| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| iMAOnArray for smoothing - Help needed https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5604 |
Page 1 of 1 |
| Author: | Bruster400 [ Tue Jan 15, 2019 1:21 pm ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
Hi, I'm trying to write a "smoothed" version of the bands indicator. The idea is that it will become a "trend" indicator highlighting strong trends and also periods of pull-back and consolidation. The attached version sort of works.... The recent data is fine and it's doing what I want it to. The problem is the data towards the oldest bars gives strange results with the line values going all over the place. It's a very simple indicator (to match my coding skills I've checked the ibands data and it's populated correctly all the way back to the oldest data point within those buffers so I know the problem is with iMAOnArray. Can anyone tell me how this is supposed to be correctly applied? Thanks Bruce |
|
| Author: | renexxxx [ Tue Jan 15, 2019 8:22 pm ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
Hi Bruce, You have to run your second loop also from left to right. I have made some small changes to your code and I think that it does what you want it to do. Try eg. with BandsPeriod=10 and SmoothingPeriod=10. Cheers ... René. |
|
| Author: | Bruster400 [ Wed Jan 16, 2019 8:39 am ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
René, Thanks once again for helping me out!! I've taken a look at the changes you've made and I understand what you've done. I had reversed the calculation direction because I'd reversed the buffer to series false. I tried doing the other way round and it didn't seem to make any difference - buffers are obviously more forgiving than arrays in EAs? However, I'm still getting the same issue with the changes you've made. In the screen grab below you can see the strange plots that the oldest smoothed data is giving: I've looked back at what I'm doing with limits to ensure that I'm giving the calculations enough valid back data and I think I've got it right: While doing this I couldn't work out why the iMAOnArray couldn't just calculate a simple average from the bolli data..... and then I realised that I wasn't doing a "simple" average, I was smoothing with an exponential average. This seems to be what is causing the problem. If I change the smoothing to SMA then I don't have the issue. There must be something about the EMA calculation that either uses more back data than I've allowed for or runs iterative calculations on its own results that send the older values exponential when EMPTY_VALUE starts getting used. I've tried initialising with zero but this doesn't work either. I don't want to waste other people's time on this more than I have done already so I think I'll look at using the SMA smoothing and see if that works for me. Alternatively I can leave it alone and just not scroll the charts back too far!! Thanks again for your time helping me René. I really do appreciate it. Bruster |
|
| Author: | Bruster400 [ Wed Jan 16, 2019 10:18 am ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
For those interested in why I'm coding this indi...... I'm a trend trader. I trade the H1 and above charts looking for H1timeframe moves in line with the longer timeframe trend. I have a number of ways of telling the HTF trend but I'm coding this indi as a potential H1 entry signal. My ideal entry is where price pulls back against the HTF trend and then rejoins the trend for my entry. This indicator is supposed to watch for just that. The idea is that when price is between the bands it's pulling back or ranging. When price breaks out (closed bar) of the bands then it's trending - with momentum - which is what I'm looking for. A valid breakout has to be in line with the HTF trend AND preceded by a touch of the centre line - ie a decent size pull back. Stops would be back across the centre line with a bit of a buffer - 10pips or so - or a recent H/L if there's a really obvious one very near to this point. Here's an example of a random snapshot of my system with a description to help clarify the idea behind it: I've used the D1 SuperSlope as the HTF filter Blue dot = pullback (reset ready to trade) Orange dot = filtered trade not taken Arrows = trade entries
Cheers Bruster |
|
| Author: | Herman [ Tue Feb 12, 2019 11:31 pm ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
Hopefully I understood correctly. |
|
| Author: | Bruster400 [ Wed Feb 13, 2019 9:07 am ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
Herman, You have indeed. Brilliantly simple version. I had tried using the iBands function rather than calculating the std devs internally but for some reason my version of this wouldn't pull through on an iCustom...? Anyway, I've checked and your version pulls through just fine so it must have been something I'd done wrong. I did notice that your version still has issues with the soothing on the oldest data but I've given up solving this as I'm sure it's down to the exponential average calcs and it's easily covered up with a decent DrawBegin gap. Thanks very much for your help with this, really appreciate it. bruster |
|
| Author: | Bruster400 [ Wed Feb 13, 2019 9:20 am ] |
| Post subject: | iMAOnArray for smoothing - Help needed |
I've built on the version Herman posted above and have added arrows to indicate the possible entries for the way that I trade this indicator. (These are breakouts from the channel but only once after each touch of the center line - ie a pullback). |
|
| All times are UTC | Page 1 of 1 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|