Global variables

Questions about MultiCharts and user contributed studies.
ppc
Posts: 42
Joined: 04 Nov 2014
Has thanked: 4 times

Global variables

Postby ppc » 16 Oct 2023

Hi MC fans,

I would like to get data in chart A and plot the data in chart B by using Global variable. I write the following code to send 3 variables from chart A to chart B but only 1 variable (GV_openTimeframe2) can be received in chart B. Thanks for your idea and comment.

indicator in Chart A:

Code: Select all

variables: int SetRtn1( 0 ), int SetRtn2( 0 ), int SetRtn3( 0 ); variables: double GV_HighTimeframe2(0), double GV_LowTimeframe2(0), double GV_openTimeframe2(0); if LastBarOnChart then begin SetRtn1 = GVSetdouble(GV_HighTimeframe2, High); SetRtn2 = GVSetdouble(GV_LowTimeframe2, L); SetRtn3 = GVSetdouble(GV_openTimeframe2, open); end; plot1(H, "GV_HighTimeframe2" ); plot2(L, "GV_LowTimeframe2" ); plot3(open, "GV_OpenTimeframe2" );
Indicator in Chart B:

Code: Select all

variables: GV_HighTimeframe2(0), GV_LowTimeframe2(0), GV_openTimeframe2(0); variables: double HighTimeframe2(0), double LowTimeframe2(0), double openTimeframe2(0); HighTimeframe2 = GVGetdouble(GV_HighTimeframe2); LowTimeframe2 = GVGetdouble(GV_LowTimeframe2); openTimeframe2 = GVGetdouble(GV_openTimeframe2); if HighTimeframe2 > 0 and LowTimeframe2 > 0 and openTimeframe2 > 0 then begin plot1(HighTimeframe2, "GV_HighTimeframe2" ); plot2(LowTimeframe2, "GV_LowTimeframe2" ); plot3(openTimeframe2, "GV_openTimeframe2" ); end;

Return to “MultiCharts”