Data Aliasing with Minute Bars

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.

//vars: myCloseData1(0),myCloseData2(0),
// myRSIData1(0),myRSIData2(0);

vars: myCloseData1(0),myCloseData2(0,data2),
myRSIData1(0),myRSIData2(0,data2);


myCloseData1 = close of data1;
myCloseData2 = close of data2;

myRSIData1 = rsi(close of data1,14);
myRSIData2 = rsi(close of data2,14);


Print(d," ",t," --------------- ");

print(" myCloseData1[0]: ",myCloseData1[0]," myCloseData2[0]: ",myCloseData2[0]);
print(" myCloseData1[1]: ",myCloseData1[1]," myCloseData2[1]: ",myCloseData2[1]);
print(" myCloseData1[2]: ",myCloseData1[2]," myCloseData2[2]: ",myCloseData2[2]);
print(" myCloseData1[3]: ",myCloseData1[3]," myCloseData2[3]: ",myCloseData2[3]);

print(" myRSIData1[0]: ",myRSIData1[0]," myRSIData2[0]: ",myRSIData2[0]);
print(" myRSIData1[1]: ",myRSIData1[1]," myRSIData2[1]: ",myRSIData2[1]);
print(" myRSIData1[2]: ",myRSIData1[2]," myRSIData1[2]: ",myRSIData2[2]);
print(" myRSIData1[3]: ",myRSIData1[3]," myRSIData1[3]: ",myRSIData2[3]);
Illustrating Difference Between Data Aliasing and Not Data Aliasing

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 [0] 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 [0] 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.

Difference between using Data Aliasing and Not using Data Aliasing

Discover more from George Pruitt

Subscribe to get the latest posts sent to your email.

Leave a Reply