Registered User Joined: 10/28/2016 Posts: 10
|
Hi , can you please help to provide formula to calculate Avg gain and Avg loss for last n number of days.
|
Registered User Joined: 4/3/2014 Posts: 22
|
I second that, I have tried coding it myself and have had no success, please help me get this formula. Thanks soo much.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
This is both simple and complicated. It is simple because once the definition has been determined, the formula can be written fairly easily in TC2000 v17. It is complicated, because the without the definition of exactly what you want, the question is ambiguous and you may not even agree on said definition.
Let's say you want the average of the net change over the most recent 10 trading days.
AVG(C - C1, 10)
If you wanted the average of the percent change over the most recent 15 trading days.
100 * (AVG(C / C1, 15) - 1)
If you want to calculate gains and losses separately, you would need to determine how to include non-gain and non-loss days in the calculations. Should they be counted as zero, or not included in the count at all when calculating the average.
So for example, an average gain calulation might be the following if you wanted to count non-gains as zero over the most recent 20 bars using Net Change.
AVG(IIF(C > C1, C - C1, 0), 20)
But the following if you didn't want to calculate non-gain bars in the average at all.
SUM(IIF(C > C1, C - C1, 0), 20) / IIF(CountTrue(C > C1, 20) > 0, CountTrue(C > C1, 20), 1)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 4/3/2014 Posts: 22
|
Bruce you are amazing, thank you so much for this. :):)
|
Registered User Joined: 10/28/2016 Posts: 10
|
Thanks for the help Bruce !!!
one more question , how to get the current share price ? what's the symbol for that.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The syntax for the close or current price is the following.
C
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 10/28/2016 Posts: 10
|
Thanks a lot
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|