Skip to main content
ATK Pine Script®

Trailing and Reduce-Only Fields

trail_offset for trailing stop strategies, and reduce_only / time_in_force field guidance.

Trailing Fields: trail_offset#

A trailing offset should mean exactly one thing: the live distance used by the strategy's trailing logic. Do not emit it as a decorative extra field. If the strategy is not genuinely trailing, leave it out.

atr_value = ta.atr(frame, int(p["atr_length"]))
frame["atr"] = atr_value
frame["trail_offset"] = frame["atr"] * float(p["trail_mult"])

Reduce-Only and Time-in-Force Fields#

FieldUse it whenGuidance
reduce_onlyThe order must only reduce exposure.Emit it only in strategies that intentionally distinguish add-exposure versus reduce-exposure behavior. Do not set it preemptively in basic examples.
time_in_forceOrder lifetime matters.Use it when the execution venue or policy meaningfully distinguishes GTC, IOC, FOK, or similar order persistence rules. Treat GTC as the stable default unless the full live adapter path for your venue has been verified.

Current guidance: these fields are part of the canonical trade-frame schema. For portable teaching examples, prefer GTC and leave reduce_only false unless the strategy is explicitly a reduce-only management flow.