PineForge v0.13.1-379-g9b50973
Deterministic PineScript v6 backtest runtime — C ABI reference
Loading...
Searching...
No Matches
leg_activation.hpp
Go to the documentation of this file.
1#pragma once
2#include <cstdint>
3#include <optional>
4#include <stdexcept>
5
6namespace pineforge {
7
8// Concrete lower bounds resolved when an exit binds an exposure cycle. Other
9// path/price/lifetime constraints remain independent of this lower bound.
15
17public:
19 if (bounds.position_cycle <= 0 || bounds.stop_first_bar < 0 || bounds.limit_first_bar < 0)
20 throw std::invalid_argument("invalid exit-leg activation bounds");
21 bounds_ = bounds;
22 }
23 void unbind() { bounds_.reset(); }
24 const std::optional<ExitLegActivationBounds>& bounds() const { return bounds_; }
25 // An unbound value imposes no lower-bound constraint. Production EXIT
26 // producers bind on live exposure; exposure creation binds retained exits.
27 bool stop_ready(int64_t cycle, int64_t bar) const {
28 return !bounds_ || (bounds_->position_cycle == cycle && bar >= bounds_->stop_first_bar);
29 }
30 bool limit_ready(int64_t cycle, int64_t bar) const {
31 return !bounds_ || (bounds_->position_cycle == cycle && bar >= bounds_->limit_first_bar);
32 }
33private:
34 std::optional<ExitLegActivationBounds> bounds_;
35};
36
37} // namespace pineforge
bool limit_ready(int64_t cycle, int64_t bar) const
void bind(ExitLegActivationBounds bounds)
const std::optional< ExitLegActivationBounds > & bounds() const
bool stop_ready(int64_t cycle, int64_t bar) const