Welcome to NexusFi: the best trading community on the planet, with over 200,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- discounts are available after registering.
-- The NexusFi team
(If you already have an account, login at the top of the page)
Hi,
can anyone to help me with this TOS function for Inertia:
script inertiaTS {
input y = close;
input n = 20;
def x = x[1] + 1;
def a = (n * Sum(x * y, n) - Sum(x, n) * Sum(y, n) ) / ( n * Sum(Sqr(x), n) - Sqr(Sum(x, n)));
def b = (Sum(Sqr(x), n) * Sum(y, n) - Sum(x, n) * Sum(x * y, n) ) / ( n * Sum(Sqr(x), n) - Sqr(Sum(x, n)));
plot InertiaTS = a * x + b;
}
My question is what is X (def x = x[1] + 1 and what is n=20 (maybe it is default length? )
I am totaly confused of X meaning.
Is there anybody who can translate this to Java or C++ ?
Thanks in advance.
Can you help answer these questions from other members on NexusFi?
There is a built-in study called Inertia. I am unsure if is the same thing as the sample code provided. Information about the study is at tlc.thinkorswim.com/center/charting/studies/studies-library/G-L/Inertia.html (<--- this is a url and i can't post links yet)
The study takes two parameters
- length for "The number of bars used to calculate the linear regression curve." I believe this is what the 20 value represents in the code.
- rvi lenght for "The number of bars used to calculate the Relative Volatility Index." I believe this is what X is.
With thinkScript (the API for thinkDesktop or what people usually call thinkOrSwim) the [1] means the prior bar/day/whatever.
For example, if I want to see what the prior day high was I would do this
If I want to see what the prior day was two days ago I would do this
This code can be easily ported to C++ or JAVA. However, with that being said I am sure you use a particular platform that has C++/JAVA as a API?
i dont use API for now. My broker is IB and they have API but i trying to develop simple soft to help me with my option trading. Unfortunately my level of programing(and math) is 0 and my programer trading level is 0 too
so what u mean with: "rvi lenght for "The number of bars used to calculate the Relative Volatility Index." I believe this is what X is." just rvi length or rvi number for that length ?