FX自動売買ソフト製作のMagic EA Maker
前の5件 | -
もう少し [FX エクセル]
[FXシステムトレード] ブログ村キーワード
やはり歯抜けデータの問題は不可避だったので、対応中
以下は歯抜けを検出し、行を挿入するプロセス。
同じ時刻の価格を比べる必要があるため。
Sub InsertCell()
ZikanB = InputBox("【冬時間指定】何時からを抽出しますか?(0〜23)")
HunB = InputBox("【冬時間指定】何分から抽出しますか?(0〜59)")
ZikanE = InputBox("【冬時間指定】何時までを抽出しますか?(0〜23)")
HunE = InputBox("【冬時間指定】何分まで抽出しますか?(0〜59)")
For t = 0 To 10 Step 9
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
Cells(1, 1 + t).Activate
ic = 0
Do Until ActiveCell.Value = "" 'For ic = 1 To lastrow(0)
ic = ic + 1
Cells(ic, 1 + t).Activate
HSup = Minute(Cells(ic, 2 + t))
HSdown = Minute(Cells(ic + 1, 2 + t))
HScalc = HSdown - HSup
HidukeUp = Day(Cells(ic, 1 + t))
HidukeDown = Day(Cells(ic + 1, 1 + t))
HJ = Hour(Cells(ic, 2 + t))
OJ = Hour(Cells(ic, 2 + t))
HH = Minute(Cells(ic, 2 + t))
OH = Minute(Cells(ic, 2 + t))
If HidukeDown <> HidukeUp Then '日付が違っていたら
If HSdown <> HunB Then 'HHがスタートになっているかチェック
InsSuu = HSdown - HunB
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
If HSup <> HunE And Cells(ic + 1, 1) <> "" Then 'OHが終わりになっているかチェック
InsSuu = HunE - HSup
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
End If
Select Case HScalc
Case Is > 1 '1分毎か否か
If HidukeDown = HidukeUp Then '日付が同じか
InsSuu = HSdown - HSup - 1
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
Case Is < 0 '時間が異なる場合
InsSuu = 60 - Abs(HSdown - HSup - 1)
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End Select
Loop 'Next
Next t
End Sub
応援お願いします。m(__)m
↓ ↓ ↓ ↓
にほんブログ村
やはり歯抜けデータの問題は不可避だったので、対応中
以下は歯抜けを検出し、行を挿入するプロセス。
同じ時刻の価格を比べる必要があるため。
Sub InsertCell()
ZikanB = InputBox("【冬時間指定】何時からを抽出しますか?(0〜23)")
HunB = InputBox("【冬時間指定】何分から抽出しますか?(0〜59)")
ZikanE = InputBox("【冬時間指定】何時までを抽出しますか?(0〜23)")
HunE = InputBox("【冬時間指定】何分まで抽出しますか?(0〜59)")
For t = 0 To 10 Step 9
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
Cells(1, 1 + t).Activate
ic = 0
Do Until ActiveCell.Value = "" 'For ic = 1 To lastrow(0)
ic = ic + 1
Cells(ic, 1 + t).Activate
HSup = Minute(Cells(ic, 2 + t))
HSdown = Minute(Cells(ic + 1, 2 + t))
HScalc = HSdown - HSup
HidukeUp = Day(Cells(ic, 1 + t))
HidukeDown = Day(Cells(ic + 1, 1 + t))
HJ = Hour(Cells(ic, 2 + t))
OJ = Hour(Cells(ic, 2 + t))
HH = Minute(Cells(ic, 2 + t))
OH = Minute(Cells(ic, 2 + t))
If HidukeDown <> HidukeUp Then '日付が違っていたら
If HSdown <> HunB Then 'HHがスタートになっているかチェック
InsSuu = HSdown - HunB
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
If HSup <> HunE And Cells(ic + 1, 1) <> "" Then 'OHが終わりになっているかチェック
InsSuu = HunE - HSup
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
End If
Select Case HScalc
Case Is > 1 '1分毎か否か
If HidukeDown = HidukeUp Then '日付が同じか
InsSuu = HSdown - HSup - 1
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End If
Case Is < 0 '時間が異なる場合
InsSuu = 60 - Abs(HSdown - HSup - 1)
For icc = 1 To InsSuu
Range(Cells(ic + 1, 1 + t), Cells(ic + 1, 8 + t)).Insert
'lastrow(0) = lastrow(0) + 1
ic = ic + 1
Next
End Select
Loop 'Next
Next t
End Sub
応援お願いします。m(__)m
↓ ↓ ↓ ↓
にほんブログ村
歯抜けデータを埋める [FX エクセル]
データ抽出 [FX エクセル]
[システムトレード] ブログ村キーワード
お久しぶりです(^O^)/
バアルです。
データ抽出をすることができました。
歯抜けの問題は、今回抽出した分に関しては問題なかったので
スルーします^^;
おそらく条件指定してInsertとかを使えばいけると思いますが、
使うところに該当箇所がないならまあいいかということでw
Insert関数にかんしてはここが参考になりそうでした。
朝あまりに早かったり、週末の引け間際とかでマイナー通貨は
「できない」ということがあるので、データが歯抜けなんですね。
そういうところは使わないのが吉だと思います。
で、以下ができあがったもの。冗長ですw
Dim lastrow(100) As Long
Dim Youbi As Integer
Dim ZikanB As Integer
Dim ZikanE As Integer
Dim HunB As Integer
Dim HunE As Integer
Dim Hajimari As Single
Dim Owari As Single
Dim HajimariV As Single
Dim OwariV As Single
Dim ownBookName As String
Dim BookName(10) As String
Dim WBK As Workbook
Dim G As Integer
Dim f1 As String
Dim f2 As String
Dim wb As Workbook
Sub main()
Set WBK = ThisWorkbook ' 自ブック
ownBookName = WBK.Name ' 自ブック名
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f1 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "1回目")
If f1 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f2 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "2回目")
If f2 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
MsgBox f1 & " を開きます"
'Workbooks.OpenText Filename:=f1, DataType:=xlDelimited, comma:=True
Dim buf As String, n As Long
Open f1 For Input As #1
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 1) = buf
Dim i As Long, tmp As Variant
tmp = Split(Cells(n, 1), ",")
Cells(n, 1) = tmp(0)
Cells(n, 2) = tmp(1)
Cells(n, 3) = tmp(2)
Cells(n, 4) = tmp(3)
Cells(n, 5) = tmp(4)
Cells(n, 6) = tmp(5)
Loop
Close #1
'Set wb = Workbooks.Add
MsgBox f2 & " を開きます"
'Workbooks.OpenText Filename:=f2, DataType:=xlDelimited, comma:=True
Open f2 For Input As #1
n = 0
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 10) = buf
tmp = Split(Cells(n, 10), ",")
Cells(n, 10) = tmp(0)
Cells(n, 11) = tmp(1)
Cells(n, 12) = tmp(2)
Cells(n, 13) = tmp(3)
Cells(n, 14) = tmp(4)
Cells(n, 15) = tmp(5)
Loop
Close #1
'For n = 1 To Workbooks.Count
' BookName(n) = Workbooks(n).Name
' If BookName(n) <> ownBookName Then
' G = n
' End If
'Next n
'Workbooks(BookName(G)).Activate
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
Youbi = InputBox("何曜日を抽出しますか?(月=1:火=2:水=3:木=4:金=5")
ZikanB = InputBox("何時からを抽出しますか?(0〜23)")
HunB = InputBox("何分から抽出しますか?(0〜59)")
ZikanE = InputBox("何時までを抽出しますか?(0〜23)")
HunE = InputBox("何分まで抽出しますか?(0〜59)")
Hajimari = 0.000694445 * 60 * ZikanB + 0.000694445 * HunB
Owari = 0.000694445 * 60 * ZikanE + 0.000694445 * HunE
For t = 0 To 10 Step 9
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
Cells(i, 7 + t) = WorksheetFunction.Weekday(Cells(i, 1 + t), 1)
Cells(i, 8 + t) = Month(Cells(i, 1 + t))
Next
For i = 1 To lastrow(0)
If Cells(i, 8 + t) > 2 And Cells(i, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(i, 7 + t) <> Youbi Or Cells(i, 2 + t) < HajimariV Or Cells(i, 2 + t) > OwariV Then
For ii = i To lastrow(0)
If Cells(ii, 8 + t) > 2 And Cells(ii, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(ii, 7 + t) = Youbi And Cells(ii, 2 + t) > HajimariV And Cells(ii, 2 + t) < OwariV Then
'Workbooks(BookName(G)).Activate
Range(Cells(i, 1 + t), Cells(ii - 2, 8 + t)).Select
Selection.Clear
i = ii + 1
Exit For
End If
Next
End If
Next
For k = 1 To lastrow(0)
If Cells(k, 1 + t) = "" Then
For kk = k To lastrow(0)
If Cells(kk, 1 + t) <> "" Then
Exit For
End If
Next
Range(Cells(k, 1 + t), Cells(kk - 1, 9 + t)).Select
'Rows(k & ":" & kk - 1).Select
Selection.Delete shift:=xlUp
lastrow(0) = lastrow(0) - (kk - k)
If k > lastrow(0) Then
Exit For
End If
'IL = IL + 1
End If
Next k
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
If Cells(i, 8 + t) > 2 And Cells(i, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(i, 7 + t) <> Youbi Or Cells(i, 2 + t) > OwariV Then
Range(Cells(i, 1 + t), Cells(lastrow(0), 8 + t)).Select
Selection.Clear
If t > 0 Then
GoTo Syuuryou
End If
Exit For
End If
Next
Next t
Syuuryou:
End Sub
次回はグラフに反映して可視化します(^O^)
応援お願いします。m(__)m
↓ ↓ ↓ ↓
にほんブログ村
バアルです。
データ抽出をすることができました。
歯抜けの問題は、今回抽出した分に関しては問題なかったので
スルーします^^;
おそらく条件指定してInsertとかを使えばいけると思いますが、
使うところに該当箇所がないならまあいいかということでw
Insert関数にかんしてはここが参考になりそうでした。
朝あまりに早かったり、週末の引け間際とかでマイナー通貨は
「できない」ということがあるので、データが歯抜けなんですね。
そういうところは使わないのが吉だと思います。
で、以下ができあがったもの。冗長ですw
Dim lastrow(100) As Long
Dim Youbi As Integer
Dim ZikanB As Integer
Dim ZikanE As Integer
Dim HunB As Integer
Dim HunE As Integer
Dim Hajimari As Single
Dim Owari As Single
Dim HajimariV As Single
Dim OwariV As Single
Dim ownBookName As String
Dim BookName(10) As String
Dim WBK As Workbook
Dim G As Integer
Dim f1 As String
Dim f2 As String
Dim wb As Workbook
Sub main()
Set WBK = ThisWorkbook ' 自ブック
ownBookName = WBK.Name ' 自ブック名
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f1 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "1回目")
If f1 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f2 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "2回目")
If f2 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
MsgBox f1 & " を開きます"
'Workbooks.OpenText Filename:=f1, DataType:=xlDelimited, comma:=True
Dim buf As String, n As Long
Open f1 For Input As #1
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 1) = buf
Dim i As Long, tmp As Variant
tmp = Split(Cells(n, 1), ",")
Cells(n, 1) = tmp(0)
Cells(n, 2) = tmp(1)
Cells(n, 3) = tmp(2)
Cells(n, 4) = tmp(3)
Cells(n, 5) = tmp(4)
Cells(n, 6) = tmp(5)
Loop
Close #1
'Set wb = Workbooks.Add
MsgBox f2 & " を開きます"
'Workbooks.OpenText Filename:=f2, DataType:=xlDelimited, comma:=True
Open f2 For Input As #1
n = 0
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 10) = buf
tmp = Split(Cells(n, 10), ",")
Cells(n, 10) = tmp(0)
Cells(n, 11) = tmp(1)
Cells(n, 12) = tmp(2)
Cells(n, 13) = tmp(3)
Cells(n, 14) = tmp(4)
Cells(n, 15) = tmp(5)
Loop
Close #1
'For n = 1 To Workbooks.Count
' BookName(n) = Workbooks(n).Name
' If BookName(n) <> ownBookName Then
' G = n
' End If
'Next n
'Workbooks(BookName(G)).Activate
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
Youbi = InputBox("何曜日を抽出しますか?(月=1:火=2:水=3:木=4:金=5")
ZikanB = InputBox("何時からを抽出しますか?(0〜23)")
HunB = InputBox("何分から抽出しますか?(0〜59)")
ZikanE = InputBox("何時までを抽出しますか?(0〜23)")
HunE = InputBox("何分まで抽出しますか?(0〜59)")
Hajimari = 0.000694445 * 60 * ZikanB + 0.000694445 * HunB
Owari = 0.000694445 * 60 * ZikanE + 0.000694445 * HunE
For t = 0 To 10 Step 9
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
Cells(i, 7 + t) = WorksheetFunction.Weekday(Cells(i, 1 + t), 1)
Cells(i, 8 + t) = Month(Cells(i, 1 + t))
Next
For i = 1 To lastrow(0)
If Cells(i, 8 + t) > 2 And Cells(i, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(i, 7 + t) <> Youbi Or Cells(i, 2 + t) < HajimariV Or Cells(i, 2 + t) > OwariV Then
For ii = i To lastrow(0)
If Cells(ii, 8 + t) > 2 And Cells(ii, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(ii, 7 + t) = Youbi And Cells(ii, 2 + t) > HajimariV And Cells(ii, 2 + t) < OwariV Then
'Workbooks(BookName(G)).Activate
Range(Cells(i, 1 + t), Cells(ii - 2, 8 + t)).Select
Selection.Clear
i = ii + 1
Exit For
End If
Next
End If
Next
For k = 1 To lastrow(0)
If Cells(k, 1 + t) = "" Then
For kk = k To lastrow(0)
If Cells(kk, 1 + t) <> "" Then
Exit For
End If
Next
Range(Cells(k, 1 + t), Cells(kk - 1, 9 + t)).Select
'Rows(k & ":" & kk - 1).Select
Selection.Delete shift:=xlUp
lastrow(0) = lastrow(0) - (kk - k)
If k > lastrow(0) Then
Exit For
End If
'IL = IL + 1
End If
Next k
lastrow(0) = Cells(1, 1 + t).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
If Cells(i, 8 + t) > 2 And Cells(i, 8 + t) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If Cells(i, 7 + t) <> Youbi Or Cells(i, 2 + t) > OwariV Then
Range(Cells(i, 1 + t), Cells(lastrow(0), 8 + t)).Select
Selection.Clear
If t > 0 Then
GoTo Syuuryou
End If
Exit For
End If
Next
Next t
Syuuryou:
End Sub
次回はグラフに反映して可視化します(^O^)
応援お願いします。m(__)m
↓ ↓ ↓ ↓
にほんブログ村
2通貨目追加 [FX エクセル]
[FXシステムトレード] ブログ村キーワード
2通貨目の追加をするプログラムを作りました。
こんな感じです。
Dim lastrow(100) As Long
Dim Youbi As Integer
Dim ZikanB As Integer
Dim ZikanE As Integer
Dim HunB As Integer
Dim HunE As Integer
Dim Hajimari As Single
Dim Owari As Single
Dim HajimariV As Single
Dim OwariV As Single
Dim ownBookName As String
Dim BookName(10) As String
Dim WBK As Workbook
Dim G As Integer
Dim f1 As String
Dim f2 As String
Dim wb As Workbook
Sub main()
Set WBK = ThisWorkbook ' 自ブック
ownBookName = WBK.Name ' 自ブック名
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f1 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "1回目")
If f1 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f2 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "2回目")
If f2 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
MsgBox f1 & " を開きます"
'Workbooks.OpenText Filename:=f1, DataType:=xlDelimited, comma:=True
Dim buf As String, n As Long
Open f1 For Input As #1
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 1) = buf
Dim i As Long, tmp As Variant
tmp = Split(Cells(n, 1), ",")
Cells(n, 1) = tmp(0)
Cells(n, 2) = tmp(1)
Cells(n, 3) = tmp(2)
Cells(n, 4) = tmp(3)
Cells(n, 5) = tmp(4)
Cells(n, 6) = tmp(5)
Loop
Close #1
'Set wb = Workbooks.Add
MsgBox f2 & " を開きます"
'Workbooks.OpenText Filename:=f2, DataType:=xlDelimited, comma:=True
Open f2 For Input As #1
n = 0
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 10) = buf
tmp = Split(Cells(n, 10), ",")
Cells(n, 10) = tmp(0)
Cells(n, 11) = tmp(1)
Cells(n, 12) = tmp(2)
Cells(n, 13) = tmp(3)
Cells(n, 14) = tmp(4)
Cells(n, 15) = tmp(5)
Loop
Close #1
'For n = 1 To Workbooks.Count
' BookName(n) = Workbooks(n).Name
' If BookName(n) <> ownBookName Then
' G = n
' End If
'Next n
'Workbooks(BookName(G)).Activate
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
Youbi = InputBox("何曜日を抽出しますか?(月=1:火=2:水=3:木=4:金=5")
ZikanB = InputBox("何時からを抽出しますか?(0〜23)")
HunB = InputBox("何分から抽出しますか?(0〜59)")
ZikanE = InputBox("何時までを抽出しますか?(0〜23)")
HunE = InputBox("何分まで抽出しますか?(0〜59)")
Hajimari = 0.000694445 * 60 * ZikanB + 0.000694445 * HunB
Owari = 0.000694445 * 60 * ZikanE + 0.000694445 * HunE
For i = 1 To lastrow(0)
Cells(i, 7) = WorksheetFunction.Weekday(Cells(i, 1), 1)
Cells(i, 8) = Month(Cells(i, 1))
Next
For i = 1 To lastrow(0)
If Cells(i, 8) > 2 And Cells(i, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If i > 31833 Then
i = i
End If
If Cells(i, 7) <> Youbi Or Cells(i, 2) < HajimariV Or Cells(i, 2) > OwariV Then
For ii = i To lastrow(0)
If Cells(ii, 8) > 2 And Cells(ii, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If ii > 35000 Then
ii = ii
End If
If Cells(ii, 7) = Youbi And Cells(ii, 2) > HajimariV And Cells(ii, 2) < OwariV Then
Workbooks(BookName(G)).Activate
Range("A" & i, "H" & ii - 2).Select
Selection.Clear
i = ii + 1
Exit For
End If
Next
End If
Next
For k = 1 To lastrow(0)
If Cells(k, 1) = "" Then
For kk = k To lastrow(0)
If Cells(kk, 1) <> "" Then
Exit For
End If
Next
Rows(k & ":" & kk - 1).Select
Selection.Delete shift:=xlUp
lastrow(0) = lastrow(0) - (kk - k)
If k > lastrow(0) Then
Exit For
End If
'IL = IL + 1
End If
Next k
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
If Cells(i, 8) > 2 And Cells(i, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If i > 189 Then
i = i
End If
If Cells(i, 7) <> Youbi Or Cells(i, 2) > OwariV Then
For ii = i To lastrow(0)
Workbooks(BookName(G)).Activate
Range("A" & i, "H" & lastrow(0)).Select
Selection.Clear
i = ii + 1
'Exit For
GoTo Syuuryou
Next
End If
Next
Syuuryou:
End Sub
Split関数というのを使って、カンマ区切りのテキストファイルを
ひとつひとつのセルに放り込みます。
面倒ですが、これが一番いいだろうと聞きましたのでそれで
作りました。
で、うまく行ったんですが、新たに問題が浮上。
なんと、歯抜けデータが存在します(;・∀・)
抜けデータがある時間帯が朝早いようなので、
おそらく、取引がなかったのであろうと推察します。
約定がないから値がつかない。
これ、どうするかなぁ。
使う箇所のみ抽出して、そこに歯抜けがあったら上の行を
コピーするようにしますかね。時間がそろわないと
比べられないですよね。
加工する前に処理をすると重くなりそうだしな。ふむ。。。
今日の1位はどこかしら
↓ ↓ ↓ ↓
にほんブログ村
2通貨目の追加をするプログラムを作りました。
こんな感じです。
Dim lastrow(100) As Long
Dim Youbi As Integer
Dim ZikanB As Integer
Dim ZikanE As Integer
Dim HunB As Integer
Dim HunE As Integer
Dim Hajimari As Single
Dim Owari As Single
Dim HajimariV As Single
Dim OwariV As Single
Dim ownBookName As String
Dim BookName(10) As String
Dim WBK As Workbook
Dim G As Integer
Dim f1 As String
Dim f2 As String
Dim wb As Workbook
Sub main()
Set WBK = ThisWorkbook ' 自ブック
ownBookName = WBK.Name ' 自ブック名
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f1 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "1回目")
If f1 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
ChDir "C:\Users\wak\Desktop\書庫\AutoForexite\HistoricalData" '\AUDJPY\1min"
f2 = Application.GetOpenFilename("テキスト ファイル (*.txt), *.txt", , "2回目")
If f2 = "False" Then
MsgBox "キャンセル"
Exit Sub
End If
MsgBox f1 & " を開きます"
'Workbooks.OpenText Filename:=f1, DataType:=xlDelimited, comma:=True
Dim buf As String, n As Long
Open f1 For Input As #1
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 1) = buf
Dim i As Long, tmp As Variant
tmp = Split(Cells(n, 1), ",")
Cells(n, 1) = tmp(0)
Cells(n, 2) = tmp(1)
Cells(n, 3) = tmp(2)
Cells(n, 4) = tmp(3)
Cells(n, 5) = tmp(4)
Cells(n, 6) = tmp(5)
Loop
Close #1
'Set wb = Workbooks.Add
MsgBox f2 & " を開きます"
'Workbooks.OpenText Filename:=f2, DataType:=xlDelimited, comma:=True
Open f2 For Input As #1
n = 0
Do Until EOF(1)
Line Input #1, buf
n = n + 1
Cells(n, 10) = buf
tmp = Split(Cells(n, 10), ",")
Cells(n, 10) = tmp(0)
Cells(n, 11) = tmp(1)
Cells(n, 12) = tmp(2)
Cells(n, 13) = tmp(3)
Cells(n, 14) = tmp(4)
Cells(n, 15) = tmp(5)
Loop
Close #1
'For n = 1 To Workbooks.Count
' BookName(n) = Workbooks(n).Name
' If BookName(n) <> ownBookName Then
' G = n
' End If
'Next n
'Workbooks(BookName(G)).Activate
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
Youbi = InputBox("何曜日を抽出しますか?(月=1:火=2:水=3:木=4:金=5")
ZikanB = InputBox("何時からを抽出しますか?(0〜23)")
HunB = InputBox("何分から抽出しますか?(0〜59)")
ZikanE = InputBox("何時までを抽出しますか?(0〜23)")
HunE = InputBox("何分まで抽出しますか?(0〜59)")
Hajimari = 0.000694445 * 60 * ZikanB + 0.000694445 * HunB
Owari = 0.000694445 * 60 * ZikanE + 0.000694445 * HunE
For i = 1 To lastrow(0)
Cells(i, 7) = WorksheetFunction.Weekday(Cells(i, 1), 1)
Cells(i, 8) = Month(Cells(i, 1))
Next
For i = 1 To lastrow(0)
If Cells(i, 8) > 2 And Cells(i, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If i > 31833 Then
i = i
End If
If Cells(i, 7) <> Youbi Or Cells(i, 2) < HajimariV Or Cells(i, 2) > OwariV Then
For ii = i To lastrow(0)
If Cells(ii, 8) > 2 And Cells(ii, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If ii > 35000 Then
ii = ii
End If
If Cells(ii, 7) = Youbi And Cells(ii, 2) > HajimariV And Cells(ii, 2) < OwariV Then
Workbooks(BookName(G)).Activate
Range("A" & i, "H" & ii - 2).Select
Selection.Clear
i = ii + 1
Exit For
End If
Next
End If
Next
For k = 1 To lastrow(0)
If Cells(k, 1) = "" Then
For kk = k To lastrow(0)
If Cells(kk, 1) <> "" Then
Exit For
End If
Next
Rows(k & ":" & kk - 1).Select
Selection.Delete shift:=xlUp
lastrow(0) = lastrow(0) - (kk - k)
If k > lastrow(0) Then
Exit For
End If
'IL = IL + 1
End If
Next k
lastrow(0) = Cells(1, 1).End(xlDown).Row 'MA40最終行
For i = 1 To lastrow(0)
If Cells(i, 8) > 2 And Cells(i, 8) < 11 Then '夏時間対応
HajimariV = Hajimari - (0.000694445 * 60)
OwariV = Owari - (0.000694445 * 60)
Else: HajimariV = Hajimari
OwariV = Owari
End If
If i > 189 Then
i = i
End If
If Cells(i, 7) <> Youbi Or Cells(i, 2) > OwariV Then
For ii = i To lastrow(0)
Workbooks(BookName(G)).Activate
Range("A" & i, "H" & lastrow(0)).Select
Selection.Clear
i = ii + 1
'Exit For
GoTo Syuuryou
Next
End If
Next
Syuuryou:
End Sub
Split関数というのを使って、カンマ区切りのテキストファイルを
ひとつひとつのセルに放り込みます。
面倒ですが、これが一番いいだろうと聞きましたのでそれで
作りました。
で、うまく行ったんですが、新たに問題が浮上。
なんと、歯抜けデータが存在します(;・∀・)
抜けデータがある時間帯が朝早いようなので、
おそらく、取引がなかったのであろうと推察します。
約定がないから値がつかない。
これ、どうするかなぁ。
使う箇所のみ抽出して、そこに歯抜けがあったら上の行を
コピーするようにしますかね。時間がそろわないと
比べられないですよね。
加工する前に処理をすると重くなりそうだしな。ふむ。。。
今日の1位はどこかしら
↓ ↓ ↓ ↓
にほんブログ村
GMO証券 口座開設 [GMO証券 口座開設]
最短5分で申し込み完了!今ならFXネオ新規口座開設で
5000円のキャッシュバック中
↓ ↓ ↓ ↓
≪GMOクリック証券≫【FXネオ】1クリックで即時注文が可能なスピード注文機能を搭載!
GMO証券はバイナリーオプションの取引口座としても非常に人気です。
人気の理由はバイナリーオプションの配当が2倍である点
最低購入金額は100円からで、FXはちょっと怖いな・・・という人もまずはバイナリーオプションから
超低リスクで始めるのがいいと思います。100万円のデモトレードより身銭を切る100円の方が
真剣になれますよ(^^♪
FXをやるよい稽古台にもなると思います。FX特有の「利を伸ばす」「損を早く切る」など非常に難しい
判断がなくてもいいのは楽ですね(・∀・)
しかも通貨ペアは円主要3ペアに加えてユーロドルもバイナリーできるのはGMO証券くらいだと思います。
エントリーは5分おきなので、寝る前に1トレードというような使い方もOK
他の証券会社のoptionは締切時間が近づくと倍率が1.01倍とかになってしまいますが、
GMO証券は2倍の固定でおどろきのレートです(゜o゜;
発注ツールも極力シンプルに作られていて、発注しづらいとか重いということはまったくなかったです。
FX取引も優秀なスペックです。
スプレッドもドル円で0.3銭
ユーロ円で0.8銭
ユーロ・ドルで0.6pips
と業界最狭水準です(・∀・)b
プレミアチャートは軽くて見やすいです(・∀・)
画像はこんな感じ。
↓ ↓ ↓ ↓
このプレミアチャートのうえのほうに幾つかツールバーがあるので、今回はまずひとつ紹介。
左から3つ目が経済指標カレンダーでいつなにが発表になるか一目瞭然です(^o^)v
指標を使ったトレードをしているかたなら、すぐチェックできて便利ですね。
続く
口座開設はこちらから>>≪GMOクリック証券≫【FXネオ】1クリックで即時注文が可能なスピード注文機能を搭載!
5000円のキャッシュバック中
↓ ↓ ↓ ↓
≪GMOクリック証券≫【FXネオ】1クリックで即時注文が可能なスピード注文機能を搭載!
GMO証券はバイナリーオプションの取引口座としても非常に人気です。
人気の理由はバイナリーオプションの配当が2倍である点
最低購入金額は100円からで、FXはちょっと怖いな・・・という人もまずはバイナリーオプションから
超低リスクで始めるのがいいと思います。100万円のデモトレードより身銭を切る100円の方が
真剣になれますよ(^^♪
FXをやるよい稽古台にもなると思います。FX特有の「利を伸ばす」「損を早く切る」など非常に難しい
判断がなくてもいいのは楽ですね(・∀・)
しかも通貨ペアは円主要3ペアに加えてユーロドルもバイナリーできるのはGMO証券くらいだと思います。
エントリーは5分おきなので、寝る前に1トレードというような使い方もOK
他の証券会社のoptionは締切時間が近づくと倍率が1.01倍とかになってしまいますが、
GMO証券は2倍の固定でおどろきのレートです(゜o゜;
発注ツールも極力シンプルに作られていて、発注しづらいとか重いということはまったくなかったです。
FX取引も優秀なスペックです。
スプレッドもドル円で0.3銭
ユーロ円で0.8銭
ユーロ・ドルで0.6pips
と業界最狭水準です(・∀・)b
プレミアチャートは軽くて見やすいです(・∀・)
画像はこんな感じ。
↓ ↓ ↓ ↓
このプレミアチャートのうえのほうに幾つかツールバーがあるので、今回はまずひとつ紹介。
左から3つ目が経済指標カレンダーでいつなにが発表になるか一目瞭然です(^o^)v
指標を使ったトレードをしているかたなら、すぐチェックできて便利ですね。
続く
口座開設はこちらから>>≪GMOクリック証券≫【FXネオ】1クリックで即時注文が可能なスピード注文機能を搭載!
前の5件 | -
GMOクリック証券