PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
exit_activation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <pineforge/bar.hpp>
6
7#include <cstddef>
8#include <cstdint>
9#include <limits>
10#include <optional>
11#include <string_view>
12#include <utility>
13
15
17
22
23// Immutable source placement evidence. It is retained with the adapter
24// snapshot, so rebinding an exit never reinterprets a later owner/price.
26 std::int64_t position_cycle = 0;
27 int entry_bar = -1;
28 int direction = 0;
29 double cursor_price = 0.0;
30 double stop_level = std::numeric_limits<double>::quiet_NaN();
31 double limit_level = std::numeric_limits<double>::quiet_NaN();
32 std::optional<LimitContinuation> limit_continuation;
33};
34
36public:
39 const std::optional<ExitPlacementEvidence>& evidence() const noexcept { return evidence_; }
40 bool holds_stop() const noexcept;
41 bool holds_limit() const noexcept;
42 bool continues_at_later_open() const noexcept;
43 ExitLegActivationBounds resolve(std::int64_t owner_cycle, int owner_entry_bar) const;
44private:
45 std::optional<ExitPlacementEvidence> evidence_;
46};
47
48// Pure producer facts from the adapter's current native callback. The
49// selector is deliberately source-layer only; it cannot alter native matching.
51 bool requested_trailing = false;
52 bool full_quantity = true;
53 bool from_fill = false;
54 bool has_from_entry = false;
56 std::string_view from_entry{};
57 std::string_view oca_name{};
58 double quantity = std::numeric_limits<double>::quiet_NaN();
59};
60
62 std::int64_t cycle = 0;
63 int bar_index = -1;
65 int direction = 0;
66 double cursor_price = std::numeric_limits<double>::quiet_NaN();
67 bool fill_recalc = false;
68 bool scheduler = false;
69 bool magnifier = false;
70 bool process_on_close = false;
71 bool warmup = false;
72 bool stream_idle = true;
74 int recalc_leg = 0;
75 bool historical_segment = false;
76 bool at_extreme = false;
78 std::uint64_t current_fill = 0;
81 double position_quantity = 0.0;
82 int pyramiding = 0;
83 std::size_t lot_count = 0;
84 std::string_view first_lot_id{};
85 std::uint64_t first_lot_incarnation = 0;
86 std::uint64_t market_recalc_incarnation = 0;
87 std::uint64_t market_recalc_fill = 0;
88 bool pending_empty = false;
89 int slippage = 0;
90 double pointvalue = 1.0;
91 double account_fx = 1.0;
92 bool fx_series_empty = true;
93 bool bar_path_high_first = false;
94 double tick_high = std::numeric_limits<double>::quiet_NaN();
95};
96
98 double stop, double limit,
99 const ExitActivationContext& context);
100
101} // namespace pineforge::compat::pine
102
ExitLegActivationBounds resolve(std::int64_t owner_cycle, int owner_entry_bar) const
const std::optional< ExitPlacementEvidence > & evidence() const noexcept
ExitActivationPolicy select_exit_activation(const ExitActivationRequest &request, double stop, double limit, const ExitActivationContext &context)
compat::pine::ExitActivationPolicy PineExitActivationPolicy
std::optional< LimitContinuation > limit_continuation