Click here to Login





                                                   Issue in Trend Strength Index Formula?

  1

0
Dave W.
2015-01-09 13:07:21


Hi. As I was trying to figure out why the Trend Strength Index indicator was not working for me, I noticed this line in the function:

result = cFunctions.CompileFormula("tsi = sma(sma(Absolute(close - ref(close, -10) / atr(10)),10), 100);").GetVectorDouble("tsi");

If I'm reading this right, the "ref(close, -10)" refers to the future, true? If so, I think this is an error, correct?

-----------------------------------------------------
I'm recoding the Trend Strength Index using the TA library functions. Does this look right to you? If so, I'll post it to the sharing server.

cFunctions.SetForwardAndBackwardBars(int.MaxValue, 0);

VectorD Ratio = 0; // Initialize the variable
VectorD TrendStrengthIndex = 0; // Initialized the variable
VectorD close = cFunctions.Close;


Ratio = TA.Absolute( (close - TA.Ref(close, ShortLookback) ) ) / TA.Atr( ShortLookback );
TrendStrengthIndex = TA.Avg( TA.Avg(Ratio,ShortLookback), LongLookback);
result = TrendStrengthIndex;



QuantShare
2015-01-12 02:53:56

  1

Best Answer
Yes, it looks like the user that uploaded the item has made a mistake and the formula uses future bars.
Your formula looks correct.



No more messages
0




Reply:

No html code. URLs turn into links automatically.

Type in the trading objects you want to include: - Add Objects
To add a trading object in your message, type in the object name, select it and then click on "Add Objects"










QuantShare

Trading Items
TSI - Trend Strength Index
Trend Strength Index
TSI - True Strength Index
Oversold Stocks - Relative Strength Index - Market Timing Indicat...
Volume Trend Index - Market Indicator

How-to Lessons
How to screen for stocks having a high correlation with the Dow J...
How to associate an index with a list of stocks
How to get stocks for a particular index using the global script
How to display the bar index of a stock on a chart
How to create a strategy-based portfolio

Related Forum Threads
Symbol Strength Relative to Index
Automatic screener for checking Equities against the index trend
Chart Pattern Index problem
force index
Unable to downlod Hang Seng index historical prices

Blog Posts
Create a Pivot Table that displays the Relative Strength Index - ...
How to Pick the Best Trend Indicators
How To Create and Backtest an S&P 500 Trend Following System
Create a stock index or a trading indicator using the composite t...
Custom Indicator: Relative Strength









QuantShare
Product
QuantShare
Features
Create an account
Affiliate Program
Support
Contact Us
Trading Forum
How-to Lessons
Manual
Company
About Us
Privacy
Terms of Use

Copyright © 2024 QuantShare.com
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Google+
Follow us on Google+
RSS Trading Items



Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.