Skip to content
Open RaamTrade

RC2_EXIT_ARG

An exit rule needs its numbers: stop_loss, take_profit and break_even take one threshold; trailing_stop takes two numbers, an activation and a distance.

What it means

The exit rules — self.stop_loss(...), self.take_profit(...), self.break_even(...), self.trailing_stop(...) — register a price level the platform watches tick by tick. stop_loss, take_profit and break_even each describe one level with one number, so a second positional value would be a second level in one rule, and no value at all would be a rule with nothing to trigger on. Both are refused rather than guessed.

trailing_stop is the one rule with two numbers: how far the trade must be up before trailing starts, and how far behind the best price to trail. It is refused with no numbers, with more than two, with only one of the two named numbers, or with named and positional numbers mixed. (With one positional number it is RC2_TRAILING_TWO_NUMBERS.)

(These are the exit rules. The exit verbs — sell, buy_to_cover — are a different shape with their own diagnostics.)

Why it happens

A rule registered with no threshold — often a half-finished edit, or an expectation that the platform has a house default:

class NoThreshold(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
self.stop_loss()
if self.trade.is_flat:
self.buy(self.trade)

Or two numbers, reading as “stop at 2%, target 5%” — one call cannot say both:

class TwoValues(Strategy):
trade = Symbol()
sizing = FixedCapital()
def execute(self):
self.take_profit(5.0, 2.0)
if self.trade.is_flat:
self.buy(self.trade)

How to fix it

One number per threshold rule, two for trailing_stop. Register as many rules as you need — whichever triggers first wins.

class ThreeRules(Strategy):
stop_pct = Param(2.0, min=0.5, max=10.0)
trade = Symbol()
sizing = FixedCapital()
def execute(self):
self.stop_loss(self.stop_pct)
self.take_profit(5.0)
self.trailing_stop(0, 1.5)
if self.trade.is_flat:
self.buy(self.trade)

The threshold can be a literal or a Param — using a Param is what makes the stop optimizable alongside the rest of the strategy.