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 |

no longer linked Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jrf-wood
Posted : Wednesday, August 4, 2010 10:49:56 PM
Registered User
Joined: 7/19/2010
Posts: 23
using my own class!
when i save my code i get the following msg.
"this item references other items on this chart. they will no longer be linked to those items."

1) is "this item" a piece of code (function) i can alter or remove; or is it all my code?
2) how can i link it?
3) is this msg. about being synchronized?
4) i am not using any child functions!
5) i am using the "addtooutput" in a for loop for x =  0 to price.count - 1!
Kuf
Posted : Thursday, August 5, 2010 10:13:21 AM


Administration

Joined: 9/18/2004
Posts: 3,522
Did you drag and drop an indicator into your code? Can you share your code with us?

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
jrf-wood
Posted : Thursday, August 5, 2010 1:07:45 PM
Registered User
Joined: 7/19/2010
Posts: 23

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Indicator:linregslope
'*** will fit slope of given (nper) slope x's to price chart
'|******************************************************************

'** no. of x points in slope calc.
'# nper = userinput.integer = 5
  
'*** data for: market array bars and size
Dim nobars As Integer = price.Bar.count
Dim lastbar As Integer = nobars - 1
Dim y_datevalue(nobars) As Date
Dim y_value(nobars) As Single
'*** data for: table index
Dim x1  As Integer
Dim xmain As Integer  
Dim x3  As Integer
Dim x4  As Integer
Dim bb As Integer
Dim ee As Integer = lastbar
'*** data For: linear regression slope calc.  
Dim testcount As Integer = 0
Dim sumx As Single
Dim sumy As Single
Dim sumxy As Single 
Dim sumxsq As Single
Dim sumysq As Single
Dim sumsqx As Single
Dim sumsqy As Single
Dim mx As Single
Dim my As Single
Dim m As Single
Dim b As Single
'*** data for: correlation coefficient; goodness of fit  
Dim rx As Single
Dim ry1 As Single
Dim ry2 As Single
Dim ry As Single
Dim sqrotrt As Single
Dim r As Single
Dim yinter As Single 
Dim xoff As Integer  

'*** save bar data for my close-price plot  
For x1 = 0 To lastbar
 y_datevalue(x1) = price.Bar.datevalue(x1)
 y_value(x1) = price.Bar.value(x1)
Next x1
'*** temp plot for debug
For x1 = 0 To lastbar
 MyBase.addtoOutput(y_datevalue(x1), y_value(x1))
Next x1
 
'*** main process control loop; step thru bars current period to last
'******************************************************************************************
For xmain = lastbar To 0  Step -1
 bb = ee - nper + 1

 '*** temp: debug
 If testcount < 20
  Me.Log.debug("////////  xmain = " & xmain & "  bb = " & bb & "  ee = " & ee)
  Me.Log.debug("lastbar = " & lastbar)
  testcount = testcount + 1
 End If

 '*** skip bars; if bars left is less then slope x's or present x's make good slope
 If xmain > ee Or bb < nper - 1
  Continue For
 Else 

  '*** calculate the slope of x-axis points(nper)  
  sumx = 0
  sumy = 0
  sumxy = 0
  sumxsq = 0
  sumysq = 0
  For x3 = bb To ee
   sumx = nper
   sumy = sumy + y_value(x3)
   sumxy = sumxy + (sumx * sumy)
   sumxsq = nper * nper
   sumysq = sumysq + (y_value(x3) * y_value(x3))
  Next x3   

  '** m is the slope
  '** b is intercept point on "y" axis
  mx = (nper * sumxy) - (sumx * sumy)
  my = (nper * sumxsq) - (sumx * sumx)
  m = mx / my
  b = (sumy - (m * sumx)) / nper

  '*** temp. debug
  If testcount < 20
   Me.Log.debug("------  bb = " & bb & "  ee = " & ee)
   Me.Log.debug("mx = " & mx & "  my = " & my)
   Me.Log.debug("sumx = " & sumx & "  sumy = " & sumy)
   Me.Log.debug("sumxy = " & sumxy & "  sumxsq = " & sumxsq)
   Me.log.debug("sumysq = " & sumysq)  
   Me.Log.debug("m = " & m & "  b = " & b)
   testcount = testcount + 1
  End If

  '*** calc. correlation coefficient
  'rx = (nper * sumxy) - (sumx * sumy)
  'ry1 = (nper * sumxsq) - (sumx * sumy)
  'ry2 = (nper * sumysq) - (sumy * sumy)
  'ry = ry1 * ry2
  'sqrotrt = System.Math.Sqrt(ry)
  'r = rx / sqrotrt
  
  'If r > 0.80
  '  xoff = 1
  ' For x3 = bb To ee
  '  yinter = b + (m * xoff)
  '  Me.Log.debug("---yinter = " & yinter)
  '  y_value(x3) = yinter
  '  xoff = xoff + 1
  ' Next x3
  '   ee = ee - nper + 1
  'End If
  '*** step back one bar to test for next slope; assume no good slope found
  ee = ee - 1
 End If
  
Next xmain
'*** end of main process loop ****************************************************

'*** store process array bars to plot array bars
'For x4 = 0 To lastbar
' MyBase.addtoOutput(z_datevalue(x4), z_value(x4))
'Next x4

jrf-wood
Posted : Thursday, August 5, 2010 2:54:24 PM
Registered User
Joined: 7/19/2010
Posts: 23

using my own class!
when i save my code i get the following msg.
"this item references other items on this chart. they will no longer be linked to those items."

1) is "this item" a piece of code (function) i can alter or remove; or is it all my code?
2) how can i link it?
3) is this msg. about being synchronized?
4) i am not using any child functions!
5) i am using the "addtooutput" in a for loop for x =  0 to price.count - 1!

Please see code below:

<WBIGuid("47a07cba-0b74-453d-bf11-84c94c822180"),FriendlyName("RealCodeIndicator"),BlockTemplateEmptyMethodOnly()> _
Public partial Class RealCodeIndicator
inherits RealCodeIndicator_base
 Sub New
  MyBase.New
  MyBase.AutoLoop = False
 End Sub
 Public Overrides Function Plot() As System.Single
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Indicator:linregslope
'|*** use linear regression in my own process
'|*** will fit slope of given (nper) slope x's to price chart
'|******************************************************************

'** no. of x points in slope calc.
'# nper = userinput.integer = 5
  
'*** data for: market array bars and size
Dim nobars As Integer = price.Bar.count
Dim lastbar As Integer = nobars - 1
Dim y_datevalue(nobars) As Date
Dim y_value(nobars) As Single
'*** data for: table index
Dim x1  As Integer
Dim xmain As Integer  
Dim x3  As Integer
Dim x4  As Integer
Dim bb As Integer
Dim ee As Integer = lastbar
'*** data For: linear regression slope calc.  
Dim testcount As Integer = 0
Dim sumx As Single
Dim sumy As Single
Dim sumxy As Single 
Dim sumxsq As Single
Dim sumysq As Single
Dim sumsqx As Single
Dim sumsqy As Single
Dim mx As Single
Dim my As Single
Dim m As Single
Dim b As Single
'*** data for: correlation coefficient; goodness of fit  
Dim rx As Single
Dim ry1 As Single
Dim ry2 As Single
Dim ry As Single
Dim sqrotrt As Single
Dim r As Single
Dim yinter As Single 
Dim xoff As Integer  

'*** save bar data for my close-price plot  
For x1 = 0 To lastbar
 y_datevalue(x1) = price.Bar.datevalue(x1)
 y_value(x1) = price.Bar.value(x1)
Next x1
'*** temp plot for debug
For x1 = 0 To lastbar
 MyBase.addtoOutput(y_datevalue(x1), y_value(x1))
Next x1
 
'*** main process control loop; step thru bars current period to last
'******************************************************************************************
For xmain = lastbar To 0  Step -1
 bb = ee - nper + 1

 '*** temp: debug
 If testcount < 20
  Me.Log.debug("////////  xmain = " & xmain & "  bb = " & bb & "  ee = " & ee)
  Me.Log.debug("lastbar = " & lastbar)
  testcount = testcount + 1
 End If

 '*** skip bars; if bars left is less then slope x's or present x's make good slope
 If xmain > ee Or bb < nper - 1
  Continue For
 Else 

  '*** calculate the slope of x-axis points(nper)  
  sumx = 0
  sumy = 0
  sumxy = 0
  sumxsq = 0
  sumysq = 0
  For x3 = bb To ee
   sumx = nper
   sumy = sumy + y_value(x3)
   sumxy = sumxy + (sumx * sumy)
   sumxsq = nper * nper
   sumysq = sumysq + (y_value(x3) * y_value(x3))
  Next x3   

  '** m is the slope
  '** b is intercept point on "y" axis
  mx = (nper * sumxy) - (sumx * sumy)
  my = (nper * sumxsq) - (sumx * sumx)
  m = mx / my
  b = (sumy - (m * sumx)) / nper

  '*** temp. debug
  If testcount < 20
   Me.Log.debug("------  bb = " & bb & "  ee = " & ee)
   Me.Log.debug("mx = " & mx & "  my = " & my)
   Me.Log.debug("sumx = " & sumx & "  sumy = " & sumy)
   Me.Log.debug("sumxy = " & sumxy & "  sumxsq = " & sumxsq)
   Me.log.debug("sumysq = " & sumysq)  
   Me.Log.debug("m = " & m & "  b = " & b)
   testcount = testcount + 1
  End If

  '*** calc. correlation coefficient
  'rx = (nper * sumxy) - (sumx * sumy)
  'ry1 = (nper * sumxsq) - (sumx * sumy)
  'ry2 = (nper * sumysq) - (sumy * sumy)
  'ry = ry1 * ry2
  'sqrotrt = System.Math.Sqrt(ry)
  'r = rx / sqrotrt
  
  'If r > 0.80
  '  xoff = 1
  ' For x3 = bb To ee
  '  yinter = b + (m * xoff)
  '  Me.Log.debug("---yinter = " & yinter)
  '  y_value(x3) = yinter
  '  xoff = xoff + 1
  ' Next x3
  '   ee = ee - nper + 1
  'End If
  '*** step back one bar to test for next slope; assume no good slope found
  ee = ee - 1
 End If
  
Next xmain
'*** end of main process loop ****************************************************

'*** store process array bars to plot array bars
'For x4 = 0 To lastbar
' MyBase.addtoOutput(z_datevalue(x4), z_value(x4))
'Next x4

 

end function
End Class

Kuf
Posted : Friday, August 6, 2010 9:44:14 AM


Administration

Joined: 9/18/2004
Posts: 3,522
Using the save button in the editor displays the error message incorrectly. If you right click and save on the indicator from the chart the message will not show. We'll get it corrected for the next build.

Ken Gilb (Kuf)
Chief Software Engineer - Worden Brothers Inc.
Try/Catch - My RealCode Blog
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.