以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  [求助]数据输出公式问题  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=5147)

--  作者:mfmsonic
--  发布时间:2011/2/12 17:06:36
--  [求助]数据输出公式问题
我写了个公式,作用是把当前K线界面的数据输出到一个txt文件中,但出现问题就是只能输出一个文件,当pageDn切换下一个合约时,不能输出新合约的数据,请大侠帮忙指点!附公式源码: _Barpos := BARPOS; _Year := YEAR; _Month := MONTH; _Day := DAY; _Time := Time; _Datatype := DATATYPE; _Marketlabel := MARKETLABEL; _StkName := STKLABEL; _Open := OPEN; _High := HIGH; _Low := LOW; _Close := CLOSE; _Vol := VOL; _Amount := AMOUNT; <% Dim Marketlabels,Stknames,Datatypes,Opens,Highs,Lows,Closes,Vols,Amounts,Years,Months,Days Barposes = ffl.vardata("_Barpos") Years = ffl.vardata("_Year") Months = ffl.vardata("_Month") Days = ffl.vardata("_Day") Times = ffl.vardata("_Time") Datatypes = ffl.vardata("_Datatype") Marketlabels = ffl.vardata("_Marketlabel") Stknames = ffl.vardata("_Stkname") Opens = ffl.vardata("_Open") Highs = ffl.vardata("_High") Lows = ffl.vardata("_Low") Closes = ffl.vardata("_Close") Vols = ffl.vardata("_Vol") Amounts = ffl.vardata("_Amount") If ReportFolderStatus("D:\\Ascii Data") = 0 Then CreatFolder() SelectCreatAsciiDataType(Datatypes) Function SelectCreatAsciiDataType(Types) Select Case Types Case 0 Case 1 Call CreateAsciiDataMin("01min","01") Case 2 Call CreateAsciiDataMin("05min","05") Case 3 Call CreateAsciiDataMin("15min","15") Case 4 Call CreateAsciiDataMin("30min","30") Case 5 Call CreateAsciiDataMin("60min","60") Case 6 Call CreateAsciiDataDayes() Case 7 Case 8 Case 9 Case 10 Case 11 Case Else End Select End Function Function CreateAsciiDataMin(FolderName,DataName) Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateTrue = -1,TristateFalse = 0,TristateUseDefault = -2 Dim Fso,FileName,TextStream,LineData,ArrayLast,LastDate,AforeDate,AforeYear,AforeMonth,AforeDay Set Fso = CreateObject("Scripting.FileSystemObject") FileName = "D:\\Ascii Data\\" & FolderName & "\\" & StkNames & "." & DataName & ".txt" Set TextStream = Fso.OpenTextFile(FileName, ForWriting, True) ArrayLast = Ubound(Barposes) LastDate = Years(ArrayLast) & "-" & Months(ArrayLast) & "-" & Days(ArrayLast) For i = 0 to ArrayLast AforeDate = DateAdd("d",(i-ArrayLast),LastDate) AforeYear = Year(AforeDate) AforeMonth = Month(AforeDate) If Len(AforeMonth) = 1 Then AforeM & AforeMonth AforeDay = Day(AforeDate) If Len(AforeDay) = 1 Then AforeDay = "0" & AforeDay Opens(i) = FormatNumber(Opens(i),2,,,TristateFalse) Highs(i) = FormatNumber(Highs(i),2,,,TristateFalse) Lows(i) = FormatNumber(Lows(i),2,,,TristateFalse) Closes(i) = FormatNumber(Closes(i),2,,,TristateFalse) Vols(i) = FormatNumber(Vols(i),2,,,TristateFalse) Amounts(i) = FormatNumber(Amounts(i),2,,,TristateFalse) LineData = Years(i) &"/"& Months(i) &"/"& Days(i) & "," & Times(i) & ","& Opens(i) & "," & Highs(i) & "," & Lows(i) & "," & Closes(i) & "," & Vols(i) & "," & Amounts(i) TextStream.WriteLine LineData Next TextStream.Close End Function Function CreateAsciiDataDayes() Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateTrue = -1,TristateFalse = 0,TristateUseDefault = -2 Dim Fso,FileName,TextStream,LineData,ArrayLast Set Fso = CreateObject("Scripting.FileSystemObject") FileName = "D:\\Ascii Data\\Dayes\\" & StkNames & ".txt" Set TextStream = Fso.OpenTextFile(FileName, ForWriting, True) ArrayLast = Ubound(Barposes) For i = 0 to ArrayLast If Len(Months(i)) = 1 Then Months(i) = "0" & Months(i) If Len(Days(i)) = 1 Then Days(i) = "0" & Days(i) Opens(i) = FormatNumber(Opens(i),2,,,TristateFalse) Highs(i) = FormatNumber(Highs(i),2,,,TristateFalse) Lows(i) = FormatNumber(Lows(i),2,,,TristateFalse) Closes(i) = FormatNumber(Closes(i),2,,,TristateFalse) Vols(i) = FormatNumber(Vols(i),2,,,TristateFalse) Amounts(i) = FormatNumber(Amounts(i),2,,,TristateFalse) LineData = Years(i) &"/"& Months(i) &"/"& Days(i) & "," & Opens(i) & "," & Highs(i) & "," & Lows(i) & "," & Closes(i) & "," & Vols(i) & "," & Amounts(i) TextStream.WriteLine LineData Next TextStream.Close End Function Function ReportFileStatus(filespec) Dim Fso, Status Set Fso = CreateObject("Scripting.FileSystemObject") If (Fso.FileExists(filespec)) Then Status = 1 Else Status = 0 End If ReportFileStatus = Status End Function Function ReportFolderStatus(FolderDir) Dim Fso, Status Set Fso = CreateObject("Scripting.FileSystemObject") If (Fso.FolderExists(FolderDir)) Then Status = 1 Else Status = 0 End If ReportFolderStatus = Status End Function Function CreatFolder() Dim Fso Set Fso = CreateObject("Scripting.FileSystemObject") Dim Folder Set Folder = Fso.CreateFolder("D:\\Ascii Data") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\Years") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\Moons") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\Weeks") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\Dayes") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\60min") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\30min") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\15min") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\05min") Set Folder = Fso.CreateFolder("D:\\Ascii Data\\01min") End Function %> 1;
--  作者:admin
--  发布时间:2011/2/12 17:29:39
--  

Marketlabels = ffl.vardata("_Marketlabel")
Stknames = ffl.vardata("_Stkname")
传递字符串变量要在金字塔里使用专用的语法

Marketlabels = ffl.strvardata("_Marketlabel")
Stknames = ffl.strvardata("_Stkname")


--  作者:mfmsonic
--  发布时间:2011/2/12 19:07:08
--  
谢谢admin版主的指点,已成功解决!
[此贴子已经被作者于2011-2-12 19:31:32编辑过]