PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
timeframe.hpp File Reference
#include <string>
#include <cstdint>
#include <vector>
#include "bar.hpp"
Include dependency graph for timeframe.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pineforge::AggregatedBar
 
struct  pineforge::NativeDayPartition
 
class  pineforge::NativeDayPartitionScope
 
class  pineforge::TimeframeAggregator
 

Namespaces

namespace  pineforge
 
namespace  pineforge::internal
 

Macros

#define PINEFORGE_HAS_NATIVE_DAY_PARTITION_V1   1
 

Enumerations

enum class  pineforge::CalendarPeriod {
  pineforge::NONE ,
  pineforge::DAY ,
  pineforge::WEEK ,
  pineforge::MONTH
}
 

Functions

int pineforge::tf_to_seconds (const std::string &tf)
 Convert a TradingView timeframe string to seconds.
 
int pineforge::tf_multiplier (const std::string &tf)
 Extract the numeric multiplier from a TF string (e.g. "15" -> 15, "D" -> 1).
 
bool pineforge::tf_is_intraday (const std::string &tf)
 
bool pineforge::tf_is_daily (const std::string &tf)
 
bool pineforge::tf_is_weekly (const std::string &tf)
 
bool pineforge::tf_is_monthly (const std::string &tf)
 
bool pineforge::tf_is_seconds (const std::string &tf)
 
bool pineforge::tf_change (int64_t prev_ms, int64_t curr_ms, const std::string &tf)
 Check if prev/curr timestamps cross a timeframe boundary.
 
int pineforge::tf_ratio (const std::string &input_tf, const std::string &target_tf)
 Compute how many input bars fit into one target bar.
 
std::string pineforge::detect_timeframe (const Bar *bars, int n, int max_samples=100)
 Detect the timeframe string from an array of bars by computing the median timestamp delta and mapping to the nearest standard TF.
 
CalendarPeriod pineforge::calendar_period_for (const std::string &tf)
 Determine the calendar period for a target TF string.
 
bool pineforge::tf_is_daily_or_higher (const std::string &tf)
 True for a daily-or-higher chart timeframe ("D", "1D", "2D", "W", "M"): a bar that covers whole session days rather than a time of day (the aggregation path's CALENDAR classification).
 
bool pineforge::crosses_boundary (int64_t prev_ms, int64_t curr_ms, CalendarPeriod period)
 Check if two timestamps (Unix milliseconds) fall in different calendar periods.
 
bool pineforge::crosses_boundary (int64_t prev_ms, int64_t curr_ms, CalendarPeriod period, const std::string &tz, const std::string &session)
 Timezone/session-aware variants.
 
bool pineforge::tf_change (int64_t prev_ms, int64_t curr_ms, const std::string &tf, const std::string &tz, const std::string &session)
 
int64_t pineforge::session_day_index (int64_t ms, const std::string &tz, const std::string &session)
 Ordinal of the session day containing ms (days since epoch on the session clock).
 
int64_t pineforge::internal::session_trading_day_index (int64_t ms, const std::string &tz, const std::string &session)
 Broker trading-day ordinal on the unmerged symbol session clock.
 
int64_t pineforge::session_period_open_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Open (Unix ms) of the symbol's D/W/M bar that contains ms: the day stamp of the period's first session-day (17:00 ET on OANDA 1800-1700, the session open elsewhere).
 
int64_t pineforge::session_intraday_bucket_open_ms (int64_t ms, int64_t bucket_sec, const std::string &tz, const std::string &session)
 Open (Unix ms) of the bucket_sec-wide intraday bucket that contains ms on the symbol's day-stamp-anchored grid: exchange-tz time since local midnight + day stamp, floored to the bucket width.
 
int64_t pineforge::session_covered_instant_ms (int64_t ms, const std::string &tz, const std::string &session)
 The session instant a native CALENDAR chart stamp covers.
 
int64_t pineforge::session_period_close_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Exclusive close (Unix ms) of the symbol's D/W/M bar that contains ms: DAY -> session-day open + session length (16:00 ET on equities, the next 17:00 ET on forex, next midnight on 24x7); WEEK / MONTH -> the open of the next period's first session-day.
 
int64_t pineforge::session_period_last_traded_close_ms (int64_t ms, const std::string &tz, const std::string &session, CalendarPeriod period)
 Exclusive close (Unix ms) of the LAST TRADED session-day of the D/W/M bar that contains ms: DAY is session_period_close_ms; WEEK / MONTH step back from the period's last session-day over weekend TRADING dates (Saturday / Sunday never hold a session on exchange-calendar symbols), so an equity week ends Friday 16:00 ET, a month whose last calendar day is a weekend ends on its last Friday, and the forex week ends Friday 17:00 ET (the Friday-open session is Saturday's trading date).
 
bool pineforge::build_native_day_partition (NativeDayPartition &out, const std::string &tz, const std::string &session, const std::vector< int64_t > &stamps, const Bar *input_bars, int n_input)
 Build the partition for the symbol clock (tz, session) from the native daily stamps and the chart's input bars (the trade instants: the last input bar before the next stamp, bounded by the last stamp's nominal session-day close; the stamp itself when no input bar lies in the period).
 
int pineforge::native_day_partition_index (const NativeDayPartition &p, int64_t ms)
 Index of the native period holding ms under p: -1 before the first stamp and at / after the last stamp's nominal session-day close.
 
const NativeDayPartitionpineforge::set_active_native_day_partition (const NativeDayPartition *p)
 The calling thread's active chart partition, read by session_day_index / session_period_open_ms / session_period_close_ms / session_period_last_traded_close_ms / crosses_boundary (and so by tf_change, the symbol-clock pine_time forms and ta::VWAP's session anchor) whenever their (tz, session) equal the partition's.
 
const NativeDayPartitionpineforge::active_native_day_partition ()
 

Variables

constexpr int64_t pineforge::kSecPerDay = 86400
 
constexpr int64_t pineforge::kMsPerDay = 86400000
 

Macro Definition Documentation

◆ PINEFORGE_HAS_NATIVE_DAY_PARTITION_V1

#define PINEFORGE_HAS_NATIVE_DAY_PARTITION_V1   1

Definition at line 284 of file timeframe.hpp.