When a strategy uses two time frames (E.g. 1 min and 5 min) of the same symbol, it is necessary to load two data series of price data into the same chart window. I wrote below codes to test the possibility of referencing a variable's value of each data series in the way like price data (OHLCV). Surprisingly, I found that such historical referencing works for each data series for price data but not variable data. Referencing a variable's historical value based on Data(2) has the same result of referencing based on Data (1).
Code: Select all
Variables:
ABC (0),
ABC = Time;
If LastBarOnChart Then Begin
Print ( DateTimeToString (DateTime), ", Time [0] of Data (1) = ", Time [0] of Data(1),
", Time [1] of Data(1) = ", Time [1] of Data(1) );
Print ( DateTimeToString (DateTime), ", Time [0] of Data (2) = ", Time [0] of Data(2),
", Time [1] of Data(2) = ", Time [1] of Data(2) );
Print ( "-------------------------------------------------------------
--------------------------------------------------------------------" );
Print ( DateTimeToString (DateTime), ", ABC [0] of Data (1) = ", ABC [0] of Data(1),
", ABC [1] of Data(1) = ", ABC [1] of Data(1) );
Print ( DateTimeToString (DateTime), ", ABC [0] of Data (2) = ", ABC [0] of Data(2),
", ABC [1] of Data(2) = ", ABC [1] of Data(2) );
Print ( "=====================================================================
============================================================" );
End;
9/18/2020 8:29:00 AM, Time [0] of Data (1) = 829.00, Time [1] of Data(1) = 828.00
9/18/2020 8:29:00 AM, Time [0] of Data (2) = 825.00, Time [1] of Data(2) = 820.00
---------------------------------------------------------------------------------------------------------------------------------
9/18/2020 8:29:00 AM, ABC [0] of Data (1) = 829.00, ABC [1] of Data(1) = 828.00
9/18/2020 8:29:00 AM, ABC [0] of Data (2) = 829.00, ABC [1] of Data(2) = 828.00
=================================================================================================================================
Did I do anything wrong or referencing a variable's historical value based on a higher data series simply does not work?
Thanks,
McGeorge