Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 10/7/2004 Posts: 67
|
july 2016 - Super Passband Filter Stocks and commodities mag.
can you write this indicator as an PCF please for TC2000
//Super Passband Filter
// (c) 2016 John F. Ehlers
// TASC JUL 2016
inputs:
Period1( 40 ),
Period2( 60 ) ;
variables:
a1( 0 ),
a2( 0 ),
PB( 0 ),
count( 0 ),
RMS( 0 ) ;
a1 = 5 / Period1 ;
a2 = 5 / Period2 ;
PB = (a1 - a2) * Close + (a2*(1 - a1) - a1 * (1 - a2))
* Close[1] + ((1 - a1) + (1 - a2))*PB[1] - (1 - a1)
* (1 - a2)*PB[2] ;
RMS = 0;
for count = 0 to 49
begin
RMS = RMS + PB[count]*PB[count] ;
end ;
RMS = SquareRoot( RMS / 50 ) ;
Plot1( PB, "Super PB" ) ;
Plot2( 0, "Zero Line" ) ;
Plot3( RMS, "+RMB" ) ;
Plot7(-RMS, "-RMS" ) ;
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
hotrod,
I don't think those calculations are possible using the PCF language.
|
|
Registered User Joined: 11/26/2007 Posts: 116
|
Would you please write this as a real code indicator for SF5?
Thanks Jim
-----------------------------------------------------------------------------------------------------
QUOTE (hotrod)
july 2016 - Super Passband Filter Stocks and commodities mag.
can you write this indicator as an PCF please for TC2000
//Super Passband Filter
// 2016 John F. Ehlers
// TASC JUL 2016
inputs:
Period1( 40 ),
Period2( 60 ) ;
variables:
a1( 0 ),
a2( 0 ),
PB( 0 ),
count( 0 ),
RMS( 0 ) ;
a1 = 5 / Period1 ;
a2 = 5 / Period2 ;
PB = (a1 - a2) * Close + (a2*(1 - a1) - a1 * (1 - a2))
* Close[1] + ((1 - a1) + (1 - a2))*PB[1] - (1 - a1)
* (1 - a2)*PB[2] ;
RMS = 0;
for count = 0 to 49
begin
RMS = RMS + PB[count]*PB[count] ;
end ;
RMS = SquareRoot( RMS / 50 ) ;
Plot1( PB, "Super PB" ) ;
Plot2( 0, "Zero Line" ) ;
Plot3( RMS, "+RMB" ) ;
Plot7(-RMS, "-RMS" ) ;
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
For the main indicator.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Super Passband Filter
'|******************************************************************
'# Cumulative
'# Period1 = UserInput.Integer = 40
'# Period2 = UserInput.Integer = 60
Static a1 As Single
Static a2 As Single
Static PB As New List(Of Single)
If isFirstBar Then
a1 = 5 / Period1
a2 = 5 / Period2
PB.Clear
PB.Insert(0, 0)
PB.Insert(0, (a1 - a1) * Price.Last)
Else
PB.Insert(0, (a1 - a2) * Price.Last + (a2 * (1 - a1) - a1 * (1 - a2)) _
* Price.Last(1) + ((1 - a1) + (1 - a2)) * PB(0) - (1 - a1) _
* (1 - a2) * PB(1))
Plot = PB(0)
End If
If isLastBar Then
PB.Clear
End If
For the +RMB line.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:RMS+
'|******************************************************************
'# SPF = chart.SuperPassbandFilter
'# Period = UserInput.integer = 50
Static RMS As Single
If isFirstBar Then
RMS = 0
End If
RMS += SPF.Value ^ 2
If CurrentIndex >= Period - 1 Then
Plot = (RMS / Period) ^ .5
RMS -= SPF.Value(Period - 1) ^ 2
Else
Plot = Single.NaN
End If
For the -RMB line.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:RMS-
'|******************************************************************
'# SPF = chart.SuperPassbandFilter
'# Period = UserInput.integer = 50
Static RMS As Single
If isFirstBar Then
RMS = 0
End If
RMS += SPF.Value ^ 2
If CurrentIndex >= Period - 1 Then
Plot = -(RMS / Period) ^ .5
RMS -= SPF.Value(Period - 1) ^ 2
Else
Plot = Single.NaN
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 11/26/2007 Posts: 116
|
Bruce,
Thanks for the SF real code for the passband filter indeicator. I created it and it looks like the chart in Ehlers article. I then created the +RMS and -RMS indicators and on each one got complie error on:
Name SPF not declared
Not being a programmer I don't know how to fix this.
Jim
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The SPF indicator should just work if you you create the Super Passband Filter indicator exactly as is without renaming it (you just copied the code from the forums and pasted it directly into the main StockFinder window).
That said, the key is the following line in the RMS+ and RMS- indicators.
'# SPF = chart.SuperPassbandFilter
This is the line which declares the SPF variable. It was originally created by dragging and dropping the Super Passband Filter indicator into the Code tab of the RealCode Editor of the RMS+ and RMS- indicators.
You should be able to delete the line and re-drag and drop your Super Passband Filter indicator into the Code tab to fix the error message you are describing if you also either replace the SPF variable with whatever variable is assigned throughout the rest of the code, or change the whatever variable is automatically assigned to SPF so it matches the rest of the code.
RealCode for Real People: Indicators (6:05)
Writing Conditions in RealCode (10:11)
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
Bruce Can you do just the pass-band part?
The only reason I ask is a spreadsheet in the TradersTips
section says its two EMAs with a different alpha weighting.
You can usually do EMAs.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I probably can do it, but it is going to take a bit longer than usual.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
This is actually simple.
I looked at the article again.
It said Ehler's alpha was: 5/N.
If you work that backward into: 2/(N+1).
The PCF is: XAVGC15-XAVGC23.
Im guessing the PCF being so small RMS is also possible.
I originally thought not because of a large PCF.
I just dont recall what the RMS calc is at the moment.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I'm very impressed with your work. I'm more than a tad bit annoyed at Ehlers overcomplicated way of writing a MACD however.
Anyway, it is pretty straightforward to write RMS:
SQR(((XAVGC15 - XAVGC23) ^ 2 + (XAVGC15.1 - XAVGC23.1) ^ 2 + (XAVGC15.2 - XAVGC23.2) ^ 2 + (XAVGC15.3 - XAVGC23.3) ^ 2 + (XAVGC15.4 - XAVGC23.4) ^ 2 + (XAVGC15.5 - XAVGC23.5) ^ 2 + (XAVGC15.6 - XAVGC23.6) ^ 2 + (XAVGC15.7 - XAVGC23.7) ^ 2 + (XAVGC15.8 - XAVGC23.8) ^ 2 + (XAVGC15.9 - XAVGC23.9) ^ 2 + (XAVGC15.10 - XAVGC23.10) ^ 2 + (XAVGC15.11 - XAVGC23.11) ^ 2 + (XAVGC15.12 - XAVGC23.12) ^ 2 + (XAVGC15.13 - XAVGC23.13) ^ 2 + (XAVGC15.14 - XAVGC23.14) ^ 2 + (XAVGC15.15 - XAVGC23.15) ^ 2 + (XAVGC15.16 - XAVGC23.16) ^ 2 + (XAVGC15.17 - XAVGC23.17) ^ 2 + (XAVGC15.18 - XAVGC23.18) ^ 2 + (XAVGC15.19 - XAVGC23.19) ^ 2 + (XAVGC15.20 - XAVGC23.20) ^ 2 + (XAVGC15.21 - XAVGC23.21) ^ 2 + (XAVGC15.22 - XAVGC23.22) ^ 2 + (XAVGC15.23 - XAVGC23.23) ^ 2 + (XAVGC15.24 - XAVGC23.24) ^ 2 + (XAVGC15.25 - XAVGC23.25) ^ 2 + (XAVGC15.26 - XAVGC23.26) ^ 2 + (XAVGC15.27 - XAVGC23.27) ^ 2 + (XAVGC15.28 - XAVGC23.28) ^ 2 + (XAVGC15.29 - XAVGC23.29) ^ 2 + (XAVGC15.30 - XAVGC23.30) ^ 2 + (XAVGC15.31 - XAVGC23.31) ^ 2 + (XAVGC15.32 - XAVGC23.32) ^ 2 + (XAVGC15.33 - XAVGC23.33) ^ 2 + (XAVGC15.34 - XAVGC23.34) ^ 2 + (XAVGC15.35 - XAVGC23.35) ^ 2 + (XAVGC15.36 - XAVGC23.36) ^ 2 + (XAVGC15.37 - XAVGC23.37) ^ 2 + (XAVGC15.38 - XAVGC23.38) ^ 2 + (XAVGC15.39 - XAVGC23.39) ^ 2 + (XAVGC15.40 - XAVGC23.40) ^ 2 + (XAVGC15.41 - XAVGC23.41) ^ 2 + (XAVGC15.42 - XAVGC23.42) ^ 2 + (XAVGC15.43 - XAVGC23.43) ^ 2 + (XAVGC15.44 - XAVGC23.44) ^ 2 + (XAVGC15.45 - XAVGC23.45) ^ 2 + (XAVGC15.46 - XAVGC23.46) ^ 2 + (XAVGC15.47 - XAVGC23.47) ^ 2 + (XAVGC15.48 - XAVGC23.48) ^ 2 + (XAVGC15.49 - XAVGC23.49) ^ 2) / 50)
And -RMS:
-SQR(((XAVGC15 - XAVGC23) ^ 2 + (XAVGC15.1 - XAVGC23.1) ^ 2 + (XAVGC15.2 - XAVGC23.2) ^ 2 + (XAVGC15.3 - XAVGC23.3) ^ 2 + (XAVGC15.4 - XAVGC23.4) ^ 2 + (XAVGC15.5 - XAVGC23.5) ^ 2 + (XAVGC15.6 - XAVGC23.6) ^ 2 + (XAVGC15.7 - XAVGC23.7) ^ 2 + (XAVGC15.8 - XAVGC23.8) ^ 2 + (XAVGC15.9 - XAVGC23.9) ^ 2 + (XAVGC15.10 - XAVGC23.10) ^ 2 + (XAVGC15.11 - XAVGC23.11) ^ 2 + (XAVGC15.12 - XAVGC23.12) ^ 2 + (XAVGC15.13 - XAVGC23.13) ^ 2 + (XAVGC15.14 - XAVGC23.14) ^ 2 + (XAVGC15.15 - XAVGC23.15) ^ 2 + (XAVGC15.16 - XAVGC23.16) ^ 2 + (XAVGC15.17 - XAVGC23.17) ^ 2 + (XAVGC15.18 - XAVGC23.18) ^ 2 + (XAVGC15.19 - XAVGC23.19) ^ 2 + (XAVGC15.20 - XAVGC23.20) ^ 2 + (XAVGC15.21 - XAVGC23.21) ^ 2 + (XAVGC15.22 - XAVGC23.22) ^ 2 + (XAVGC15.23 - XAVGC23.23) ^ 2 + (XAVGC15.24 - XAVGC23.24) ^ 2 + (XAVGC15.25 - XAVGC23.25) ^ 2 + (XAVGC15.26 - XAVGC23.26) ^ 2 + (XAVGC15.27 - XAVGC23.27) ^ 2 + (XAVGC15.28 - XAVGC23.28) ^ 2 + (XAVGC15.29 - XAVGC23.29) ^ 2 + (XAVGC15.30 - XAVGC23.30) ^ 2 + (XAVGC15.31 - XAVGC23.31) ^ 2 + (XAVGC15.32 - XAVGC23.32) ^ 2 + (XAVGC15.33 - XAVGC23.33) ^ 2 + (XAVGC15.34 - XAVGC23.34) ^ 2 + (XAVGC15.35 - XAVGC23.35) ^ 2 + (XAVGC15.36 - XAVGC23.36) ^ 2 + (XAVGC15.37 - XAVGC23.37) ^ 2 + (XAVGC15.38 - XAVGC23.38) ^ 2 + (XAVGC15.39 - XAVGC23.39) ^ 2 + (XAVGC15.40 - XAVGC23.40) ^ 2 + (XAVGC15.41 - XAVGC23.41) ^ 2 + (XAVGC15.42 - XAVGC23.42) ^ 2 + (XAVGC15.43 - XAVGC23.43) ^ 2 + (XAVGC15.44 - XAVGC23.44) ^ 2 + (XAVGC15.45 - XAVGC23.45) ^ 2 + (XAVGC15.46 - XAVGC23.46) ^ 2 + (XAVGC15.47 - XAVGC23.47) ^ 2 + (XAVGC15.48 - XAVGC23.48) ^ 2 + (XAVGC15.49 - XAVGC23.49) ^ 2) / 50)
Even though the resulting formulas ending up being rather long.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/28/2005 Posts: 6,049
|
Is there a "skip" in the bars back?
It goes to 48 and the second EMA set has no number.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
A "skip" is probably an apt description of the issue (actually the most recent value got included twice). Please try the corrected formulas.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |