A reader of this blog wanted to be able to use different time frames and some built-in indicators and output the information in a similar fashion as I did in the original MTF post. There are numerous ways to program this but the two easiest are to use data structures such as arrays or vectors or use TradeStation’s own multi data inputs. The more complicated of the two would be to use arrays and stay compliant with Multicharts. Or in that same vein use vectors and not stay compliant with Multicharts. I chose, for this post, the down and dirty yet compliant method. [NOTE HERE! When I started this post I didn’t realize it was going to take the turn I ended up with. Read thoroughly before playing around with the code to see that it is what you are really, really looking for.] I created a multi data chart with five-time frames: 5,10,15,30 and 60 minutes. I then hid data2 thru data5. I created an MTF indicator that plots the relationship of the five time frames applied to the ADX indicator with length 14. If the ADX > 20 then the plot will be green else it will be red. If all plots align, then the composite plot will reflect the alignment color.
This code is very similar to the original MTF indicator, but here I simply pass a pointer to the different time frames to the ADX function. Since the ADX function only requires a length input I had assumed I could use the following format to get the result for each individual time frame:
adxData1 = adx(14) of data1;
adxData2 = adx(14) of data2;
This assumption worked out.
But are we really getting what we really, really want? I might be putting too much thought into this but of the five-time frame indicator dots, only the 5-minute will change on a 5-minute basis. The 10-min dot will stay the same for two 5-min bars. The dots will reflect the closing of the PRIOR time frame and the current 5-min bar is ignored in the calculation. This may be what you want, I will leave that up to you. Here is an illustration of the delay in the different time frames.
So when you look at each dot color remember to say to yourself – this is the result of the prior respective time frame’s closing price. You can say to yourself, “Okay this is the ADX of the current 5-minute bar and this is the ADX of the prior 10-minute close and this is the ADX of the prior 15 minutes close and so on and so on. We all know that the last 5 minutes will change all of the time frames closing tick, but it may or may not change the price extremes of those larger time frames. I will show you how to do this in the next post. If you want to see the impact of the last 5- minutes, then you must build your bars internally and dynamically.
Discover more from George Pruitt
Subscribe to get the latest posts sent to your email.