返回列表 上一主題 發帖

如何將台指期的每一分鐘資料都紀錄在sheet 1裡..請教版上高手前輩~~

回復 20# cfuxiong


    請問c大,態量.xls檔案內的  圖表區程式碼要如何寫出來?謝謝。
devidlin

TOP

回復 13# cfuxiong


    請問c大,態量.xls檔案內的  圖表區程式碼要如何寫出來?謝謝。
devidlin

TOP

回復 21# c_c_lai


    請問c大,態量.xls檔案內的  圖表區程式碼要如何寫出來?謝謝。
devidlin

TOP

回復 57# c_c_lai


    請參考,謝謝。

量態.zip (35.86 KB)

devidlin

TOP

回復 57# c_c_lai


    小弟比較愚笨,程式碼如下,如果說在圖表區要增加台指期每分鐘之價格邀如何修改?謝謝。

    Option Explicit
Dim LastMin As Integer

Private Sub Workbook_Open()
    Sheets("策略記錄").Cells(4, 2) = 10
    LastMin = Minute(Time)
    Call Timer
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Timer", , False
End Sub


Public Sub Timer()
    Dim Pos As Integer, i As Integer, RangeStr As String
        
    On Error Resume Next
    Application.OnTime Now + TimeValue("00:00:01"), "ThisWorkbook.Timer" '每秒顯示
    Sheets("策略記錄").Cells(3, 2) = Time '將時間show至策略的b3欄位
    Dim HHMM As Integer
    HHMM = Hour(Time) * 100 + Minute(Time)
    If (HHMM < 845 Or HHMM > 2045) Then Exit Sub '營業時間才執行
    If Minute(Time) <> LastMin Then '開始後做
        With Sheets("策略記錄")
            .Cells(4, 2) = .Cells(4, 2) + 1 '將變動行號加一行
            Pos = .Cells(4, 2)
            .Cells(Pos, 1) = Time
            .Cells(Pos, 2) = .Cells(2, 2)
            .Cells(Pos, 3) = .Cells(2, 3)
            .Cells(Pos, 4) = .Cells(2, 4)
            .Cells(Pos, 5) = .Cells(2, 5)
            .Cells(Pos, 6) = .Cells(2, 6)
            .Cells(Pos, 7) = .Cells(2, 7)
            .Cells(Pos, 8) = .Cells(2, 8)
            .Cells(Pos, 9) = .Cells(2, 9)
            .Cells(Pos, 10) = .Cells(2, 10)
            .Cells(Pos, 11) = .Cells(2, 11)
         
        End With
   
        LastMin = Minute(Time)
    End If
End Sub
devidlin

TOP

        靜思自在 : 有多少力量就做多少事,不要心存等待,等待才會落空。
返回列表 上一主題