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 |

MAX( XAVG( SGN( C*1.35<=XAVG(MINL500,21) ) )*C,3) .30) Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
mcwang2012
Posted : Friday, February 7, 2014 7:39:18 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

 

Can I write an indicator like this,

 

MAX( XAVG( SGN( C*1.35<=XAVG(MINL500,21) ) )*C,3) .30) 

 

in TC2000 12.4 ?

 

Br,

Mike

Bruce_L
Posted : Friday, February 7, 2014 10:16:22 AM


Worden Trainer

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

No. The syntax as given would not be valid in any version of TC2000 as it would not allow the nested functions.

It would be theoretically possible to create valid syntax for this by manually expanded the 3-period exponential moving average and the 30-period MAX() function, but the resulting formula would be too long and slow to be practical.

Cascades of Moving Averages
Min Max PCFs

In addition, while the resulting formula might work in TC2000 version 7 (albeit very slowly), it would not work at all in TC2000 version 12.4 because only the most recent 500 bars of data are available in any given time frame.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Friday, February 7, 2014 10:50:47 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

How should I write for the maximum value of the variable 《XAVG(C,30) 》 among the current and the past 29-periods? 

Br,

Mike

Bruce_L
Posted : Friday, February 7, 2014 11:06:13 AM


Worden Trainer

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

Because you can use XAVGC30 instead of XAVG(C,30), I would used the following:

MAX(XAVGC30,30)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Friday, February 7, 2014 11:08:09 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

What should I write for the maximum value of the variable 《XAVG(C,30) 》 among the current and the past 29-periods? 

Br,

Mike

mcwang2012
Posted : Friday, February 7, 2014 11:09:11 AM
Registered User
Joined: 2/17/2013
Posts: 67

got it. Tks.

mcwang2012
Posted : Wednesday, February 12, 2014 7:23:24 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

I tried my self very hard, but failed to write an expression for VARG, as shown below. 

Is there any way that I can write an indicator, VARG, as shown below.

It will be greatly appreciated for your guidance.

Br,

Mike

VAR1:=EMA(HHV(HIGH,450),21);
VAR2:=EMA(HHV(HIGH,250),21);
VAR3:=EMA(HHV(HIGH,90),21);
VAR4:=EMA(LLV(LOW,450),21);
VAR5:=EMA(LLV(LOW,250),21);
VAR6:=EMA(LLV(LOW,90),21);
VAR7:=EMA((VAR4*0.96+VAR5*0.96+VAR6*0.96+VAR1*0.558+VAR2*0.558+VAR3*0.558)/6,21);
VAR8:=EMA((VAR4*1.25+VAR5*1.23+VAR6*1.2+VAR1*0.558+VAR2*0.558+VAR3*0.558)/6,21);
VAR9:=EMA((VAR4*1.3+VAR5*1.3+VAR6*1.3+VAR1*0.68+VAR2*0.68+VAR3*0.68)/6,21);
VARA:=EMA((VAR7*3+VAR8*2+VAR9)/6*1.738,21);
VARB:=REF(LOW,1);
VARC:=SMA(ABS(LOW-VARB),3,1)/SMA(MAX(LOW-VARB,0),3,1)*100;
VARD:=EMA(IF(CLOSE*0.35<=VARA,VARC*10,VARC/10),3);
VARE:=LLV(LOW,60);
VARF:=HHV(VARD,60);
VARG:=EMA(IF(LOW<=VARE,(VARD+VARF*2)/2,0),3)/618;
plot VARG;
Bruce_L
Posted : Wednesday, February 12, 2014 3:13:59 PM


Worden Trainer

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

The biggest problem is that VARA ends up being a very long formula to the point of being too slow to be practical or post in the forums even on its own (and I tried some rather significant optimizations to try and shorten it and speed it up).

You end up needing to incorporate slightly different versions of VARA into a formula for VARG. So that that means VARG ends up being even longer and slower than VARA.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Wednesday, February 12, 2014 4:22:48 PM
Registered User
Joined: 2/17/2013
Posts: 67
Dear Bruce,
 
Your advise is always appeciated and respected. This formula is quite important to me.  I can run this formula under other analysis program. However, only TC2000 can provide me the most complete trading data. The expression compatible to TC2000 is highly desired.  I have tried to reorganize VARA as follows. 
 
VAR7=(0.96*(XAVG(MINL450,21)+XAVG(MINL250,21)+XAVG(MINL90,21))+0.558*(XAVG(MAXH450,21)+XAVG(MAXH250,21)+XAVG(MAXH90,21)))/6
VAR8=(1.25*XAVG(MINL450,21)+1.23*XAVG(MINL250,21)+1.2*XAVG(MINL90,21)+0.55*XAVG(MAXH450,21)+0.55*XAVG(MAXH250,21)+0.65*XAVG(MAXH90,21))/6
VAR9=(1.3*(XAVG(MINL450,21)+XAVG(MINL250,21)+XAVG(MINL90,21))+0.68*(XAVG(MAXH450,21)+XAVG(MAXH250,21)+XAVG(MAXH90,21)))/6 
VARA=(6.68*XAVG(MINL450,21)+6.64*XAVG(MINL250,21)+5.96*XAVG(MINL90,21)+3.454*XAVG(MAXH450,21)+3.454*XAVG(MAXH250,21)+3.654*XAVG(MAXH90,21))/36*1.738
 
But I am stucked by the next four lines. Pls help me to find a way, by any means, to get the VARG expression as an executable  indicator in TC2000 .
 
Br,
Mike 
 
VARC:=SMA(ABS(LOW-VARB),3,1)/SMA(MAX(LOW-VARB,0),3,1)*100;
VARD:=EMA(IF(CLOSE*0.35<=VARA,VARC*10,VARC/10),3);
VARF:=HHV(VARD,60);
VARG:=EMA(IF(LOW<=VARE,(VARD+VARF*2)/2,0),3)/618;

 

Bruce_L
Posted : Wednesday, February 12, 2014 4:54:52 PM


Worden Trainer

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

VARC isn't a particularly big problem.

100 * (ABS(L - L1) + ABS(L1 - L2) + ABS(L2 - L3)) / (ABS(L > L1) * (L - L1) + ABS(L1 > L2) * (L1 - L2) + ABS(L2 > L3) * (L2 - L3))

And you have come very close to what I had for an unexpanded VARA. Once we have VARA, we don't need anything above it. You appear to be missing the outer XAVG(,21) structure and I'm not quite sure if your factors or mine are correct (they don't match).

XAVG(XAVG((6.68*XAVG(MINL450,21)+6.64*XAVG(MINL250,21)+6.58*XAVG(MINL90,21)+3.464*(XAVG(MAXH450,21)+XAVG(MAXH250,21)+XAVG(MAXH90,21)))/36*1.738,21),21)

The problem is the nested 21-period exponential moving averages which go three deep. If the EMAs were different periods, then we could combine them in a way which does not require a manual expansion of the moving averages but that is not the case. This means substituting in the base items being averaged into something like:

(1/2)*(1-a)^3
*(1*2*C0+a
*(2*3*C1+a
*(3*4*C2+a
*...
*((k+1)*(k+2)*Ck+a
*...)))...

Where C0, C1, C2 and Ck are bars ago versions of MAXH450, MAXH250, MAXH90, MINL450, MINL250 and MINL90. And we need to take this expansion out to 100+ bars in order for the approximation to converge on an accurate value.

Cascades of Moving Averages

And the calculation for VARA needs to be included in every comparison used to create VARD for every term. The manual expansion of the 3-period exponential moving average can probably be done using 15-20 terms, but that still means 15-20 copies of bars ago versions of VARA to create VARD.

Then VARF requires getting the highest value for VARD over 60 bars. The technique I've devised for this has only even been expanded out to 32 bars because anything longer is too long and slow to be practical even when we aren't trying to find the high of something as complicated as VARD. Just take a look at the following topic to see how quickly the formulas increase in size.

Min Max PCFs

And then VARG itself ends up being a 3-period exponential moving average as well which needs to incorporate 15-20 bars ago copies of VARD and VARF.

We could do this using something with a full programming language like the RealCode in StockFinder or in TC2000 if the XAVG(), AVG(), MIN() and MAX() functions could accept complex formulas as arguments instead of being limited to only taking one of the indicators built into the PCF Language as arguments, but as things stand, it is not possible to create a PCF for VARG in TC2000.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Wednesday, February 12, 2014 6:03:30 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

Is it possible that I can export data streams of TC2000 to Multicharts?

 

Br,

Mike

mcwang2012
Posted : Wednesday, February 12, 2014 6:09:43 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

 

If I change VARA formula a little bit to 20-period, such as

VARA:=EMA((VAR7*3+VAR8*2+VAR9)/6*1.738,20)

 

then, can we have an executable indicator expression?

 

Br,

Mike

Bruce_L
Posted : Thursday, February 13, 2014 12:33:43 PM


Worden Trainer

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

TC2000 version 7 has three methods of exporting data (Smart Export to TeleChart Version 3, MetaStock and Export to Text). I do not know if any of these export methods would allow Multicharts to use the data.

Exporting data to text format - comma, space or tab delimited

But TC2000 version 12.4 does not have the ability to export data for more than one symbol at a time.

To get a reasonably short formula for VARA, the periods for VAR1-6 would need to use one period, VAR7-9 would need to use a second period and VARA would need to use a third period. If one assumes those periods should be as close to 21 as possible, then the periods used would need to be 20, 21 and 22. It doesn't matter which periods you use for each as the order in which the moving averages are applied does not matter.

1.738 * (6.68 * (361 * XAVG(MINL450, 20) - 800 * XAVG(MINL450, 21) + 441 * XAVG(MINL450, 22)) + 6.64 * (361 * XAVG(MINL250, 20) - 800 * XAVG(MINL250, 21) + 441 * XAVG(MINL250, 22)) + 6.58 * (361 * XAVG(MINL90, 20) - 800 * XAVG(MINL90, 21) + 441 * XAVG(MINL90, 22)) + 3.464 * (361 * XAVG(MAXH450, 20) - 800 * XAVG(MAXH450, 21) + 441 * XAVG(MAXH450, 22) + 361 * XAVG(MAXH250, 20) - 800 * XAVG(MAXH250, 21) + 441 * XAVG(MAXH250, 22) + 361 * XAVG(MAXH90, 20) - 800 * XAVG(MAXH90, 21) + 441 * XAVG(MAXH90, 22))) / 72

This might be short enough to get us to be able to calculate VARD, but the formula for VARD would still be thousands of characters on its own.

And even if we could shorten that considerably, it doesn't get us to the point of being able to calculate VARF (which is required for VARG).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Thursday, February 13, 2014 4:18:57 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

Tks for the guidance.

Pls instruct me the detailed procedure of exporting data from TC2000 version 12.4.

 

Br,

Mike

Bruce_L
Posted : Thursday, February 13, 2014 4:39:35 PM


Worden Trainer

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

There should be an Export Chart Data icon at the top of the chart in TC2000 version 12.4. It looks like two small stacks of silver coins. Clicking on the Export Chart Data icon will bring up a window with a list of indicators on that chart which can be checked and unchecked. Clicking on the Export button in that window will export all of the data for the checked indicators for the active symbol currently being used for those indicators on the chart.

As noted in my previous response, Tc2000 version 12.4 does not have the ability to export data for more than one symbol at a time.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Friday, February 14, 2014 8:50:49 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

 

I can not find the icon for exporting chart data. Do you mind sending me a figure showing the icon's position?

Also, any plan or schedule for TC2000.12 to be able to incorporate the arguments of complex functions?

Br,

Mike 

mcwang2012
Posted : Friday, February 14, 2014 9:01:20 AM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

I think I found the icon.

 

Br,

Mike

Bruce_L
Posted : Friday, February 14, 2014 10:12:31 AM


Worden Trainer

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

I am happy to read you were able to find the icon on your own.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Thursday, February 27, 2014 1:27:54 PM
Registered User
Joined: 2/17/2013
Posts: 67
Dear Bruce,
 
Is there a similar function in TC2000.14 as Barsnumber in EasyLanguage?
 
I like to use an indicator, with the formula as  
((Cr-MINLr.5)/(MAXCr.5-MINLr.5))*100
 
while Cr and Lr are defined as follows.
 
C2:=(C.BARSnumber) * (C.BARSnumber) / C;
CR:=C2/C;
LR:=C2/H;
 
Br,
Mike
Bruce_L
Posted : Friday, February 28, 2014 12:31:10 PM


Worden Trainer

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

I really couldn't say without knowing more about "BARSnumber". Almost all of the syntax in the Personal Criteria Formula Language has a bars ago parameter. So if "BARSnumber" is the number of bars ago of interest, then you could use that number in the syntax.

For example, if r = 10 and r is the number of bars ago, then my bust guess at:

((Cr-MINLr.5)/(MAXCr.5-MINLr.5))*100

Would be:

(C10 - MINL5.10) / (MAXC5.10 - MINL5.10) * 100

And my best guess at C2 would be:

(C10 ^ 2) / C

My best guess at CR would be:

(C10 ^ 2) / (C ^ 2)

And my best guess at LR would be:

(C10 ^ 2) / C / H

PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Friday, February 28, 2014 6:52:05 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

[the definition , BarNumber is an EL function that allows you to determine the number of the bar that is currently being calculated.Starting with the first calculation bar after MaxBarsBack, each bar is assigned a number starting at 1.]

Cs is the value of C of BARSnumber-1  bars ago.

Cr and Lr are variables , defined by

Cr=Cs^2/C

Lr=Cs^2/H

I like to calculate the formula as follows

((Cr-MINLr.5)/(MAXCr.5-MINLr.5))*100

 

Br,

Mike

wwrightjuly4
Posted : Friday, February 28, 2014 8:41:28 PM
Gold Customer Gold Customer

Joined: 4/10/2006
Posts: 954

He is a Platinum member, could this be achieved in Stockfinder

mcwang2012
Posted : Monday, March 3, 2014 12:09:44 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

It seems the following formula is not accepted by TC. How should I modify it?

( (C'01/03/2013' * C'01/03/2013' / C-MIN( C'01/03/2013' * C'01/03/2013' / H , 5) )/( MAX( C'01/03/2013' * C'01/03/2013' / C , 5 )-MIN( C'01/03/2013' * C'01/03/2013' / H , 5) ) )*100

 

Br,

Mike

Bruce_L
Posted : Tuesday, March 4, 2014 9:27:41 AM


Worden Trainer

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

wwrightjuly4,
New TC2000 Platinum subscriptions no longer provide access to StockFinder Gold.

mcwang2012,
The MIN() and MAX() functions do not accept compound formulas or other functions as arguments. There is no good way to modify the formula.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mcwang2012
Posted : Saturday, March 15, 2014 11:49:59 PM
Registered User
Joined: 2/17/2013
Posts: 67

Dear Bruce,

 

If I can use 330, instead of 450, in the following formula. Is that possible that we can write the formula for VARG?

Br,

----------------------------------------------

QUOTE (Bruce_L)

VARC isn't a particularly big problem.

100 * (ABS(L - L1) + ABS(L1 - L2) + ABS(L2 - L3)) / (ABS(L > L1) * (L - L1) + ABS(L1 > L2) * (L1 - L2) + ABS(L2 > L3) * (L2 - L3))

And you have come very close to what I had for an unexpanded VARA. Once we have VARA, we don't need anything above it. You appear to be missing the outer XAVG(,21) structure and I'm not quite sure if your factors or mine are correct (they don't match).

XAVG(XAVG((6.68*XAVG(MINL450,21)+6.64*XAVG(MINL250,21)+6.58*XAVG(MINL90,21)+3.464*(XAVG(MAXH450,21)+XAVG(MAXH250,21)+XAVG(MAXH90,21)))/36*1.738,21),21)

The problem is the nested 21-period exponential moving averages which go three deep. If the EMAs were different periods, then we could combine them in a way which does not require a manual expansion of the moving averages but that is not the case. This means substituting in the base items being averaged into something like:

(1/2)*(1-a)^3
*(1*2*C0+a
*(2*3*C1+a
*(3*4*C2+a
*...
*((k+1)*(k+2)*Ck+a
*...)))...

Where C0, C1, C2 and Ck are bars ago versions of MAXH450, MAXH250, MAXH90, MINL450, MINL250 and MINL90. And we need to take this expansion out to 100+ bars in order for the approximation to converge on an accurate value.

Cascades of Moving Averages

And the calculation for VARA needs to be included in every comparison used to create VARD for every term. The manual expansion of the 3-period exponential moving average can probably be done using 15-20 terms, but that still means 15-20 copies of bars ago versions of VARA to create VARD.

Then VARF requires getting the highest value for VARD over 60 bars. The technique I've devised for this has only even been expanded out to 32 bars because anything longer is too long and slow to be practical even when we aren't trying to find the high of something as complicated as VARD. Just take a look at the following topic to see how quickly the formulas increase in size.

Min Max PCFs

And then VARG itself ends up being a 3-period exponential moving average as well which needs to incorporate 15-20 bars ago copies of VARD and VARF.

We could do this using something with a full programming language like the RealCode in StockFinder or in TC2000 if the XAVG(), AVG(), MIN() and MAX() functions could accept complex formulas as arguments instead of being limited to only taking one of the indicators built into the PCF Language as arguments, but as things stand, it is not possible to create a PCF for VARG in TC2000.

Bruce_L
Posted : Monday, March 17, 2014 2:32:58 PM


Worden Trainer

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

There is no significant difference in the formula when switching from 450 to 330 in the formulas. In fact, the formulas would theoretically be exactly the same length (although if the resulting formulas were possible, the 330 version would probably calculate more quickly than the 450 version).



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