-- График должен быть открыт в 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.
protected override void Execute() { var d1 = (Close >> 1) - (Close >> 2); var d2 = (Close >> 2) - (Close >> 3); var d3 = (Close >> 3) - (Close >> 4); var d4 = (Close >> 4) - (Close >> 5); for (int i = 5; i < Bars.Count-2; i++) { double A = d1[i]*d4[i] - d2[i]*d3[i]; double B = d2[i]*d2[i] - d1[i]*d3[i]; double id = A*d1[i] + B*d2[i]; int posDir = (! IsLastPositionActive) ? 0 : LastPosition.PositionType == PositionType.Long ? 1 : -1; if (id >= 0 && posDir != 1) { if (posDir == -1) ExitAtClose (i, LastPosition); BuyAtClose (i); } else if (id < 0 && posDir != -1) { if (posDir == 1) ExitAtClose (i, LastPosition); ShortAtClose (i); } } // for (int i } // Execute()даёт результаты на минутках на 68 днях от 10:00 до 18:44 для сделок без комиссии и проскальзывания
StrategyName Growth SANDP-500_010216_220131dayly Weekly ini 1326.6100 fin 4546.5400 growth 3.4272 bars 1091 years 20.9699 year% 6.0498 mean% 12.3421 nn;HiIdx;HiMax ; HiDate ; LoIdx;LoMin ; LoDate ;Days ;Drawdown ;Pct>=20 0; 0; 1326.61; 17.02.2001; 86; 768.63; 11.10.2002; 601; 557.98; 42.06 1; 344; 1576.03; 13.10.2007; 417; 667.04; 07.03.2009; 511; 908.99; 57.68 2; 530; 1370.58; 06.05.2011; 552; 1075.09; 07.10.2011; 154; 295.49; 21.56 3; 915; 2940.91; 21.09.2018; 929; 2346.58; 28.12.2018; 98; 594.33; 20.21 4; 989; 3393.52; 21.02.2020; 994; 2192.07; 27.03.2020; 35; 1201.45; 35.40 Самая долгая просадка 0; 0; 1326.61; 17.02.2001; 86; 768.63; 11.10.2002; 601; 557.98; 42.06 Наибольшая абсолютная 4; 989; 3393.52; 21.02.2020; 994; 2192.07; 27.03.2020; 35; 1201.45; 35.40 Наибольшая относительная 1; 344; 1576.03; 13.10.2007; 417; 667.04; 07.03.2009; 511; 908.99; 57.68Результаты по NASDAQ
for (int i = i0; i < weeks.Count; ++i) { int idxIni = IndexOf (weeks[i][0]-1, entryTime); int idxFin = IndexOf (weeks[i][1], exitTime); double strike = mwu.RoundTo (Open[idxIni], strikeStep); double dura = (Date[idxFin] - Date[idxIni]).TotalDays; double calIni = OptPrice ('C', Open[idxIni], strike, dura, volaIni); double putIni = OptPrice ('P', Open[idxIni], strike, dura, volaIni); double calFin = OptPrice ('C', Close[idxFin], strike, 1e-6, volaFin); double putFin = OptPrice ('P', Close[idxFin], strike, 1e-6, volaFin); double win = (calIni+putIni) * (1-slpg) - (calFin+putFin) - 2*fee; PrintDebug (String.Format (fmt, i, Date[idxFin].ToShortDateString() ,calIni, putIni, calFin, putFin, win)); } // for (int i = i0Вот выдача за первый квартал