주시
1
0
포크
이미 MQL5Book을(를) 포크했습니다
0
원본 프로젝트 rosh/MQL5Book
MQL5Book/Scripts/p7/DBQuotesIntradayLag.sql
16 라인
856 비
SQL
super.admin
2025-05-30 16:09:41 +02:00
-- this SQL statement expects 3 input parameters (start time, stop time, limit)
-- NB: if this text is processed by StringFormat-ing, '%' symbols should be doubled
-- in MQL5 code to preserve them for SQL processing
SELECT
DATETIME(time, 'unixepoch') as datetime,
open,
time,
TIME(time, 'unixepoch') AS intraday,
STRFTIME('%w', time, 'unixepoch') AS day,
(LAG(open,-1) OVER (ORDER BY time) - open) AS delta,
SIGN(open - LAG(open) OVER (ORDER BY time)) AS direction,
(LAG(open,-1) OVER (ORDER BY time) - open) * (open - LAG(open) OVER (ORDER BY time)) AS product,
(LAG(open,-1) OVER (ORDER BY time) - open) * SIGN(open - LAG(open) OVER (ORDER BY time)) AS estimate
FROM MqlRatesDB
WHERE (time >= ?1 AND time < ?2)
ORDER BY time LIMIT ?3;