欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]数据输出公式问题

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有5733人关注过本帖树形打印复制链接

主题:[求助]数据输出公式问题

帅哥哟,离线,有人找我吗?
mfmsonic
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:10 积分:65 威望:0 精华:0 注册:2011/2/12 16:37:19
[求助]数据输出公式问题  发帖心情 Post By:2011/2/12 17:06:36    Post IP:59.108.49.23[只看该作者]

我写了个公式,作用是把当前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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:7302 积分:32559 威望:1000 精华:45 注册:2003/12/30 16:34:32
  发帖心情 Post By:2011/2/12 17:29:39    Post IP:58.246.57.26[只看该作者]

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

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


 回到顶部
帅哥哟,离线,有人找我吗?
mfmsonic
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:10 积分:65 威望:0 精华:0 注册:2011/2/12 16:37:19
  发帖心情 Post By:2011/2/12 19:07:08    Post IP:59.108.49.23[只看该作者]

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

 回到顶部