Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Gold Customer
Joined: 1/28/2005 Posts: 38
|
Bruce,
A while back you created a version of ADX for me which uses 13 DI lines and an 8 for ADX (code below). It works great on the chart. However, when I try to put it on the watchlist as a sort item, the numbers are incorrect. Can you tell me what is wrong?
Thanks,
Joe
'# Period = UserInput.Integer = 8
Static DX As Single
Static DMp As Single
Static DMn As Single
Static DMIp As Single
Static DMIn As Single
Static ADX As Single
Static termratio As Single
Static weight As Single
Static sumweight As Single
If isFirstBar Then
DMIp = 0
DMIn = 0
ADX = 0
termratio = (Period - 1) / Period
weight = 1
sumweight = 1
Else
If Price.High > Price.High(1) And _
Price.High - Price.High(1) > Price.Low(1) - Price.Low Then
DMp = Price.High - Price.High(1)
Else
DMp = 0
End If
If Price.Low(1) > Price.Low And _
Price.Low(1) - Price.Low > Price.High - Price.High(1) Then
DMn = Price.Low(1) - Price.Low
Else
DMn = 0
End If
DMIp = DMIp * (1 - weight) + weight * DMp
DMIn = DMIn * (1 - weight) + weight * DMn
DX = 100 * System.Math.Abs(DMIp-DMIn)/(DMIp+DMIn+.00000001)
ADX = ADX * (1 - weight) + weight * DX
sumweight = sumweight * termratio + 1
weight = 1 / sumweight
End If
Plot = ADX
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Please try adding the following line:
#Cumulative
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Gold Customer
Joined: 1/28/2005 Posts: 38
|
When I add this line to the end, it gives me a error message.
|
|
Registered User Joined: 10/27/2004 Posts: 821 Location: Philly area
|
Try up top. Here is a snip from another piece of code
'#Cumulative
'# Stoc = indicator.Stochastics.3
You can ignore the STOC line, it's just there for perspective.
Also note the apostrophe, which I think is needed.
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
The line is
'#Cumulative
and cause items moved to the watchlist to use all data. Without it on;y a subset of data is used. For cummulative indicators the value win't match the chart without declaring
'#Cumulative
exact match of the string is required. A space after the # will cause it not to be interpreted.
Placing it at the top with the other '# lines is better form but not required.
|
|
Guest-1 |