Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Custom Indicator as sort item (for Bruce) Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
delphi
Posted : Wednesday, July 23, 2008 12:09:16 PM
Gold Customer 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
Bruce_L
Posted : Wednesday, July 23, 2008 12:36:39 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Please try adding the following line:

#Cumulative

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
delphi
Posted : Wednesday, July 23, 2008 1:25:17 PM
Gold Customer Gold Customer

Joined: 1/28/2005
Posts: 38
When I add this line to the end, it gives me a error message.
jschott
Posted : Thursday, July 24, 2008 11:17:14 AM
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.
jas0501
Posted : Thursday, July 24, 2008 2:15:20 PM
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.


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.