Data1 Data2 update

Questions about MultiCharts and user contributed studies.
enricog
Posts: 11
Joined: 10 Dec 2021
Has thanked: 1 time

Data1 Data2 update

Postby enricog » 15 Mar 2022

Hello,

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);
Last edited by enricog on 16 Mar 2022, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Data1 Data2 update

Postby TJ » 15 Mar 2022

Data1 is the drummer. He sets the beat.

Have you tried Data1 as 2 min and Data2 as a multiple of data1?

enricog
Posts: 11
Joined: 10 Dec 2021
Has thanked: 1 time

Re: Data1 Data2 update

Postby enricog » 16 Mar 2022

Sorry, the time fame are: data1 5min, data2 240 min (not 2min as I wrote)


Return to “MultiCharts”