Bijan
 
I looked at using Quotes Plus's scan capability and Excel this last
weekend to provide a historical calculation of the number of advancing
and declining stocks and the total up down volume on a daily basis for a
basket of stocks.  I didn't like what I saw and decided that a better
approach was to use Visual Basic 2005 Express Edition to perform the
calclations.  Shown below is the code I came up with.  
The output data is in CSV format and can be loaded into Excel for
further analaysis or plotting. 
 
Thanks go to nduroman for his posting on 6/11/2006 for providing a great
starting point for this program.  
 
Howard
 
'To Compile and Run this code with Visual Basic 2005 Epress Edition
 
'1.   In Visual Basic 2005 Express Edition Choose "File" , "New Project"
and
'   "Console Application". Next provide a "Project Name" in the "Name"
box
'   on the "New Project" page and then click "OK".
'2. Replace the starter code provided by Microsoft with the code shown
below.
'3.   Go to "Project" in the menu
'4.   Choose "Add Reference"
'5.   Click on the COM tab and find "Quotes Plus 1.1 Type Library.
Highlight
'   this and press "Select" then OK. 
'6. Select "Build" and "Build "Your Project Name" "
'7. Select "Debug" and "Start Debugging"
 
Imports QuotesPlus
Structure AdvanceDecline
    Public Up As Integer
    Public Down As Integer
    Public UpVol As Long
    Public DownVol As Long
    Public DataDate As Date
    Public Overrides Function ToString() As String
        Return (FormatDateTime(DataDate, DateFormat.ShortDate) & ",  " &
_
        Up.ToString() & ",    " & Down.ToString() & ",   " & _
        UpVol.ToString() & ",    " & DownVol.ToString())
 
    End Function
End Structure
 
Module Module1
 
    Sub Main()
        ' Create an instance of Price2Class
        Dim qpData As QuotesPlus.Price2Class
        qpData = New QuotesPlus.Price2Class
 
        Dim qpClose1 As Double
        Dim qpClose2 As Double
        Dim qpVolume As Integer
        Dim qpDate As Date
        Dim qpDaysLoaded As Integer
        Dim advances As Integer
        Dim decliners As Integer
        Dim UpVolume As Long
        Dim DownVolume As Long
        ' Sample set of symbols use to test program.
        ' Edit the sample set to suit your needs.
        Dim Symbols() As String
        Symbols = New String() {"AAPL", "AMD", "C", "DELL", "GM", "H", _
        "IBM", "INTC", "QCOM", "SNDK"}
        ' NumOfDays is the number of days for which advances, decliners,
        ' up volume and down volume is calculated.  Edit the value to
suit
        ' your needs.  Forty four hundred is about the maximum number of
        ' days Quotes Plus supplies historical data. 
        Const NumOfDays As Integer = 100
        Dim DayNum As Integer
        ' Daily calculations of advances, decliners, up volume and down
        ' voume is stored in the "Results" array.  
        Dim Results(NumOfDays) As AdvanceDecline
 
        For DayNum = -NumOfDays To -1
            advances = 0
            decliners = 0
            UpVolume = 0
            DownVolume = 0
 
            For Each sym As String In Symbols
                qpData.Symbol = sym
                ' "DaysLoaded"  is the number of days Quotes Plus
provides
                ' historical data, for a particular stock, and is used
to
                ' skip days prior to when a new issue starts trading.  
                qpDaysLoaded = qpData.DaysLoaded
                If (DayNum + qpDaysLoaded < 1) Then Continue For
 
                qpClose1 = qpData.Close(DayNum)
                qpClose2 = qpData.Close(DayNum + 1)
                qpVolume = qpData.Volume(DayNum + 1)
                qpDate = qpData.Date(DayNum + 1)
                If (qpClose2 > qpClose1) Then
                    advances += 1
                    UpVolume += qpVolume
                End If
                If (qpClose2 < qpClose1) Then
                    decliners += 1
                    DownVolume += qpVolume
                End If
            Next
 
            Results(NumOfDays + DayNum).Up = advances
            Results(NumOfDays + DayNum).UpVol = UpVolume
 
            Results(NumOfDays + DayNum).Down = decliners
            Results(NumOfDays + DayNum).DownVol += DownVolume
 
            Results(NumOfDays + DayNum).DataDate = qpDate
        Next
 
        ' Write data for first and last date on screen.
        Dim Header As String = "Date    Advances   Decliners" & _
                                "Up Volume     Down Volume"
        Console.WriteLine(Header)
        Console.WriteLine(Results(0).ToString())
        Console.WriteLine(Results(NumOfDays - 1).ToString())
 
        ' Write all data to a file. Edit the file name and path to suit
        ' your needs.  You should manually empty the output file between
        ' runs.  Because each time the program is run the new data is
        ' appened to the old data. 
        My.Computer.FileSystem.WriteAllText("C:\AdvDecl.txt", Header & _
                                            vbCrLf, True)
        For i As Integer = 0 To (NumOfDays - 1)
            My.Computer.FileSystem.WriteAllText("C:\AdvDecl.txt", _
                                Results(i).ToString() & vbCrLf, True)
        Next
 
    End Sub
End Module
 
 
 
 
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of Bijan Khezri
Sent: Friday, August 25, 2006 7:14 AM
To: [email protected]
Subject: RE: [quotes-plus] Scan help
 
Howard,

Thank you very much. I am aware of the existing data which is published
by
the exchanges. I am trying to put together a way to do the same for
other
indices, such as the Russell 2000, for which the exchanges do not
publish
breadth data. With kind regards,

Bijan

_____ 

From: quotes-plus@ <mailto:quotes-plus%40yahoogroups.com>
yahoogroups.com [mailto:quotes-plus@
<mailto:quotes-plus%40yahoogroups.com> yahoogroups.com] On
Behalf Of Howard Hansen
Sent: Friday, August 25, 2006 12:09 AM
To: quotes-plus@ <mailto:quotes-plus%40yahoogroups.com> yahoogroups.com
Subject: RE: [quotes-plus] Scan help

Bejin 

I will take a look at using Quotes Plus and Excel to calculate the
number of advancing and declining stocks in a list this week end. But
have you noticed that Quotes Plus already has historical data for
exactly the type of data you are looking for the American, NASDAQ and
New York Stock Exchanges. 

Howard

Bijan 

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
 


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/quotes-plus/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to