Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

How to calculate avg gain and avg loss for say last n number of days Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
vb1612
Posted : Sunday, April 9, 2017 3:12:13 PM
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.

limitless4646
Posted : Sunday, April 9, 2017 6:21:29 PM
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.

Bruce_L
Posted : Monday, April 10, 2017 10:56:33 AM


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
limitless4646
Posted : Monday, April 10, 2017 2:48:08 PM
Registered User
Joined: 4/3/2014
Posts: 22

Bruce you are amazing, thank you so much for this. :):) 

vb1612
Posted : Tuesday, April 11, 2017 8:58:06 AM
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.

Bruce_L
Posted : Tuesday, April 11, 2017 9:29:11 AM


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
vb1612
Posted : Tuesday, April 11, 2017 10:30:56 AM
Registered User
Joined: 10/28/2016
Posts: 10

Thanks a lot

Bruce_L
Posted : Tuesday, April 11, 2017 10:33:38 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

You're welcome.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.