I am using 2 Time frame. data1 with 5min, data2 240min.
On data1 run the following script in real time.
On Data1 is update MA1 (MA1[0] exponential moving average) on every 5min when bar is close.
On Data2, MA2 (MA2[0] exponential moving average on data2) remain always the same, because the bar is not changhed yet.
I would to like to update the MA2 with the effective real time value when the script evaluate the 5min bar (on data1)
Note. This code is used in a signal.
Any help will be appreciated.
Thank you
Code: Select all
variables:
MA1 (0, data1),
MA2 (0, data2);
// inputs and variable initialization section
if (datetime
MA1 = round(XAverage(close, 20), 1) data1;
MA2 = round(XAverage(close, 20), 1) data2;
once ClearPrintLog;
print("MA1[0]= ", MA1[0]:6:1,
" MA1[1]= ", MA1[1]:6:1, "Time ", Time_s);
print(NewLine);
print("MA2[0]= ", MA2[0]:6:1,
" MA2[1]= ", MA2[1]:6:1, "Time ", Time_s);