Why It Is Important to Connect Variables with Correct Time Frame
I had a question about data aliasing from a reader of this blog. Here is the debug code I used in the form of an Indicator.
If you have a higher resolution as Data 1 (5 minute in this case) than Data 2 (15 minute), then you must use Data Aliasing if you are going to use a variable to represent a price or a function output. With out Data Aliasing all data references are in terms of Data 1. When the 15 minute bar closes then the current  and one bar back[ 1] will be correct – going back further in time will reflect correct data. During the 15 minute bar only the last value  will show the correct reading of the last completed 15 minute bar. Once you tie the variable to its correct time frame variableName(0, Data2), you can then reference historic bars in the same fashion as if it were Data1. This includes price references and function output values.
Check this chart out and see if it makes sense to you. I dedicate a portion of a Tutorial on Data Aliasing in my latest book due out next week – Easing Into EasyLanguage – Advanced Topics.