NexusFi: Find Your Edge


Home Menu

 





Help about TOS function


Discussion in ThinkOrSwim

Updated
    1. trending_up 4,140 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Help about TOS function

  #1 (permalink)
 alchemist74 
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.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
ZombieSqueeze
Platforms and Indicators
Exit Strategy
NinjaTrader
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
  #2 (permalink)
 RHcZL0Mfs 
Chicago
 
Experience: Advanced
Platform: ThinkOrSwim
Trading: options
Posts: 11 since Dec 2013
Thanks Given: 3
Thanks Received: 8

I could be incorrect saying this.

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
 
Code
plot yHigh = high (period = "day")[1];

If I want to see what the prior day was two days ago I would do this
 
Code
plot yHigh = high (period = "day")[2];

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?

Reply With Quote
Thanked by:
  #3 (permalink)
 alchemist74 
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


Thx RHcZL0Mfs for your answer.

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 ?

thx again for your answer and Happy New Year !

Started this thread Reply With Quote
  #4 (permalink)
jonshengit
Pleasanton CA/USA
 
Posts: 1 since Aug 2020
Thanks Given: 0
Thanks Received: 0

i came cross this post.

I am looking at LeavittConvolutionSlope. I notice the LeavittConvolutionSlope use Time Series Forecast which use Inertia.

The ta-lib provides TSF - Time Series Forecast.

if your purpose is to get LeavittConvolutionSlope work, Inertia can be bypass using ta-lib.TSF.

Reply With Quote




Last Updated on August 25, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts