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 |

Double Stochastic was in EasyLanguage, could use some conversion help Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
JRSnell
Posted : Wednesday, January 21, 2009 10:53:43 AM
Registered User
Joined: 10/7/2004
Posts: 6

I'm working on a custom indicator for TC200 that I've used for years under TradeStation. I'm pretty familiar with Easy Language, but I'm having trouble getting it done for TC2000...

Basically, it starts with a typical stochastic calculation... I'm using 10 periods... I've tentatively written this for %K:

((C-MINL10)/(MAXH10-MINL10))*100

Which is a pretty generic stochastics calculation... as far as I can tell, right?

From here, the Easy Language steps to make it the double stochastic are to find the lowest %K for the last 10 periods and the highest %k for the last 10 periods to construct another formula. Is there a way to discover the highest and lowest %K's from the initial formula to use in this final formula? It seems that TC2000 can find it with High,Low,Close, etc (i.e. MINL10)... how is it done for other values?

Bruce_L
Posted : Wednesday, January 21, 2009 11:43:19 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try the following:

100 * (STOC10 - MIN(STOC10,10)) / (MAX(STOC10,10) - MIN(STOC10,10))

You may wish to review the following:

PCF Formula Descriptions
How to create a Personal Criteria Forumula (PCF)
Understanding Stochastics
Handy PCF example formulas to help you learn the syntax of PCFs!

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
JRSnell
Posted : Wednesday, January 21, 2009 11:51:56 AM
Registered User
Joined: 10/7/2004
Posts: 6
Bruce,

Thanks... this just may do it. I guess somewhere I didn't see that the MIN MAX function had other options. Still a bit of a noobie I guess.

One question though... the STOC10 Worden calc... Is this the same as the calc that I had in my post?

((C-MINL10)/(MAXH10-MINL10))*100

Jeff (aka Sir Grail)
Bruce_L
Posted : Wednesday, January 21, 2009 12:01:24 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
STOC10 = ((C-MINL10)/(MAXH10-MINL10))*100

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
JRSnell
Posted : Wednesday, January 21, 2009 1:23:25 PM
Registered User
Joined: 10/7/2004
Posts: 6

Got it... it computes, but is a bit more erratic than what I see in TS. Here's the whole thing with my feeble explanations....

Num = C-_Lst(L,DStLen);
Denom = _Hst (H,DstLen) - _Lst (L,DstLen);


These two statements set up the numerator and denominator of the Stochastic. The Num contains the "_Lst" function which is just the "lowest" (x,y)... so, lowest low of last 10 bars. Ditto reverse for the Denom "_hst" function.

Ratio = IFF (Denom>0, (Num/Denom)*100,Ratio[1]);

This "IFF" is an "if-then" thing: If Denom>0, then calculate the regular stochastic, otherwise use yesterday's.

PctK = IFF (CurrentBar=1,Ratio, PctK[1]+(.5*(Ratio-PctK[1])));

Another "IFF": If you're evaluating the first bar, then use the ratio... otherwise use yesterday's PctK and add half of today's ratio minus yesterday's PctK.

And then we do the whole thing over again for PctK, which gives me the "double" stochastic...

DNum = PctK - _Lst (PctK,DstLen);
DDenom = _Hst (PctK,DstLen) - _Lst (PctK, DStLen);
DRatio = IFF (DDenom>0, (DNum/DDenom) * 100, DRatio[1]);
DPctK=IFF (CurrentBar=1, DRatio, DPctK[1]+(.5*(DRatio - DPctK[1])));

and DPctK is what is plotted.

It seems like it might be doable in TC2000... but I am really getting hung up on these "IFF" things and how to relate this to how TC2000 works.

Thanks again for ANY help,

Jeff

Bruce_L
Posted : Wednesday, January 21, 2009 1:39:05 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It's smoother because the Ptck line is adding a 3-Period Exponential Moving Average (as is the DPctK line). Unfortunately, this makes the resulting formula (at least those constructed using any methods that come to mind) too long to be practical.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
JRSnell
Posted : Wednesday, January 21, 2009 1:47:24 PM
Registered User
Joined: 10/7/2004
Posts: 6
Bruce,

That's a bummer. I've been a user for nearly 20 years but I've always had to keep another platform around to be able to use this formula. I was hoping to finally get it over to TC2000 to simplify life.

If you can think of any way to get it done... or if anyone else out there can... I would be ecstatic.

Sir Grail
Bruce_L
Posted : Wednesday, January 21, 2009 1:56:14 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I can do it using 3-Period Simple Moving Averages:

100 * ((STOC10.3 - MIN(STOC10.3,10)) / (MAX(STOC10.3,10) - MIN(STOC10.3,10)) + (STOC10.3.1 - MIN(STOC10.3.1,10)) / (MAX(STOC10.3.1,10) - MIN(STOC10.3.1,10)) + (STOC10.3.2 - MIN(STOC10.3.2,10)) / (MAX(STOC10.3.2,10) - MIN(STOC10.3.2,10))) / 3

But 3-Period Exponential Moving Averages would seem to require the manual expansion of all of the Moving Averages, Minimum and Maximums. It's a limitation of TeleChart's Personal Criteria Formula Language (it could be done in StockFinder rather easily).

Min Max PCFs
Cascades of Moving Averages

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Thursday, January 22, 2009 6:15:52 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Jeff,

Bruce gave you an Indicator Formula to use if you are willing to replace both EMA3's by SMA3's.  It is only the first EMA3 which causes the problem.  If you are willing to replace it by an SMA3, then use the Indicator Formula:

100 * (STOC10.3 - MIN(STOC10.3,10)) / (MAX(STOC10.3,10) - MIN(STOC10.3,10))

and use either EMA3 or SMA3 as the "Smoothing Average".

Thanks,
Jim Murphy
Bruce_L
Posted : Thursday, January 22, 2009 10:13:07 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
JRSnell,
If you are just plotting this as a Custom Indicator, bustermu's formula will work by applying the built in Smoothing. It's also possible to create the second Moving Average as an Exponential expansion if you need it as a Personal Criteria Formula:

50.0488758553275 * ((STOC10.3 - MIN(STOC10.3,10)) / (MAX(STOC10.3,10) - MIN(STOC10.3,10)) + .5 * ((STOC10.3.1 - MIN(STOC10.3.1,10)) / (MAX(STOC10.3.1,10) - MIN(STOC10.3.1,10)) + .5 * ((STOC10.3.2 - MIN(STOC10.3.2,10)) / (MAX(STOC10.3.2,10) - MIN(STOC10.3.2,10)) + .5 * ((STOC10.3.3 - MIN(STOC10.3.3,10)) / (MAX(STOC10.3.3,10) - MIN(STOC10.3.3,10)) + .5 * ((STOC10.3.4 - MIN(STOC10.3.4,10)) / (MAX(STOC10.3.4,10) - MIN(STOC10.3.4,10)) + .5 * ((STOC10.3.5 - MIN(STOC10.3.5,10)) / (MAX(STOC10.3.5,10) - MIN(STOC10.3.5,10)) + .5 * ((STOC10.3.6 - MIN(STOC10.3.6,10)) / (MAX(STOC10.3.6,10) - MIN(STOC10.3.6,10)) + .5 * ((STOC10.3.7 - MIN(STOC10.3.7,10)) / (MAX(STOC10.3.7,10) - MIN(STOC10.3.7,10)) + .5 * ((STOC10.3.8 - MIN(STOC10.3.8,10)) / (MAX(STOC10.3.8,10) - MIN(STOC10.3.8,10)) + .5 * ((STOC10.3.9 - MIN(STOC10.3.9,10)) / (MAX(STOC10.3.9,10) - MIN(STOC10.3.9,10))))))))))))

But again, while the second Moving Average is Exponential, the first is Simple.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
JRSnell
Posted : Friday, January 23, 2009 12:29:35 PM
Registered User
Joined: 10/7/2004
Posts: 6
Hi Bruce,

You say it would be pretty simple in StockFinder? I looked at the product... looks pretty interesting.

Do you think it would still be easy enough to learn the language AND figure out how to get my original formula programmed?

Like I mentioned before... I know TS EasyLanguage fairly well... but beyond that, nothing about VB etc.

Thanks,

Jeff
Bruce_L
Posted : Friday, January 23, 2009 12:36:18 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
JRSnell,
Here's how easy it is in StockFinder:

- Select Add Indicator | Select... | Stochastics | OK.
- Adjust the Period to 10, the %K to 3 and the Avg Type to Exponential.
- Select Add Indicator | Select... | Stochastics of Indicator | OK | Stochastics | OK.
- Adjus the Period to 10, the %K to 3 and the Avg Type to Exponential.

You could then optionally uncheck Draw on Chart for the original Stochastic to get rid of that line and delete any of the other Indicators in the Pane (%D, OB and OS).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
JRSnell
Posted : Friday, January 23, 2009 12:42:44 PM
Registered User
Joined: 10/7/2004
Posts: 6
Bruce,

Thanks. You looked at the original formula (the one in EL that I posted)... Does the manner you suggest EXACTLY duplicate that formula?

Thanks,

Jeff
Bruce_L
Posted : Friday, January 23, 2009 12:51:07 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I don't know EasyLanguage, so I can't say for sure. That said, I suspect it would differ in one regard. The algorithm in your Wednesday, January 21, 2009 1:23:25 PM ET post would seem to leave the Stochastic at its previous value when the highest High over the last ten Periods is the same as the lowest Low over the last ten Periods. A normal Stochastic would assign this a value of 50 by definition. This would only affect the results when the Price underwent absolutely no change over the course of ten Bars.

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