PowerLanguage, referencing previous values of a variable

Questions about MultiCharts and user contributed studies.
HPF
Posts: 47
Joined: 02 Apr 2013
Has thanked: 11 times
Been thanked: 7 times

PowerLanguage, referencing previous values of a variable

Postby HPF » 21 Sep 2015

Hi,

here is a stupid and rather basic question about PowerLanguage. I have a signal with a local variable whose previous values I refer to using the square brackets [...].

Code: Select all

{Example signal code}

variables:
v1(123.45);

v1 = close[0];

print ("CurrentBar = " + NumToStr (CurrentBar,0) +
", close[10] = " + NumToStr (close[10],2) +
", v1[10] = " + NumToStr (v1[10],2));
What is the expected behaviour when I access v1[10] when CurrentBar is between 1 and 10? In which document is this behaviour specified?

When I try this in MC 8.8 I get the initial value (here: 123.45) whenever CurrentBar is between 1 and 10. This is irrepsective of MaxBarsBack which only determines how many bars are skipped before my signals starts and which makes sure that close[10] yields the correct values right from the beginning at CurrentBar=1. When I point the mouse at v1 in the editor, it tells me that the variable is of the type NumericSeries.

Thank you very much for your help.

HPF

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

Re: PowerLanguage, referencing previous values of a variable

Postby Henry MultiСharts » 22 Sep 2015

When I try this in MC 8.8 I get the initial value (here: 123.45) whenever CurrentBar is between 1 and 10.
Hello HPF,

The behavior you have described is the expected one.


Return to “MultiCharts”