PineForge v1.4.0-4-g873b25da
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
magnifier_intrabars.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pineforge/bar.hpp>
4
5#include <string>
6#include <string_view>
7#include <vector>
8
10
11/// The intrabar timeframe TradingView's bar magnifier walks on a chart of
12/// `chart_tf`, from the table in TradingView's help centre ("What is bar
13/// magnifier backtesting mode"), each row covering the chart timeframes from
14/// it up to the next one: below 30S 1S, 30S 5S, 1 10S, 5 30S, 10 1, 15 2,
15/// 30 5, 60 10, 240 30, 1D 60, 3D 240, 1W and up 1D. Empty for a literal that
16/// does not parse. R5 lane MAG-INTRABAR measured every row the population
17/// uses against TradingView's own request.security_lower_tf bars and
18/// magnified tapes (tests/fixtures/magnifier_intrabars).
19std::string tradingview_intrabar_timeframe(std::string_view chart_tf);
20
21/// The lower-timeframe path TradingView's bar magnifier walks for every chart
22/// bar of a run whose chart bars are aggregated from `bars` (input timeframe
23/// `input_tf`, chart timeframe `script_tf`, the symbol's `session` in
24/// `timezone`), as bars for IntrabarPath::lower_tf on the input's own grid.
25///
26/// TradingView's intrabars are the symbol's regular bars at the table's
27/// timeframe: anchored at the session day's open, cut at its close, and each
28/// owned by the chart bar that holds its LAST minute, so on a 15-minute chart
29/// a 2-minute intrabar that straddles a chart boundary belongs to the later
30/// bar. A chart bar's path is its own open, its owned intrabars (each open a
31/// discrete point, then its extremes and close), then its own close. Here
32/// that is:
33/// - a one-price bar at the chart bar's open, stamped at its first input,
34/// when its first intrabar starts before it (the straddler);
35/// - each owned intrabar, stamped at its first input bar -- the straddler
36/// one millisecond after the open bar, inside the chart bar that owns it;
37/// - a one-price bar at the chart bar's close, stamped at its last input,
38/// when its last input belongs to a later chart bar's intrabar.
39///
40/// The input bars come back unchanged when the table's intrabar is the input
41/// timeframe itself (a 10-minute chart on 1-minute bars), cannot be built
42/// from it (a 1- or 5-minute chart needs 10- or 30-second bars), or when a
43/// bar's calendar interval cannot be resolved.
44std::vector<Bar> tradingview_magnifier_bars(const Bar* bars, int n,
45 const std::string& input_tf,
46 const std::string& script_tf,
47 const std::string& session,
48 const std::string& timezone);
49
50} // namespace pineforge::source
std::vector< Bar > tradingview_magnifier_bars(const Bar *bars, int n, const std::string &input_tf, const std::string &script_tf, const std::string &session, const std::string &timezone)
The lower-timeframe path TradingView's bar magnifier walks for every chart bar of a run whose chart b...
std::string tradingview_intrabar_timeframe(std::string_view chart_tf)
The intrabar timeframe TradingView's bar magnifier walks on a chart of chart_tf, from the table in Tr...