15bool trading_window_active(std::int64_t current_ms, std::int64_t start_ms,
16 int script_tf_seconds)
noexcept {
17 if (start_ms == std::numeric_limits<std::int64_t>::min())
return true;
18 const std::int64_t buffer_ms = script_tf_seconds > 0
19 ?
static_cast<std::int64_t
>(script_tf_seconds) * 1000 : 0;
20 return current_ms >= start_ms - buffer_ms;
26 double limit_price,
double stop_price,
double qty,
27 const std::string& comment,
28 const std::string& oca_name,
int oca_type,
30 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
33 adapter_.entry(
id, is_long, limit_price, stop_price, qty, comment, oca_name,
38 double qty,
double qty_percent,
bool immediately) {
40 adapter_.close(
id, comment, qty, qty_percent, immediately);
44 double qty,
double qty_percent,
bool immediately,
45 std::uint64_t callsite_token) {
46 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
49 adapter_.close(
id, comment, qty, qty_percent, immediately, callsite_token);
53 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
60 double limit_price,
double stop_price,
61 double trail_points,
double trail_offset,
62 double trail_price,
double qty_percent,
63 const std::string& comment,
double qty,
64 const std::string& oca_name,
65 double profit_ticks,
double loss_ticks) {
66 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
69 adapter_.exit(
id, from_entry, limit_price, stop_price, trail_points, trail_offset,
70 trail_price, qty_percent, comment, qty, oca_name, profit_ticks,
75 const std::string& from_entry,
76 const std::string& comment) {
77 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
80 adapter_.exit_cancel_bracket(exit_id, from_entry, comment);
94 double limit_price,
double stop_price,
95 const std::string& oca_name,
int oca_type) {
96 if (!trading_window_active(current_bar_.timestamp, trade_start_time_, script_tf_seconds_))
99 adapter_.order(
id, is_long, qty, limit_price, stop_price, oca_name, oca_type);
void strategy_cancel_all()
PineExecutionAdapter adapter_
void strategy_entry(const std::string &id, bool is_long, double limit_price=std::numeric_limits< double >::quiet_NaN(), double stop_price=std::numeric_limits< double >::quiet_NaN(), double qty=std::numeric_limits< double >::quiet_NaN(), const std::string &comment={}, const std::string &oca_name={}, int oca_type=0, int qty_type=-1)
void strategy_order(const std::string &id, bool is_long, double qty, double limit_price=std::numeric_limits< double >::quiet_NaN(), double stop_price=std::numeric_limits< double >::quiet_NaN(), const std::string &oca_name={}, int oca_type=0)
void strategy_exit_cancel_bracket(const std::string &exit_id, const std::string &from_entry, const std::string &comment={})
void strategy_close_all()
void strategy_cancel(const std::string &id)
PineStrategyConfig config_
void strategy_exit(const std::string &id, const std::string &from_entry, double limit_price, double stop_price, double trail_points=std::numeric_limits< double >::quiet_NaN(), double trail_offset=std::numeric_limits< double >::quiet_NaN(), double trail_price=std::numeric_limits< double >::quiet_NaN(), double qty_percent=100.0, const std::string &comment={}, double qty=std::numeric_limits< double >::quiet_NaN(), const std::string &oca_name={}, double profit_ticks=std::numeric_limits< double >::quiet_NaN(), double loss_ticks=std::numeric_limits< double >::quiet_NaN())
void strategy_close(const std::string &id, const std::string &comment={}, double qty=std::numeric_limits< double >::quiet_NaN(), double qty_percent=std::numeric_limits< double >::quiet_NaN(), bool immediately=false)