how to plot the frequency of the true values in the “plot scan” indicator


Category:
0
0

Hellow mr Hahn

i have a small line of code i need created.  Its a simple “plot scan” script as down below, but the kicker is that i need you to create a code plotting the frequency of the true values over a look back period of X bars.

For example            Plot Scan = DataH5 is true

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on September 20, 2017 8:32 am
72 views
0
Private answer

We can do this will a single line of code. The first thing to understand is that in Thinkscript, a True value = 1 and a False value = 0. Armed with this knowledge, we can use the Sum() function to add together the 1’s and 0’s over the specified ‘lookback’ period (in this example a lookback period of 10 bars).

plot numberOfTrueValues = Sum(Scan, 10);

Since we don’t see the rest of the code, we must assume that your DataH5 variable is defined in an earlier statement. We don’t really need the “plot scan” statement at all. We can simply do this:

plot numberOfTrueValues = Sum(DataH5, 10);

You can read more about the Sum() function here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Math—Trig/Sum.html

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 20, 2017 10:24 am