thinkScript GetValue() formula


New member
These examples and notes were found in the thinkScript lounge.

Useful to remember: GetValue() can be used to accumulate the highest value.

08:55 Paris: Mobius, following up on one of your posts from yesterday. The following two statements appear to be equivalent. Getting a handle on the finer points of the differences of these two statements.

plot HHa = Highest (high, 12);
plot HHb = GetValue(high, GetMaxValueOffset(high, 12), 12);

08:57 Mobius: the latter can be used to accumulate the highest value whereas the other can not
08:58 Paris: Noted, other than that, returns the exact same values from my limited tests
08:58 Mobius: It should
09:00 Paris: Much obliged, I have seen the latter statement, always wanted to experiment and find out more. Glad I put it through its paces.

11:56 DMonkey: plot NextHigh = fold i = 0 to 100 with price = Double.NaN while IsNaN(price) do if getValue(high, -i, -99) > 40 then getValue(high, -i, -99) else Double.NaN; This example script plots the closest high price value greater than 40 out of the next 100 bars. Here is example 3 from the manual. It iterates forward. It is looking for the condition of high being greater than 40. While price remains under 49 it will continue to iterations. When high is greater than 40 it terminates the loop because condition is no longer nan.

Similar threads