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 |

Num of days > 50 Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thnkbigr
Posted : Wednesday, November 14, 2018 3:47:33 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

In TC I need a PCF that counts the number of days in a row stocks closed above its 50 day MA and reset to 0 once it closes below it. The count will re-start once it crosses and closes above the 50 day again. 

StockGuy
Posted : Wednesday, November 14, 2018 4:37:29 PM

Administration

Joined: 9/30/2004
Posts: 9,187

TRUEINROW(C > AVGC50,200)

This looks at the most recent 200 bars (days).  You can increase the 200 if you need to.

thnkbigr
Posted : Wednesday, November 14, 2018 6:15:55 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Can I do this in a way that once the stock crosses and closes below the 50 day causing the indicator to re-set to 0 it would now start counting the closes below the 50 day

For ex assume the stock closed above its 50 day for 75 days and the indicator continued to count up to 75 once it closed below the 50 day the count will re-set and start counting num of days that closed below the 50 day

I guess we need to say count days since last cross  

thnkbigr
Posted : Wednesday, November 14, 2018 6:31:01 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

I guess this does it 

TRUEINROW(C > AVGC50,200) + TRUEINROW(C < AVGC50,200)

StockGuy
Posted : Wednesday, November 14, 2018 7:03:31 PM

Administration

Joined: 9/30/2004
Posts: 9,187

To help distinguish between the two you could multiply the second part by -1.

TRUEINROW(C > AVGC50,200) + (TRUEINROW(C < AVGC50,200) * -1)

This would plot a negative value when C < AVGC50.

thnkbigr
Posted : Wednesday, November 14, 2018 9:02:53 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Thanks 

thnkbigr
Posted : Thursday, November 15, 2018 1:12:47 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

What do i need to add here to offset this PCF by 1 day

I need the new PCF to show what was the value of this PCF yesterday

TRUEINROW(C > AVGC50 - ATR50 AND C < AVGC50 + ATR50,200) 

Bruce_L
Posted : Thursday, November 15, 2018 1:58:34 PM


Worden Trainer

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

You would add 1 to all of the bars ago parameters (which are currently at the zero default).

TrueInRow(ABS(C1 - AVGC50.1) < ATR50.1, 200)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Friday, November 16, 2018 12:37:43 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Bruce I need a little bit of your magic touch here 

I want to add a little room here so that the indicator doesn't constantly reset to 0 if price barely closes above or below the 50 day 

Any way I can do something here so that the indicator will start counting the days from when price closes above the 50 day + ATR50 and reset to 0 when it closes below the 50 day - ATR50

Close > 50 Day + ATR = Start count

Close < 50 Day - ATR = reset 

Thank you 

Bruce_L
Posted : Friday, November 16, 2018 12:48:33 PM


Worden Trainer

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

The formula in my Thursday, November 15, 2018 1:58:34 PM ET post shouldn't reset whenever price closes barely above or below the 50 day. It won't reset unless price is at least the 50 period average true range above or below the 50 day simple moving average.

So maybe something like the following?

TrueInRow(ABS(C - AVGC50) < ATR50, 200) * SGN(SinceTrue(C <= AVGC50 - ATR50, 200) - SinceTrue(C >= AVGC50 + ATR50, 200))



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Friday, November 16, 2018 2:26:09 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Bruce something is off with both look at AAP as one ex 

During June to Oct when the stock was clearly above the 50 day both indicators sat at 0

The indicator should start counting from the first day stock closes above 50 day + ATR and reset to 0 and count up each day until it closes below the 50 day - ATR

 

Bruce_L
Posted : Friday, November 16, 2018 2:39:25 PM


Worden Trainer

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

I misunderstood and thought you wanted it to be between the ranges as in the last request. That said, I don't think we can create a formula which actually does what you want.

About the best I can think of would be to count the number of bars price has been above AVGC50 - ATR50.

TrueInRow(C > AVGC50 - ATR50, 200)

Now you can make it so it only returns this number when price is above the 50 if you want (but the value doesn't "reset" unless price drops to AVGC50 - ATR50 or below).

TrueInRow(C > AVGC50 - ATR50, 200) * IIF(C > AVGC50, 1, 0)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Sunday, November 18, 2018 10:50:17 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Bruce is there any way i can do the above with Volatility stop loss

Count num of days stock closed above VST 22ATR, Multiplier 4

Bruce_L
Posted : Monday, November 19, 2018 8:45:26 AM


Worden Trainer

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

No, I cannot think of a way to do so as I do not know of any method to reproduce the Volatility Stop indicator in the Personal Criteria Formula Language.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 20, 2018 10:32:16 AM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

My guess this is not possible in TC but it doesn't hurt to ask 

Bruce you have anyway in mind to be able to count the number of swings that were > 4 * ATR22 over a period of time. let's use last 126 days

My goal is to get rid of stocks that have too many swings back and forth and continue to chop

So looking at the last 6 months is there a way to count how many times the stock has swung back and forth that was > 4 * ATR22

Assume ATR22 is 1 and the stock moved from 20 to 25 (Swing 1) and reversed down to 20 ( Swing 2) if it reversed back up to 25 again that would be 3 swings 

But if the stock just moved up from 20 to 40 without ever dropping 4 * ATR the entire move is 1 swing 

  

Bruce_L
Posted : Tuesday, November 20, 2018 11:20:01 AM


Worden Trainer

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

I can't really think of a good method, but maybe you can work with something like the following. Count the number of times price crossed up through the max high over some period minus four times ATR and add that to the number of times price crossed down through the min low over some period plus four time ATR. Unfortunately, if you whipsaw near the top or bottom of the range it would trigger it could count extra swings and you are pretty much stuff with a fixed span for the swing.

CountTrue(XUP(L, MAXH22 - 4 * ATR22), 126) + CountTrue(XDOWN(H, MINL22 + 4 * ATR22), 126)

It the theoretical sense you could do something like check for the low to just be less than or equal to the max high minus four times the ATR and make sure it is the first time it happened by checking that the last time it happened was more bars ago than the last time the high was equal to the min low plus four times the ATR. This would avoid multiple counts from whipsaws and could be reversed, but the formula would be too slow to be practical or post in the forums (even though it wouldn't be that long).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Tuesday, November 20, 2018 4:49:45 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Thanks

Take a look at FANG as a perfect example. it has been swinging back and forth all year 

How about counting the number of bars between Last 33 Day Closing High to Last 33 Day Closing Low

Can we write a PCF that would be able to start counting from the last 33 day High and Re-set to 0 on the 33 Day Low  

 

Bruce_L
Posted : Tuesday, November 20, 2018 5:18:59 PM


Worden Trainer

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

So something like the following?

IIF(TrueInRow(C > MINC33, 75) < TrueInRow(C < MAXC33, 75), 0, TrueInRow(C < MAXC33, 75))



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