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 |

Profile: jrf-wood
About
User Name: jrf-wood
Groups: Gold User, Member, TeleChart
Rank: Registered User
Real Name:
Location
Occupation:
Interests:
Gender: Unsure
Statistics
Joined: Monday, July 19, 2010
Last Visit: Saturday, August 28, 2010 2:18:55 PM
Number of Posts: 23
[0.01% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: main price chart
Posted: Saturday, August 28, 2010 2:18:54 PM
How do I regenerate the main price history chart if i delete it? Is it in the lib. og indicaters?
Topic: macd; my RealCode must be wrong, indicater looks wrong.
Posted: Thursday, August 26, 2010 10:34:35 PM

my macd RealCode does not plot like yours. I must be doing somthing wrong?
My code is from; "a quick tutorial in macd, by g. and m. apple" found on
"www.signalert.com%20TUTORIAL.PDF"

Please find my RealCode below. It is normalzed w/ n26. It does not look like your macd;
"macd simple,12,simple,26 (simple,moving 9). I have tried w/ and w/ out smoothing constants etc.
can not get it to look like yours!  There is smothing wrong w/ my understanding of RealCode.


'|*** Indicator:pmacdsl  ((no signal line plot))
Static n26 As Integer = 26
Static n12 As Integer = 12
Static n9 As Integer = 9
Static s1 As Single = 2 / (n12 + 1)
Static s2 As Single = 2 / (n26 + 1)
Static s3 As Single = 2 / (n9 + 1)
Dim avg26 As Single
Dim avg12 As Single
Dim avg9 As Single
Dim pa1 As Single
Dim pa2 As Single
Dim pa3 As Single
Dim dl As Single

If currentindex < n26 Then
 Me.setindexinvalid
else
 avg12 = price.AVG(n12, 1)
 avg26 = price.AVG(n26, 1)
 'avg9 = price.AVG(n9, 1)
 pa1 = avg12 + s1 * (price.Close - avg12)
 pa2 = avg26 + s2 * (price.Close - avg26)
 'pa3 = avg9 + s3 * (price.Close - avg9)

 dl = (pa1 - pa2)
 plot = DL / PA2
End If

'|*** Indicator:pmacdsl     ((signal only))
'|******************************************************************
Static n26 As Integer = 26
Static n12 As Integer = 12
Static n9 As Integer = 9
Static s1 As Single = 2 / (n12 + 1)
Static s2 As Single = 2 / (n26 + 1)
Static s3 As Single = 2 / (n9 + 1)
Dim avg26 As Single
Dim avg12 As Single
Dim avg9 As Single
Dim pa1 As Single
Dim pa2 As Single
Dim pa3 As Single
Dim dl As Single

If currentindex < n26 Then
 Me.setindexinvalid
else
 'avg12 = price.AVG(n12, 1)
 avg26 = price.AVG(n26, 1)
 avg9 = price.AVG(n9, 1)
 'pa1 = avg12 + s1 * (price.Close - avg12)
 pa2 = avg26 + s2 * (price.Close - avg26)
 pa3 = avg9 + s3 * (price.Close - avg9)

 'dl = (pa1 - pa2) / PA2
 plot = (PA3 / PA2)
End If

 

 

 

 

 

 

 

 

Topic: correct use of fund dta
Posted: Wednesday, August 25, 2010 6:43:41 PM
new fund. data is just as good as old for backtesting!
in back testing you must have a date you call "today".
price data to the right is for validation.
current fund. data is ok for back testing because it has the same relationship from on stock
to the other.
Topic: correct use of fund dta
Posted: Tuesday, August 24, 2010 2:49:31 PM

Using Fundamental Data

I am thinking about upgrading to SFP from SFG to get fundamental data. Before spending more money I have some questions about how fund data is used in RealCode:

1) Fund. data by itself would never be of value because it is only numbers.

2) Historical fund Data is of no value because all charting uses current data for actual placing buy/sell orders w/ a broker.

3) To days date is moved back in time so we can see the chart data to the right of "today";

this well tell us how good our indicators are in predicting the future, we may get rich.

4) Current fund data can be used for history bars because all the data is relative!

5) The requirement is to compare fund data of one symbol to all the rest.

6) To do that comparison one must apply a score to a set of fund data values for each symbol.

7) The score is then normalized across all tickers in a given population to give each a relative value to the other.

8) The fund data items considered for each scoring constitutes a strategy.

9) For each ticker and strategy a score value would be used in the RealCode along with other indicators.

10) Something like the above is the only way I can visualize a meaningful use of fund data

11) I would vary much like a response to my thanking . Thank you in advance.

Topic: labels on plot
Posted: Monday, August 23, 2010 7:20:07 PM


Question#1.
At bottom of program below i have:
 (me.chartooverlaytext = "percent fit w/ r >= 80%:" & percent / 100). This label is now part of the
"price history" chart. The label remains when i delete my indicater?

question #2.
How to i re-gen the "price history" if i delete it?

'|*********************************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Indicator:linregslope
'|*** use linear regression to gen. variable lgth slopes in my own process
'|********************************************************************************
'|--- This indicator well Select the best fitting slopes.
'|--- It well test sloops from 30 days to 3 days by -1.
'|--- scaling: exponential     plotstyle: line or bar     paint: green & red
'=================================================================================
 
'*** data for: market array bars and size
Dim lowtstslp As Integer = 5   '*** min slope test 
Dim maxnper As Integer = 30    '*** max slope test   
Dim cof_r(maxnper+1) As Single
Dim cof_b(maxnper+1) As Single
Dim cof_m(maxnper+1) As Single
Dim cof_nper(maxnper+1) As Integer
Dim cof_bb(maxnper+1) As Integer
Dim cof_ee(maxnper+1) As Integer

'*** stats data for good fits
Dim stat_nper(price.Bar.count+1) As Integer
Dim stat_bb(price.Bar.count+1) As Integer
Dim stat_ee(price.Bar.count+1) As Integer
Dim stat_r(price.Bar.count+1) As Single
Dim stat_m(price.Bar.count+1) As Single
Dim stat_b(price.Bar.count+1) As Single

'*** bars
Dim y_datevalue(price.Bar.count+1) As Date
Dim y_value(price.Bar.count+1) As Single
'*** data for: table index
Dim x1 As Integer
Dim x2 As Integer  
Dim x3 As Integer
Dim x4 As Integer
Dim x5 As Integer
Dim x6 As Integer
Dim x7 As Integer
Dim bb As Integer
Dim ee As Integer
'*** data For: linear regression slope calc.  
Dim mex As Single
Dim mey As Single
Dim newy As Single
Dim xx As Single
Dim yy As Single
Dim xy As Single
Dim sumx As Single
Dim sumy As Single
Dim sumxy As Single 
Dim sumsqx As Single
Dim sumsqy As Single
Dim m As Single
Dim b As Single
Dim rx As Single
Dim ry As Single
Dim r As Single
Dim ag1 As Single
Dim ag2 As Single
Dim ag3 As Single
Dim ag4 As Single
Dim ag5 As Single
Dim ag6 As Single
Dim pergodfit As Single

'*** debug
Dim tstcnt  As Integer = 0

Dim nper As Integer 

'*** save bar data for my close-price plot  
For x1 = 0 To (price.Bar.count - 1)
 y_datevalue(x1) = price.Bar.datevalue(x1)
 y_value(x1) = price.Bar.value(x1)
Next x1

'--- skip bars 0 to "nper" to allow slope insert (if any).
'****************************************************************
x7 = 0   '*** store stats
x6 = 1   '*** store slope data in best fit table
nper = maxnper
ee = (price.Bar.count - 1)    '*** apply slope to each bar

Do    '--- bars loop; step thru bars current period to last.

 bb = ee - (nper - 1)     '*** "bb" = first point of slope

 sumx = 0
 sumy = 0
 sumxy = 0
 sumsqx = 0
 sumsqy = 0
 mex = 1           '*** count of x's is always = one unit of time
 For x2 = bb To ee
  mey = y_value(x2)
  xx = mex * mex
  yy = mey * mey
  xy = mex * mey
  sumx = sumx + mex
  sumy = sumy + mey
  sumxy = sumxy + xy
  sumsqx = sumsqx + xx
  sumsqy = sumsqy + yy
  mex = mex + 1
 Next x2   

 ag1 = nper * sumxy
 ag2 = sumx * sumy
 ag3 = nper * sumsqx
 ag4 = sumx * sumx
 ag5 = sumy * sumy
 ag6 = nper * sumsqy
 m = (ag1 - ag2) / (ag3 - ag4)
 b = (sumy - (m * sumx)) / nper
 rx = ag1 - ag2
 ry = (ag3 - ag4) * (ag6 - ag5)
 r = rx / math.Sqrt(ry)
 r = math.abs(r)

 cof_r(x6) = r
 cof_b(x6) = b
 cof_m(x6) = m
 cof_nper(x6) = nper
 cof_bb(x6) = bb
 cof_ee(x6) = ee
 x6 = x6 + 1

 If nper > lowtstslp Then
  nper = nper - 1
 Else
  For x3 = 2 To x6
   If cof_r(x3) > cof_r(1)
    cof_r(1) = cof_r(x3)
    cof_b(1) = cof_b(x3)
    cof_m(1) = cof_m(x3)
    cof_bb(1) = cof_bb(x3)
    cof_ee(1) = cof_ee(x3)
    cof_nper(1) = cof_nper(x3)
   End If
  Next x3 
  r = cof_r(1)
  b = cof_b(1)
  m = cof_m(1)
  bb = cof_bb(1)
  ee = cof_ee(1)
  nper = cof_nper(1)
  
  mex = 1
  For x4 = bb To ee
   newy = b + (m * mex)
    y_value(x4) = newy
    mex = mex + 1
  Next x4
 
  stat_r(x7) = r
  stat_m(x7) = m
  stat_b(x7) = b
  stat_nper(x7) = nper
  stat_bb(x7) = bb
  stat_ee(x7) = ee
  x6 = 1
  ee = bb - 1
  nper = maxnper
  x7 = x7 + 1
 End If

 If ee < (maxnper - 1) Then    '*** test for end of bars loop
  Exit Do
 End If
   
Loop    '*** end of bars loop

'*** sum up stats
x2 = 0
x3 = 0
For x1 = 1 To (x7 - 1)
 If stat_r(x1) >= 0.80 Then
  x2 = x2 + 1
 Else
  x3 = x3 + 1
 End If
Next x1 

x7 = (x2 / (x2 + x3)) * 10000
pergodfit = x7
For x5 = 0 To (price.Bar.count - 1)
 MyBase.addtoOutput(y_datevalue(x5), y_value(x5))
Next x5
Me.chartoverlaytext = "Percent fit w/ R >= 80%: " & pergodfit / 100

'************** end of program *********************************************** 

 

Topic: what is the "bar" name for "volume"
Posted: Sunday, August 15, 2010 11:11:42 PM

Please see line 7 below. I can not see the correct name for volume in your
ref. for array storage in my own class?


'********************************************************************
1     For x1 = 0 To (price.Bar.count - 1)
2          y_datevalue(x1) = price.Bar.datevalue(x1)
3          y_value(x1) = price.Bar.value(x1)
4          y_open(x1) = price.Bar.openvalue(x1)
5          y_high(x1) = price.Bar.highvalue(x1)
6          y_low(x1) = price.Bar.lowvalue(x1)
7          y_volume(x1) = price.bar.volume(x1)         <<<<<<<<<<<<<<<<<
8   Next x1
'*****************************************************************
Topic: no longer linked
Posted: Thursday, August 5, 2010 2:54:24 PM

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

Topic: no longer linked
Posted: Thursday, August 5, 2010 2:52:09 PM

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

Topic: price.bar.closevalue(i)
Posted: Thursday, August 5, 2010 1:27:10 PM
on your blog is the entry "importing market data with the marketdatareader class"
the entry i want to study?
Topic: no longer linked
Posted: Thursday, August 5, 2010 1:07:45 PM

'|******************************************************************
'|*** 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