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 |

Simple indicator coding guidance needed Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
PropKid
Posted : Wednesday, January 14, 2015 9:47:43 AM
Gold Customer Gold Customer

Joined: 9/28/2006
Posts: 10

I've been writing code in VBA and Tradestation's Easy Language for years. I'm looking for some simple steps to follow to code indicators. Here are some specific issues:

1. How to include a variable that will be input by the users (e.g. moving average length)

2. How to apply functions to simple calculations such as taking the average of the High minus the Low for the last 14 days. I tried "AVG(H-L,14" but get an error.

Thanks very much for the assistance.

 

Bruce_L
Posted : Wednesday, January 14, 2015 10:02:09 AM


Worden Trainer

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

TC2000 doesn't actually have a full programming or scripting language exposed which has variables or a way to get user inputs (although for something as simple as a moving average being applied to a calculation, this would be available in a Custom PCF Indicator).

TC2000's Personal Criteria Formula Language is just that, a formula language. It is designed for expressing formulas in a single logical line.

The PCF Formula Descriptions topic lists all of the syntax valid in the PCF Language and the Handy PCF example formulas to help you learn the syntax of PCFs! topic has basic examples of this syntax in use.

The AVG() function cannot be applied to other functions or to compound formulas. The first argument needs to be a single indicator with its settings and the second arguments needs to be the period of the simple moving average.

The 14 period moving average of the high minus the low can be written as follows.

AVGH14 - AVGL14

Since you seem to be interested in programming with a full programming language, it should probably be noted that StockFinder does have a full programming language called RealCode which is based on Visual Basic.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
PropKid
Posted : Wednesday, January 14, 2015 10:08:48 AM
Gold Customer Gold Customer

Joined: 9/28/2006
Posts: 10

Thanks, Bruce!

Quick follow-up:

Won't the code you offered below first calculate the average of the highs for the last 14 days, then subtract the average for the lows of the last 14 days from that? That would be a much different result than an average of H-L for each day in the same time period.

AVGH14 - AVGL14

Bruce_L
Posted : Wednesday, January 14, 2015 10:16:04 AM


Worden Trainer

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

That is exactly what it would do, but the result in this particular case is also exactly the same.

You could manually expand everything out to see this is the case or try a simple example where you plot two Custom PCF Indicators. In the first case use the following settings.

- Period: 14
- Average Type: Simple
- Formula: H - L

And in the second case use the following settings.

- Period: 1
- Average Type: Simple
- Formula: AVGH14 - AVGL14

The plots will be exactly the same. Now if you had a 1-period percent change.

100 * (C / C1 - 1)

And you wanted to add say a 5-period simple moving average to it, you would need to manually expand the formula because of the division.

100 * ((C / C1 + C1 / C2 + C2 / C3 + C3 / C4 + C4 / C5) / 5 - 1)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
PropKid
Posted : Wednesday, January 14, 2015 10:26:12 AM
Gold Customer Gold Customer

Joined: 9/28/2006
Posts: 10

I stand corrected. I dumped some of the SPX data to prove the ATR calculation to myself in Excel. Just don't tell my highschool math teacher that I had to do that....

Bruce_L
Posted : Wednesday, January 14, 2015 10:27:36 AM


Worden Trainer

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

As long as your high school math teacher doesn't read the forums, I think you are fine. Besides, I'm guessing your high school math teacher didn't know you as PropKid.



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