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 |

Custom Cumulative Indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
tonyofderby
Posted : Tuesday, May 2, 2006 1:39:02 PM
Registered User
Joined: 2/21/2006
Posts: 24
Good afternoon.

I have created a custon indicator to increment when a given condition is satisfied on the chart. This works insofar as it increments (by one) each time the condition appears and this can be easily observed (there are very few occasions when my criteria are met).

However, the counter doesn't start at one; it starts to increment at another number, a number less than 10, but apparently random.

I understood that only the extent of the chart on show is assessed for the criteria conditions, but the cumulating numbers suggest that it has 'looked at' some period prior to the visual chart.

Is there something that I might be doing wrong that you can easily correct?

Regards

Tony
Bruce_L
Posted : Tuesday, May 2, 2006 1:49:46 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Based on my tests, it appears that a Custom Cumulative Indicator is calculated for any portion of the chart required to calculate any other indicator on the chart even if that portion is not visible.

If there is nothing on the chart besides Price and the Custom Cumulative Indicator, the calculation will use very little data prior to the chart, but if you add a 500-Period Exponential Moving Average, a lot more prior data will be used.

This is not an unexpected result. The actual value of Cumulative Indicators are meaningless because you don't know the start date of the calculation. The value has meaning only when compared to other values of the same indicator on the same chart calculated at the same time.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Tuesday, May 2, 2006 2:05:26 PM
Registered User
Joined: 2/21/2006
Posts: 24
Hi Bruce. Thank you for your reply.

There is nothing on the chart apart from the price bars and the custom indicator.

One of the indicator criteria is that the condition is met subject to SK and SD exponential stochastic moving averages (you sorted me out on this a couple of weeks ago!) for the previous 10 working days holding a certain relationship. However, the counter should only increment for the condition at the end of this 10 day period, ie, when seen on the chart.

Typically, for a relatively short time period up to 2-3 months, the conditions are satisfied up to a max of about 5 times. I have scrolled back a few days and there is nothing on the chart that includes the 10 days that would cause a counter to increment.

This problem occurs on every chart I bring up, but the counter error varies for each chart.

Does this confuse, or clarify? I guess I can always subtract the 'error', from the counter, but I suspected I was making some simple error.

Regards

Tony
Bruce_L
Posted : Tuesday, May 2, 2006 2:23:38 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I don't think I'm understanding the question. If you are actually using the Custom Cumulative Indicator as a Cumulative Indicator, its actual value is meaningless.

If you are trying to count how many times a Boolean condition returns True in a specific period, a better option might be to create a normal Custom Indicator with the Boolean condition in parentheses. Multiply the result by negative one times the period, set the Smoothing Average to the period and the Average Type to Simple.

For example, if you wanted to count how many times the Net Change was positive at Zoom 9:

Select Chart Template | Add Indicator | Indicator.
-Visible: Checked
-Center Zero Line: Unchecked
-Plot using price scale: Unchecked
-Smoothing Average: 19
-Average Type: Simple
-Indicator Formula: (C > C1) * ( - 19)

You would obviously need to substitute the appropriate Boolean formula. The period is not limited to the Zooms available in TeleChart, but if you wish to count the number of times something happens on the chart, the number of bars required will vary by Zoom and if the formula needs to count the bar that is halfway off the left edge of the chart:

Zoom 1++ (1125 or 1124 Bars)
Zoom 1+ (750 or 749 Bars)
Zoom 1 (500 or 499 Bars)
Zoom 2 (333 or 332 Bars)
Zoom 3 (222 or 221 Bars)
Zoom 4 (148 or 147 Bars)
Zoom 5 (99 or 98 Bars)
Zoom 6 (66 or 65 Bars)
Zoom 7 (44 or 43 Bars)
Zoom 8 (29 or 28 Bars)
Zoom 9 (20 or 19 Bars)

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Tuesday, May 2, 2006 2:47:17 PM
Registered User
Joined: 2/21/2006
Posts: 24
Bruce, many thanks.

I am following the procedure outlined in a Worden note on 19 April on backtesting. If you look it up, you will see exactly what I am trying to achieve, in principle.

The simple example given worked well, but I am using the technique to test a more complex scenario. What I have described is the set-up condition. As I have said, it does work, but with a 'zero error'! What I have yet to do is put in the second cumulative indicator, along the lines described in the Worden note.

Your response gives a way of doing what I want (I think!), but my criteria are quite extensive. Also, I'm not clear what the -19 in brackets is.

I don't want to waste your time pursuing this if there is no obvious answer; I thought there might be a simple answer to my problem.

Tony
Bruce_L
Posted : Tuesday, May 2, 2006 3:03:57 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The ( - 19) is negative one times the number of bars in Zoom 9 chart. On a Zoom 1++ chart, the same Boolean formula would use ( - 1124) and have a Period of 1124.

A Boolean formula in parentheses will return zero when False and negative one when True. Unless it as adjusted, the Simple Moving Average would be the ratio of the number of times the formula returned True to the number of bars in the period multiplied by negative one. If I multiply the result by ( - 100) I'd get a percentage, but if I multiply the result by ( - period) I get a count.

As long as the formula is Boolean, you should be able to place the parentheses around the entire formula even if it is fairly complex. If you are getting a Divide by Zero Error, that might actually be what is happening. You may need to adjust your formula to add or a subtract a small value (say .00001) from any denominators in your formula.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Tuesday, May 2, 2006 3:16:58 PM
Registered User
Joined: 2/21/2006
Posts: 24
Bruce

I understand where you are coming from, now.

The approach I was taking used the information window in the top left of the chart screen, (after pressing period twice), to display a numerical count of the occasions when the criteria are met.

I will try your approach to see if there is any difference.

Thanks again. If you have any further thoughts, let me know.

Tony
Bruce_L
Posted : Tuesday, May 2, 2006 3:19:28 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome. If I come up with anything else, I'll mention it in this topic.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
bustermu
Posted : Tuesday, May 2, 2006 11:40:04 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
Tony,

The Custom Cumulative Indicator, the Custom indicator, and the Custom Percent True Indicator can all be used to count the number of times a Boolean PCF returns True over any given interval.

For the Cumulative Indicator, you have to view the entire interval plus one bar on the left and subtract the values at the endpoints of the observed interval. The advantage is that you can observe where the PCF returned True.

For the other two, you only have to read the interval's right end point value and multiply by the SMA period and, for the Percent True Indicator, divide by 100. You cannot observe where the PCF returned True and you have to change the SMA period each time you change the interval's length.

Thanks,
Jim Murphy
Bruce_L
Posted : Wednesday, May 3, 2006 8:59:27 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (bustermu)
The Custom Cumulative Indicator, the Custom indicator, and the Custom Percent True Indicator can all be used to count the number of times a Boolean PCF returns True over any given interval.

Both the Custom Cumulative and the Custom Percent True methods require computation after the fact. Only the basic Custom Indicator method allows the value to be displayed directly.

QUOTE (bustermu)
For the Cumulative Indicator, you have to view the entire interval plus one bar on the left and subtract the values at the endpoints of the observed interval.

The subtraction appeared to be what tonyofderby was trying to avoid (especially considing the starting value was not as consistent as was desired).

QUOTE (bustermu)
The advantage is that you can observe where the PCF returned True.

And the Custom Indicator has the advantages of the value being displayed with no additional work in the Data Box when using Pointer Mode and being able to visually compare the counts to previous periods of the same length.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Wednesday, May 3, 2006 10:02:57 AM
Registered User
Joined: 2/21/2006
Posts: 24
Good morning Trainers

Thank you Bruce and Jim for your added comments. Whilst I am absorbing their significance for my problem, I would like to extend my study by asking another question:

I have used the technique suggested by Bruce and have been able to identify all occasions when my set-up condition occurs as a series of step changes in the bottom window. The condition is based on a certain pattern of stochastics as previously discussed, as determined by a Boolean expression.

I now wish to show how much the price changes during the n-days following each time that set-up condition has been satisfied. In other words, the set-up being satisfied (I can see when each instance occurs) should be the trigger to calculate the price change in the subsequent n-days. Ideally I would like this to be a percentage for each occasion, either + or -.

Is this possible?

Thank you in anticipation...

Regards

Tony
bustermu
Posted : Wednesday, May 3, 2006 10:36:00 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (Bruce_L)
...


All that was said is correct, of course.

Thanks,
Jim Murphy
Bruce_L
Posted : Wednesday, May 3, 2006 10:40:04 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (tonyofderby)
I have used the technique suggested by Bruce and have been able to identify all occasions when my set-up condition occurs as a series of step changes in the bottom window.

If this is your intent, the Custom Cumulative Indicator is a better option, because it is only adjusted based on what is being counted at the time the adjustment is made. The method I outlined can step up or down based on what is leaving the period being counted as well.

QUOTE (tonyofderby)
I now wish to show how much the price changes during the n-days following each time that set-up condition has been satisfied. In other words, the set-up being satisfied (I can see when each instance occurs) should be the trigger to calculate the price change in the subsequent n-days. Ideally I would like this to be a percentage for each occasion, either + or -.

Please try the following:

Select Chart Template | Add Indicator | Cumulative.
-Visible: Checked
-Up Condition: The condition you are testing re-written for n-Periods ago.
-Down Condition: C < C - 1
-Value To Add/Subtract: Price Percent Change Formula for n-Periods.

For example, if you wanted to test what happens during the 10-Periods following the SD of a Simple Stochastic (10,3,3) crossing down through 80, you could write the following:

Select Chart Template | Add Indicator | Cumulative.
-Visible: Checked
-Up Condition: AVG(STOC10.3.10,3) < 80 AND AVG(STOC10.3.11,3) >= 80
-Down Condition: C < C - 1
-Value To Add/Subtract: 100 * C / C10 - 100

We can adjust this or switch to an entirely different method if it doesn't work as desired.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Wednesday, May 3, 2006 11:13:52 AM
Registered User
Joined: 2/21/2006
Posts: 24
Bruce

Correction on my earlier message: it is a Custom Cumulative Indicator I have placed in the bottom window, not your technique - sorry. The zero error is still there, but I can live with that; I just subtract it from the total for each chart on show to count the number of instances I can see on the chart, which also shows the stochastics as an overlay.

Tony
bustermu
Posted : Wednesday, May 3, 2006 11:57:58 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (Bruce_L)
The method I outlined can step up or down based on what is leaving the period being counted as well.

Suppose the SMA has period P.
1) If there is a step up, the PCF returned a True.
2) If there is a step down, the PCF returned a False.
3) If there is no step, then look back until you find the most recent step at a multiple P days ago. For today, the PCF returned True if that most recent step was up and False if that most recent step was down.

In summary, observe the most recent step at nonnegative multiples P days ago. If that step was up, the PCF returned True today. If that step was down, the PCF returned False today. If there is no last step?

The easy way is to put the SMA on externally and read or look at the Indicator to see whether the PCF returns True of False.

Thanks,
Jim Murphy
tonyofderby
Posted : Wednesday, May 3, 2006 12:35:18 PM
Registered User
Joined: 2/21/2006
Posts: 24
Hi Bruce

I have tried the method you outlined (actually using a simple stochastic passing up thro' 30, because it corresponds to what I have on a chart) and the cumulative indicator shows (as expected!) the accumulation of gains/losses.

The result is confused by the zero error previously discussed; the starting value for the accumulation is not zero. If it is possible to show the price change as a spike (up or down about a zero line), that would probably meet my needs.

Is that possible?

Also, could you explain the 'value to add or subtract'? I must be getting tired - it is the end of the afternoon here in the UK...

Many thanks

Tony
Bruce_L
Posted : Wednesday, May 3, 2006 12:47:27 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you want to understand Value To Add/Subtract better, you may wish to review the following from the Online Help Files:

Custom Cumulative

Please try the following (it's a spike version of the Cumulative example I gave earlier):

Select Chart Template | Add Indicator | Indicator.
-Visible: Checked
-Center Zero LIne: Checked
-Plot using price scale: Unchecked
-Smoothing Average: 1
-Indicator Formula: (AVG(STOC10.3.10,3) < 80) * (AVG(STOC10.3.11,3) >= 80) * (100 * C / C10 - 100)

If you plot both, you will see that the spike occur where the Cumulative version changes. It will need to be adjusted to work with your test formula. One thing to notice about both is that the spike or change happens at the end of Price Percent Change Period, not when the unadjusted test itself would have returned True.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Wednesday, May 3, 2006 2:19:08 PM
Registered User
Joined: 2/21/2006
Posts: 24
Bruce

This works on the simple case I have tested it on. Thanks.

For the indicator formula, you are multiplying together two terms that I would otherwise join with an 'AND' and use as a boolean function. Have you have done this because each term becomes +1 if true, and only when both are true will the formula be calculated to a value needed.

Is my reasoning correct?

Thanks for your help.

Regards

Tony
Bruce_L
Posted : Wednesday, May 3, 2006 2:23:47 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (tonyofderby)
For the indicator formula, you are multiplying together two terms that I would otherwise join with an 'AND' and use as a boolean function. Have you have done this because each term becomes +1 if true, and only when both are true will the formula be calculated to a value needed.Is my reasoning correct?

Your reasoning appears to be correct, but I want to clarify something just to make sure. Each term actually becomes -1 if True, so multiplying them together would produce either 0 (if any are False) or +1 if both are True. If there is an odd number of conditions, the result must be multiplied by -1.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
tonyofderby
Posted : Wednesday, May 3, 2006 2:51:07 PM
Registered User
Joined: 2/21/2006
Posts: 24
Bruce

Many thanks. That is critical, as I have quite a few terms, so must check odd or even.

It's the little things that catch you out...!

Regards

Tony
tonyofderby
Posted : Thursday, May 4, 2006 11:27:27 AM
Registered User
Joined: 2/21/2006
Posts: 24
Just to say, thanks guys. It's all working as I want it, now.

Regards

Tony
Doug_H
Posted : Thursday, May 4, 2006 11:29:36 AM


Worden Trainer

Joined: 10/1/2004
Posts: 4,308
You're very welcome! We're glad to help.

- Doug
Teaching Online!
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.