Ok.. kenne SAP nicht.
Ich habe auch keinen Filter programmiert, sondern eine Schnittstelle zu Yahoo, die sich die Kursdaten holt. Bin übrigens ein furchtbar schlechter Programmierer. Hab nie ein Buch drüber gelesen und auch nie nen Kurs besucht ;o
Die Variablenbezeichnungen sind wahrscheinlich lächerlich und der Stil nicht sehr kompakt.. aber vielleicht gibt es Dir ja einpaar Ideen. Excel hat VBS, ist mit VB verwandt..
Public Function load_em_up(Source As String)
'Diese Funktion lädt die Werte in den Speicher
Dim comparison As String
comparison ="<tr bgcolor=" & Chr(34) &"#dcdcdc" & Chr(34) &"><th>Date</th><th>Open</th><th>High</th><th>Low</th><th>Close</th><th>Volume</th><th>Adj. Close*</th></tr>"
'Definition des Markers
Dim scaled_source As String
'Variable für die beschnittene Version des Codes
Dim positions(1000) As Long
Dim actual_position As Long
'Diese Variablen dienen dem Speichern der Enter-codes
Dim cols(1000) As String
Dim temp As Long
Dim i As Long
Dim j As Long
'Variablen, die für die Schlaufen verwendet werden
'Der Code wird beschnitten --->> scaled_source
actual_position = 1
For i = 1 To Len(Source) - Len(comparison)
If Mid(Source, i, Len(comparison)) = comparison Then
'OK
scaled_source = Mid(Source, i + Len(comparison) + 5, Len(Source) - i - Len(comparison))
i = Len(Source) - Len(comparison)
End If
Next i
'Die Positionen der Enter-codes werden festgestellt
For i = 1 To Len(scaled_source)
If Mid(scaled_source, i, 1) = Chr(10) Then
positions(actual_position) = i
actual_position = actual_position + 1
End If
Next i
'Die Daten werden zu Zeilen verarbeitet
temp = 0
cols(1) = Mid(scaled_source, 1, positions(1))
For i = 1 To actual_position - 1
If Mid(scaled_source, positions(i) + 1, 5) ="align" Then
temp = temp + 1
cols(temp + 1) = Mid(scaled_source, positions(i) + 1, positions(i + 1) - 1 - positions(i))
End If
Next i
Dim t As Long
For i = 1 To temp + 1
'OPEN
For j = 35 To 45
If Mid(cols(i), j, 1) ="<" Then
s_open(temp - i + 2) = Mid(cols(i), 35, j - 35)
t = j - 35
j = 46
End If
Next j
'HIGH
For j = 43 + t To 53 + t
If Mid(cols(i), j, 1) ="<" Then
s_high(temp - i + 2) = Mid(cols(i), 44 + t, j - 44 - t)
t = j - 43
j = 53 + t
End If
Next j
'LOW
For j = 51 + t To 61 + t
If Mid(cols(i), j, 1) ="<" Then
s_low(temp - i + 2) = Mid(cols(i), 52 + t, j - 52 - t)
t = j - 51
j = 61 + t
End If
Next j
'CLOSE
For j = 62 + t To 72 + t
If Mid(cols(i), j, 1) ="<" Then
s_close(temp - i + 2) = Mid(cols(i), 63 + t, j - 63 - t)
t = j - 62
j = 72 + t
End If
Next j
'Volume
For j = 74 + t To 90 + t
If Mid(cols(i), j, 1) ="<" Then
s_volume(temp - i + 2) = reinigung(Mid(cols(i), 75 + t, j - 75 - t))
t = j - 74
j = 90 + t
End If
Next j
'ADJ.
For j = 82 + t To 92 + t
If Mid(cols(i), j, 1) ="<" Then
s_adj(temp - i + 2) = Mid(cols(i), 83 + t, j - 83 - t)
t = j - 82
j = 92 + t
End If
Next j
If Not s_close(temp - i + 2) = s_adj(temp - i + 2) Then
s_open(temp - i + 2) = s_open(temp - i + 2) / (s_close(temp - i + 2) / s_adj(temp - i + 2))
s_high(temp - i + 2) = s_high(temp - i + 2) / (s_close(temp - i + 2) / s_adj(temp - i + 2))
s_low(temp - i + 2) = s_low(temp - i + 2) / (s_close(temp - i + 2) / s_adj(temp - i + 2))
s_close(temp - i + 2) = s_close(temp - i + 2) / (s_close(temp - i + 2) / s_adj(temp - i + 2))
s_volume(temp - i + 2) = s_volume(temp - i + 2) * (s_close(temp - i + 2) / s_adj(temp - i + 2))
End If
Next i
s_q = temp + 1
Data.EMAs
End Function
'Daten laden
Private Sub Command1_Click()
Data.trend_Anz = 0
Data.SR_Anz = 0
Data.logo = False
'Ticker überprüfen
If Text1.Text ="" Then
Nachricht.Caption ="Kein Ticker!"
Exit Sub
End If
'Internet oder Cache?
If Option1.Value = False And Option2.Value = False Then
Nachricht.Caption ="Keine Option gewählt!"
Exit Sub
End If
'Laden aus dem Cache
If Option1.Value = True Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(Konstanten.Speichort & Text1.Text &".data") Then
Set a = fs.opentextfile(Konstanten.Speichort & Text1.Text &".data", 1, True)
Data.load_em_up (a.readall)
a.Close
Frame2.Enabled = True
Else
Nachricht.Caption ="Nicht im Cache!"
End If
Exit Sub
End If
'Laden aus dem Internet
If Option2.Value = True Then
Dim Source As String
Command1.Enabled = False
Source = Inet1.OpenURL("http://chart.yahoo.com/t?a=" & Text3.Text &"&b=" & Text2.Text &"&c=" & Text4.Text &"&d=" & Text6.Text &"&e=" & Text5.Text &"&f=" & Text7 - Text &"&g=d&s=" & Text1.Text &"&=0&z=medx")
Command1.Enabled = True
Data.load_em_up (Source)
Frame2.Enabled = True
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.fileexists(Konstanten.Speichort & Text1.Text &".data") Then
fs.deletefile (Konstanten.Speichort & Text1.Text &".data")
Set a = fs.createTextFile(Konstanten.Speichort & Text1.Text &".data")
a.write (Source)
a.Close
Else
Set a = fs.createTextFile(Konstanten.Speichort & Text1.Text &".data")
a.write (Source)
a.Close
End If
Exit Sub
End If
End Sub
'Chart zeichnen
Public Function draw_me()
If Form1.advanced = False And Not Chart.Height = 575 * 15 Then
Chart.ScaleHeight = 687 * (685 / 550)
Chart.ScaleWidth = 794 * (800 / 640)
Chart.Height = 550 * 15 + 25 * 15
Chart.Width = 640 * 15
Chart.Label2(0).Top = Chart.Label2(0).Top / 685 * 550
Chart.Label2(1).Top = Chart.Label2(1).Top / 685 * 550
Chart.Label2(2).Top = Chart.Label2(2).Top / 685 * 550
End If
Chart.Cls
Chart.ForeColor = &H0&
Chart.DrawWidth = 2
Dim start As Long
start = 1
'Wir zeichnen die 200 letzten Tage
If Not Data.s_q < 200 Then
start = Data.s_q - 199
End If
'Wir berechnen die Skala
Dim ratio As Double
Dim min As Double
Dim max As Double
Dim i As Long
min = Data.s_open(start)
max = Data.s_open(start)
For i = start To Data.s_q
If Data.s_high(i) > max Then
max = Data.s_high(i)
End If
If Data.s_low(i) < min Then
min = Data.s_low(i)
End If
Next i
min_c = min
max_c = max
ratio = 350 / (max - min)
'Wir zeichnen die Skala (10 teile)
Chart.ForeColor = &HC0C0C0
For i = 1 To 10
Chart.Line (0, i * 35)-(800, i * 35)
Next i
'SRs
If Data.SR_Anz > 0 Then
Chart.DrawStyle = 3
Chart.DrawWidth = 2
For i = 1 To Data.SR_Anz
Chart.ForeColor = Form1.Shape1(Data.color_SR(i)).FillColor
Chart.Line (0, Data.SR(i))-(800, SR(i))
Next i
End If
'Trendlinien
If Data.trend_Anz > 0 Then
Chart.DrawStyle = 1
Chart.DrawWidth = 2
For i = 1 To Data.trend_Anz
Chart.ForeColor = Form1.Shape1(Data.color_trend(i)).FillColor
Chart.Line (Data.trend_x1(i), Data.trend_y1(i))-(Data.trend_x2(i), Data.trend_y2(i))
Next i
End If
'Logo reinhauen
If Data.logo = True Then
Call Chart.PaintPicture(LoadPicture(Konstanten.Speichort &"investmentstrategy.jpg"), Data.logo_x, Data.logo_y)
End If
Chart.DrawWidth = 2
Chart.DrawStyle = 1
Chart.ForeColor = &H0&
Chart.Line (0, 355)-(800, 355)
Chart.Line (0, 465)-(800, 465)
Chart.Line (0, 575)-(800, 575)
'4
Chart.DrawStyle = 2
Chart.DrawWidth = 1
Chart.Line (0, 490)-(800, 490)
Chart.Line (0, 550)-(800, 550)
Chart.Line (0, 600)-(800, 600)
Chart.Line (0, 660)-(800, 660)
Chart.DrawStyle = 0
Chart.DrawWidth = 2
Chart.Line (0, 685)-(800, 685)
Chart.Line (0, 0)-(0, 685)
Chart.Line (0, 0)-(800, 0)
Chart.Line (800, 0)-(800, 685)
'Wir zeichnen den OHLC-CHART
Dim x As Long
For i = start To Data.s_q
'Wir berechnen x
x = 1 + i * 4
'O
Chart.Line (x, (max - Data.s_open(i)) * ratio)-(x, (max - Data.s_open(i)) * ratio)
'HL
Chart.Line (x + 1, (max - Data.s_high(i)) * ratio)-(x + 1, (max - Data.s_low(i)) * ratio)
'C
Chart.Line (x + 2, (max - Data.s_close(i)) * ratio)-(x + 2, (max - Data.s_close(i)) * ratio)
Next i
'Candlesticks
'For i = start To Data.s_q
'X = 1 + i * 4
''Farbe green=&H0000FF00& red=&H000000FF&
'If Data.s_close(i) > Data.s_open(i) Then
'Chart.ForeColor = &HFF00&
'Else
'If Data.s_close(i) < Data.s_open(i) Then
'Chart.ForeColor = &HFF&
'Else
'Chart.ForeColor = &H0&
'End If
'End If
'Farbe Zeichnen
'Chart.Line (X + 1, (max - Data.s_open(i)) * ratio)-(X + 1, (max - Data.s_close(i)) * ratio)
'Next i
'EMAs
For i = Form1.Text8.Text + 1 To Data.s_q
If Form1.Check1.Value = 1 Then
Chart.ForeColor = &HFF0000
Chart.Line (i * 4 - 2, (max - Data.PRICE_EMA(Form1.Text8.Text, i - 1)) * ratio)-(2 + i * 4, (max - Data.PRICE_EMA(Form1.Text8.Text, i)) * ratio)
End If
Next i
For i = Form1.Text9.Text + 1 To Data.s_q
If Form1.Check2.Value = 1 Then
Chart.ForeColor = &HFF00FF
Chart.Line (i * 4 - 2, (max - Data.PRICE_EMA(Form1.Text9.Text, i - 1)) * ratio)-(2 + i * 4, (max - Data.PRICE_EMA(Form1.Text9.Text, i)) * ratio)
End If
Next i
'Volumen einzeichnen
'Wir berechnen die Skala
min = Data.s_volume(start)
max = Data.s_volume(start)
For i = start To Data.s_q
If Data.s_volume(i) > max Then
max = Data.s_volume(i)
End If
If Data.s_volume(i) < min Then
min = Data.s_volume(i)
End If
Next i
ratio = 100 / (max - min)
Chart.DrawWidth = 3
For i = 1 To Data.s_q
If i > 1 And Data.s_close(i) > Data.s_close(i - 1) Then
Chart.ForeColor = &HFF00&
Else
If i > 1 And Data.s_close(i) < Data.s_close(i - 1) Then
Chart.ForeColor = &HFF&
Else
Chart.ForeColor = &H0&
End If
End If
Chart.Line (i * 4 - 2, (max - Data.s_volume(i)) * ratio + 360)-(i * 4 - 2, 460)
Next i
For i = Form1.Text10.Text + 1 To Data.s_q
If Form1.Check3.Value = 1 Then
Chart.ForeColor = &HFF0000
Chart.Line (i * 4 - 2, (max - Data.volume_EMA(Form1.Text10.Text, i - 1)) * ratio + 360)-(2 + i * 4, (max - Data.volume_EMA(Form1.Text10.Text, i)) * ratio + 360)
End If
Next i
'Stochastic einzeichnen
Chart.DrawWidth = 1
Call Data.stoch(Form1.Text11.Text, Form1.Text13.Text, Form1.Text12.Text)
ratio = 1
For i = Int(Form1.Text11.Text) + Int(Form1.Text12.Text) + Int(Form1.Text13.Text) - 1 To Data.s_q
Chart.ForeColor = &HFF0000
Chart.Line (i * 4 - 2, (100 - Data.stoch_D(i - 1)) * ratio + 470)-(2 + i * 4, (100 - Data.stoch_D(i)) * ratio + 470)
Chart.ForeColor = &HFF00FF
Chart.Line (i * 4 - 2, (100 - Data.stoch_K(i - 1)) * ratio + 470)-(2 + i * 4, (100 - Data.stoch_K(i)) * ratio + 470)
Next i
'MACD einzeichnen
Call Data.calc_MACD(Form1.Text14.Text, Form1.Text15.Text, Form1.Text16.Text)
min = Data.MACD(start_MACD)
max = Data.MACD(start_MACD)
For i = Data.start_MACD To Data.s_q
If Data.MACD(i) > max Then
max = Data.MACD(i)
End If
If Data.MACD(i) < min Then
min = Data.MACD(i)
End If
If Data.MACD_s(i) > max Then
max = Data.MACD(i)
End If
If Data.MACD_s(i) < min Then
min = Data.MACD(i)
End If
Next i
If min < 0 Then
For i = Int(start_MACD) To Data.s_q
Data.MACD(i) = Data.MACD(i) + Abs(min)
Data.MACD_s(i) = Data.MACD_s(i) + Abs(min)
Next i
End If
max = max + Abs(min)
min = 0
ratio = 100 / (max - min)
For i = start_MACD + 1 To Data.s_q
Chart.ForeColor = &HFF0000
Chart.Line (i * 4 - 2, (max - Data.MACD(i - 1)) * ratio + 580)-(2 + i * 4, (max - Data.MACD(i)) * ratio + 580)
Chart.ForeColor = &HFF00FF
Chart.Line (i * 4 - 2, (max - Data.MACD_s(i - 1)) * ratio + 580)-(2 + i * 4, (max - Data.MACD_s(i)) * ratio + 580)
Next i
End Function
Gruss
Daniel
<center>
<HR>
</center> |