PineForge v1.4.0-4-g873b25da
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
callback_lifecycle_rules.hpp
Go to the documentation of this file.
1#pragma once
2// Per-rule switches for the callback and lifecycle pins (TradingView
3// synthetic tapes, tests/fixtures/callback_lifecycle). Every switch is ON
4// in the shipped library. They exist so a regression can be bisected one
5// rule at a time: only tests clear them (test_callback_lifecycle_tapes
6// clears each in turn and requires exactly its tapes to depart), through this
7// internal header; no public API, C ABI entry or strategy input reaches them.
8// A switch is read when its rule applies and never stored, so it holds no run
9// state. Process-wide: set one only around single-threaded runs. Not part of
10// the installed API.
11
13
14enum class PineCallbackLifecycleRule : int {
15 // trail_points become whole ticks with a mintick-scaled tolerance,
16 // ceil(trail_points - c * mintick), instead of the constant 5e-5 ticks
17 // (compat::pine::trail_points_to_ticks).
19 // A declined reversal kills the held position's stop and limit exits; a
20 // later re-issue of such an exit, changed or not, is a new live order.
21 // Without the switch an unchanged re-issue keeps the killed row
22 // (reissue_revives_declined_exit).
24 // A limit exit born in a calc_on_order_fills recalculation reaches the
25 // end of its in-flight leg only when that waypoint's tick-built print
26 // does; the level itself stays raw (exit()'s in-flight remainder).
28 // A limit exit under calc_on_order_fills that closes the position held
29 // when it is placed, on the chart path, and that its placement point does
30 // not already reach, rests at its half-tick threshold: a print half a
31 // tick short of an on-grid level reaches it (H 9.725 prints 9.73 and
32 // fills a 9.73 sell limit). Without the switch every on-grid level stays
33 // raw under calc_on_order_fills (exit_limit_trigger).
35 // A carried trailing stop (calc_on_order_fills off) is reached at the
36 // first point where the bar's tick-built print reaches it, when that comes
37 // before the raw print would; the level stays the raw running best +/- the
38 // offset (retune_carried_trails_for_tick_reach).
40};
41
42inline constexpr int kPineCallbackLifecycleRuleCount = 5;
43
46
47} // namespace pineforge::source::detail
bool pine_callback_lifecycle_rule(PineCallbackLifecycleRule rule) noexcept
void set_pine_callback_lifecycle_rule(PineCallbackLifecycleRule rule, bool on) noexcept