To recall the existing variables at any moment  [SOLVED]

Questions about MultiCharts and user contributed studies.
Spikehog
Posts: 39
Joined: 09 Dec 2013
Has thanked: 26 times
Been thanked: 1 time

To recall the existing variables at any moment

Postby Spikehog » 04 Jun 2015

Hello there, those values on the y-axis keep changing when the market is opened. I was wondering how I can recall those variables at any moment before its bars closed. For example, those values are circled in orange on the y-axis as per the screenshot, is it possible to get those values before each particular bar is closed?

Thank you so much!!!
Attachments
MCenquiry.png
(25.69 KiB) Downloaded 598 times

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: To recall the existing variables at any moment

Postby JoshM » 04 Jun 2015

Hello there, those values on the y-axis keep changing when the market is opened. I was wondering how I can recall those variables at any moment before its bars closed. For example, those values are circled in orange on the y-axis as per the screenshot, is it possible to get those values before each particular bar is closed?
The values you point out in your picture are plotted by the indicator. You can find them in the indicator's code by looking for the `plot()` statement.

I'm not sure what you mean with "get those values before each particular bar is closed". Before what do you want these values? If you mean values of the previous bar (so the bar before that particular bar closed), you can do so with `[1]`. For example:

Code: Select all

Variables:
myVariableValue(0);

// Plotting current value
Plot(myVariableValue);

// Printing the variable's value on the previous bar
Print("Prev bar value: ", myVariableValue[1]);

Spikehog
Posts: 39
Joined: 09 Dec 2013
Has thanked: 26 times
Been thanked: 1 time

Re: To recall the existing variables at any moment

Postby Spikehog » 16 Jul 2015

I am sorry. I didn't make myself clear. Those values on y-axis were calculated based on Data1 and Data2. And Data1 and Data2 were on two different time resolution i.e. 1 min for Data1 and 1 hr Data2. What I observed was that the values based on Data2 were updated every hour, even though I printed out the values every minute, the values based on Data1 were changed every minute and not the values based on Data2. I was wondering if possible to update the values based on Data2 when the values of Data1 is updated every minute?

Thank you very much!

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: To recall the existing variables at any moment  [SOLVED]

Postby Henry MultiСharts » 17 Jul 2015

Hello Spikehog,

If you want to store the intrabar values - you need to create an intrabarpersist variable and store the required values in it.

Intrabarpersist never resets itself during the script calculation. 
Every "regular" variable will keep its value throughout the whole script calculation on all data series (if the value was assigned on the bar's close) until you assign a different value to it. 
 
The difference between regular variable and IntraBarPersist variable is that regular variable's value is fixed on bar close and IntraBarPersist variable's value is fixed even inside bar. 
 
For example: 
If you assign a value for regular variable inside bar (barstatus=1) - the variable value will not be kept on bar open/close (barstatus=0 and 2). 
If you do the same with intrabarpersist variable-the value will be kept on all barstatus values (0,1,2).

Code: Select all

[IntrabarOrderGeneration=true]
once cleardebug;

var:
var0(0),
intrabarpersist var1ibps(0);

if LastBarOnChart_s then print("> ", barstatus, " ",currentbar:5:0, " ", var0:5:5, " ", var1ibps:5:5);

var0 = var0 + 1;
var1ibps = var1ibps + 1;

if LastBarOnChart_s then print("< ", barstatus, " ",currentbar:5:0, " ", var0:5:5, " ", var1ibps:5:5);


Return to “MultiCharts”