Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Avg above and max in row Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
0002ct
Posted : Friday, February 2, 2018 10:18:38 AM
Registered User
Joined: 11/19/2015
Posts: 459

Hello.

Could I please be helped with two evaluations?

1. Output the average times-in-a-row price has been at or above BB 18 1.78 over the last 175 bars. What I'm looking for here is "what is average consecutive run length of close being at or above that BB line".

2.  Over the last 175 bars, how many bars was the max consecutive run of price at or above the same BB line?

Thank you very much.

Bruce_L
Posted : Friday, February 2, 2018 10:42:14 AM


Worden Trainer

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

For the average, maybe something like the following?

SUM(IIF(TrueInRow(C < BBTOP(1.78, 18), 2) = 1, TrueInRow(C1 >= BBTOP(1.78, 18, 1), 10), 0), 175) / CountTrue(TrueInRow(C < BBTOP(1.78, 18), 2) = 1, 175)

For the maximum, maybe something like the following?

MAX(IIF(TrueInRow(C < BBTOP(1.78, 18), 2) = 1, TrueInRow(C1 >= BBTOP(1.78, 18, 1), 10), 0), 175)

Note that the run needs to have finished in order to get counted and included in the average. A current run where price is still at or above the top Bollinger Band is not included in the average or maximum.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Friday, February 2, 2018 11:56:16 AM
Registered User
Joined: 11/19/2015
Posts: 459

Thank you, Bruce. These work well. I appreciate the help.

0002ct
Posted : Friday, February 2, 2018 1:15:32 PM
Registered User
Joined: 11/19/2015
Posts: 459

Bruce, a question.
What's the 10 here? 1.78, 18, 1), 10

MAX(IIF(TrueInRow(C < BBTOP(1.78, 18), 2) = 1, TrueInRow(C1 >= BBTOP(1.78, 18, 1), 10), 0), 175)

Thank you.

 

Bruce_L
Posted : Friday, February 2, 2018 1:19:00 PM


Worden Trainer

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

The TrueInRow() function is not open ended. The 10 is the maximum number of bars in a row for which the formula checks. The number returned by:

TrueInRow(C1 >= BBTOP(1.78, 18, 1), 10)

Ranges from 0 through 10. If it is true 20 bars in a row, it would still return 10 because it would not be checking bars 11 through 20.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Friday, February 2, 2018 1:38:35 PM
Registered User
Joined: 11/19/2015
Posts: 459

Gotcha. So 10 is a limit, if I understand correctly?

Bruce_L
Posted : Friday, February 2, 2018 1:48:32 PM


Worden Trainer

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

Yes, it is a limit of sorts. It limits the maximum number of bars in a row. You can however change the 10 to a different number of you want. Note that setting this too high can make the formula slower.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Friday, February 2, 2018 2:07:18 PM
Registered User
Joined: 11/19/2015
Posts: 459

I see, so not a system limit (like, say, an absolutely max lookback) It just defines the end limit to include for the formula itself.  If I change that, does anything else need to change? 

One related question: Have I correctly used EMA8 in the same formula below?

MAX(IIF(TrueInRow(C < XAVGC8, 2) = 1, TrueInRow(C1 >= XAVGC8, 1), 10), 0), 175)

Thanks for help, Bruce.
Bruce_L
Posted : Friday, February 2, 2018 2:13:24 PM


Worden Trainer

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

Nothing else would need to be changed.

Your formula for EMA8 is close, but the second part does not correctly convert XAVGC8 to XAVGC8.1 to get the one bar ago version.

MAX(IIF(TrueInRow(C < BBTOP(1.78, 18), 2) = 1, TrueInRow(C1 >= XAVGC8.1, 10), 0), 175)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
0002ct
Posted : Friday, February 2, 2018 2:41:44 PM
Registered User
Joined: 11/19/2015
Posts: 459

Ah, oops. I actually knew that. I'm not sure if it matters that I knew that, since knowing that didn't change what I did. 

Thanks again, Bruce. Have a nice weekend.

Bruce_L
Posted : Friday, February 2, 2018 2:42:41 PM


Worden Trainer

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

You're welcome. Have a nice weekend.



-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.