Блог им. kurd
-- График должен быть открыт в Quik'е Class = "SPBFUT" -- "CETS_MTL" "CETS" SecId="BRK4" -- "NGJ4" "GLDRUB_TOM" "USD000UTSTOM" "SiZ3" Intrvl = INTERVAL_H1 -- D1 -- M5 Header = "<TICKER>;<PER>;<DATE>;<TIME>;".. "<OPEN>;<HIGH>;<LOW>;<CLOSE>;<VOL>" Period = "60" -- Дневки - 0, W1, MN1, H4, H2 - недопустимо function Log (i) local t = DS:T(i) local ymd = string.format ("%04d%02d%02d", t.year, t.month, t.day) local hms = string.format ("%02d%02d%02d", t.hour, t.min, t.sec); if not (IniDt <= ymd and ymd <= FinDt) or not (IniTm <= hms and hms <= FinTm) then return end local str = string.format ("%s;%s;%s;%s;%.4f;%.4f;%.4f;%.4f;%.0f\n" ,SecId, Period, ymd, hms ,DS:O(i), DS:H(i), DS:L(i), DS:C(i), DS:V(i)) F:write (str) end -- Log() function OnInit (scriptPath) qu = require ("QuikUtil(qu)") -- lu,qc,tu ScriptDir, ScriptName = lu. <a name="cut"></a> SplitPath (scriptPath) DataPath = ScriptDir .. ScriptName .. ".dat" message (DataPath) end -- OnInit() function main () os.execute ("notepad.exe ".. DataPath) dofile (DataPath) -- Class, SecId, Frame, IniDt, FinDt Intrvl = qu.FrameToInterval (Frame) Period = Frame == "D1" and 0 or Intrvl DS, err = CreateDataSource (Class, SecId, Intrvl) if not DS or DS:Size() == 0 then error ("No DS\n".. tostring(err)) end local t0 = DS:T(1); local k = DS:Size(); local t1 = DS:T(k) local iniDt=string.format("%04d%02d%02d",t0.year,t0.month,t0.day) local finDt=string.format("%04d%02d%02d",t1.year,t1.month,t1.day) if iniDt > IniDt or finDt < FinDt then error ("Короткая история ".. iniDt .."-".. finDt) end LogPath = ScriptDir .. SecId .."_".. Frame .."_".. IniDt .."_".. FinDt ..".csv" message ( "Class ".. tostring(Class) .."\nSecId ".. tostring(SecId) .."\nFrame ".. tostring(Frame) .."\nIntrvl ".. tostring(Intrvl) .."\nLogPath ".. LogPath .."\nPeriod ".. Period .."\nIniDt ".. IniDt .."\nFinDt ".. FinDt) if Period > 240 then error ("Invalid Frame") end F = io.open (LogPath, "w") F:write (Header .."\n") for i = 1, DS:Size() do Log (i) end F:close() message (ScriptName .." OK") end -- main()
Class = "SPBFUT" SecId = "VBH5" Frame = "H1" IniDt = "20240912" FinDt = "20250129"
Rostislav Kudryashov, Сравниваю что?