Subscription & data-feed pricing Class schedule

Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.

 first and second derivitive tests? Rate this Topic:
 Previous Topic · Next Topic Watch this topic · Print this topic ·
scottnlena
 Posted : Wednesday, November 18, 2009 1:55:28 AM

Registered User
Joined: 4/18/2005
Posts: 4,090
Is it possible to write code that will filter for stocks that pass a first and second derivitive test on say a 10 day time frame ?
mammon
 Posted : Wednesday, November 18, 2009 9:45:44 AM
Gold Customer

Joined: 11/11/2006
Posts: 359
Scott:

I do not know the answer to your question, but I am delighted to see you posting again.

Family fine I hope?

Mammon
william4567
 Posted : Wednesday, November 18, 2009 12:55:59 PM
Gold Customer

Joined: 11/22/2006
Posts: 100

Scottnlena,

Its interesting to see the type of questions your academic studies has led you to.

I tried going for a visual solution to your question in Telechart. . Whether its the best way to go, I'm not sure. Trying to write code just gives me a headache. Stockfinder might give you better options in finding your answer. I'm no expert in this sort of thing, so proceed with caution. Here is my partial solution to get you started.

I applied a simple moving average to price, with a setting of 1 for now. I believe you need to smooth the data, not sure to what.  Added a Rate of Change of the Moving Average for the first derivative.   Add a Rate of Change to the first Rate of Change for the second derivative.  Use Visual Sorting of the different Rate of Change to find what you need. Looking for a zero line cross, direction of the line slope or maximum/minimum values will require a bit of visual inspection. You ask for a 10 day range, is that a 10 day bar?

Good Luck to you . Good to see you posting again.

William

diceman
 Posted : Wednesday, November 18, 2009 7:06:22 PM
Registered User
Joined: 1/28/2005
Posts: 6,049
william4567

If your interested in the combination of smoothing and momentum/ROC
it sounds like the indicator TRIX.

(realize that with smoothing set to 1 there is basically no smoothing)

If your interested here's a method to set it up in
telechart:

Thanks
diceman
william4567
 Posted : Thursday, November 19, 2009 7:25:11 AM
Gold Customer

Joined: 11/22/2006
Posts: 100
Thanks Diceman for the video link on the Trix.  It was a good review on proper Telechart technique and bigger ideas.  The smoothing set to 1 was just to allow the use of ROC. The video showed a better way to get the job done.   I used the term "smoothing" a bit loosely.  From what I saw graphically from what I suggested didn't look very useful for the 2nd ROC.  I have to review the rules of 1st and 2nd derivative test.  Calculus was too many years ago for me.  Yes I know, just Google.

Thanks.

William
driger
 Posted : Thursday, November 19, 2009 9:50:42 AM

Registered User
Joined: 12/31/2005
Posts: 266
QUOTE (scottnlena)
Is it possible to write code that will filter for stocks that pass a first and second derivative test on say a 10 day time frame ?

pretty vague question, but wouldn't you simply just scan based on the second derivative, since if the requirements of the second derivative were satisfied, then requirements for the first derivative would be satisfied also?
scottnlena
 Posted : Thursday, November 26, 2009 3:19:55 PM

Registered User
Joined: 4/18/2005
Posts: 4,090
Drigger and all.

Family is fine, Daughter growing like a weed.  Little smarty pants.  Sings the alphabet at 2, spells 5 words and completes puzzels for 3-4 year olds.

Driger, The first derivitive is the slope of the origiinal function at a point or the equation that gives the slope at that point.  The 2nd derivitive boils down to positive or negative.  This gives us concavity.  Take a bowl and look at it.  Mathematically speaking it's concave up.  Now turn the bowl upside down on the table.  That is called concave down.  Imagine that as a section of a stock chart.  I'd rather be riding the the inside concave up slop than the outside (upsidedown) concave down slope.

Both have a positive slope (greater than 0 first derivitive) but the concave down example will have a negative value for the upside down bowl and a positive value for the bowl in the right side up position.  So BOTH must be positive ... or negative togeather.  This would be a pair of conditions that will be true in the begining of a parobolic or exponential graph of price.

forgive spelling.  Late for a T-day party.
driger
 Posted : Friday, November 27, 2009 2:08:05 AM

Registered User
Joined: 12/31/2005
Posts: 266
QUOTE (scottnlena)
Drigger and all.

Family is fine, Daughter growing like a weed.  Little smarty pants.  Sings the alphabet at 2, spells 5 words and completes puzzels for 3-4 year olds.

Driger, The first derivitive is the slope of the origiinal function at a point or the equation that gives the slope at that point.  The 2nd derivitive boils down to positive or negative.  This gives us concavity.  Take a bowl and look at it.  Mathematically speaking it's concave up.  Now turn the bowl upside down on the table.  That is called concave down.  Imagine that as a section of a stock chart.  I'd rather be riding the the inside concave up slop than the outside (upsidedown) concave down slope.

Both have a positive slope (greater than 0 first derivitive) but the concave down example will have a negative value for the upside down bowl and a positive value for the bowl in the right side up position.  So BOTH must be positive ... or negative togeather.  This would be a pair of conditions that will be true in the begining of a parobolic or exponential graph of price.

forgive spelling.  Late for a T-day party.

not really sure how all that relates to charting stocks, but the general definition of a derivative is a substance that can be derived from another substance.

when i think of something that is derived from something else in charting, i think of applying an indicator to a stockchart to get a buy or sell signal. i guess when u say 2nd derivative i'm thinking of derivative derived from another derivative.

btw, i took 4 semesters of calculus in college. thats about the last time i ever used it.
scottnlena
 Posted : Friday, November 27, 2009 8:37:08 PM

Registered User
Joined: 4/18/2005
Posts: 4,090
Actually, mathematically speaking a derivitive is the reate of change of a function.  I make no claims to fame in calculus.  I'm getting clobbered to be honest.

4 semesters is no where near whare I want to take calculus.  Mostly becasue I think that there is no way to tell the future no matter how intricate the equation is.  I'm not gong into physics or engeeneering in which I need to calculate the area and surface area of complex vessels or the possible fill rate as a function of shape and surface area..  No thanks.

This first and 2nd derivitive stuff is about as basic as it gets in Calculus.  An in terms of trading and investing I'd be suprised if any of it is used.  Despite all the finance based questions in my homeworks.  More of it comes to use where it overlaps with probability theory.  the rest of calculus I see as a prime tool for building rockes and planning satelite orbits.  I don't want to be anywhere near my rocket when it's launched and my satelite is likely to knock out cellphone service for 2/3 of all americans.

I just got to thinking about the concepts of 1st and 2nd derivitive as a rate of change and a rato of change of a rate of change and realized that it could be a great tool for screening trading candidates.  There will be other ways to do the same thing but that is really succinct.

Say you have a function which plots as a stock line chart.  The first derivitive will be an equation for the slope at any given point (fill in X).  Positive slope obviously means climbing stock.  2nd derivitive will show if it's accelerating or decelerating based on a positive or negative value)

Interestingly the first derivitive will cross the x axis when the original function has a slope of zero.  Where the frist derivitive takes on a slop of zero the original function has stopped accelerating.  These are critical and inflection points.  a 2nd derivitive inflection point shows the point where the concavity of the original function begins to change.  So if the stock is falling but begins to slow it's decent then it will trigger a concavity chage.  the trend is still down but it's begining to slow.  Waiting till the first derivitive turns positive then means that the trend is changing (or has changed) and the slope is up and accelerating.

that is the theory, I have no idea how well it works and that is not making any attempt to predict anything.  Pluss we all know that other factors affect prices beyond prices.  We only see what is happening and what has happened.  The next bar is a wild card.

I've been so bussy I haven't had allot of time to tinker with this stuff and I zero market expolsure right now.  so what ever happened to APSLL, David John Hall, Diceman and the rest of the gang?
funnymony
 Posted : Friday, November 27, 2009 8:52:11 PM

Registered User
Joined: 2/5/2006
Posts: 1,148
apsll has a real estate venture he's tending too. the rest are still around.
Users browsing this topic
Guest-1

 Forum Jump Customer Training & Support - Ask a Trainer - TC2000 version 12/18 - Ask a Trainer - TC2000 version 7 - Ask a Trainer - StockFinder 5.0 - PCFs, EasyScan and Custom Indicators General Discussions - Stock and Market Talk - TC2000 version 12 or 18 - TC2000 version 7 - StockFinder 5.0 - RealCode for StockFinder 5.0 Tutorial Videos - TC2000 version 12 tutorial videos - TC2000 version 7 tutorial videos 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.