Sofia, Bulgaria
Experience: Advanced
Platform: IB,TOS
Broker: IB
Trading: Options,ES,6E,ZB,SPX,RUT,CL
Posts: 47 since Jul 2010
Thanks Given: 6
Thanks Received: 42
|
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;
}
input length = 20;
plot LinReg1 = Inertia(close, length);
plot LinReg2 = InertiaTS(close, length);
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.
|