AlgoHive
Blocks

Manage Rules

Control open positions with stop losses, take profits, and more.

Manage rules control what happens after a position is opened. They protect your capital and lock in profits.

Rule Types

Stop Loss

Exit at a loss threshold to limit downside.

Configuration:

Level TypeDescriptionExample
PercentageDistance from entry5% below entry
Risk MultipleMultiple of initial risk1R (original risk)
PriceSpecific price level$50,000
ExpressionDynamic calculationentry_price - atr * 2

Take Profit

Exit at a profit target to lock in gains.

Configuration:

Level TypeDescriptionExample
PercentageDistance from entry10% above entry
Risk MultipleMultiple of initial risk3R (3x the risk)
PriceSpecific price level$60,000
ExpressionDynamic calculationentry_price + atr * 4
ConditionalExit on signalsignals.overbought

Trailing Stop

Dynamic stop that follows price, protecting profits.

Configuration:

  • Trail Percentage — How far behind price to trail (e.g., 3%)
  • Activation — When to start trailing (optional)

Exit

Exit on a specific signal condition.

Configuration:

  • When — Signal condition to trigger exit
signals.trend_reversal
signals.momentum_dying AND bars_since_entry() > 10

Move Stop

Adjust stop loss level based on conditions.

Configuration:

  • When — Signal to trigger the move
  • To — New stop level (breakeven, percentage, expression)

Example: Move to breakeven after 2R profit:

when: position_profit_pct() > 0.02
to: breakeven

Add

Add to a winning position.

Configuration:

  • When — Signal to add
  • Amount — How much to add (percentage of original)

Targeting

Manage rules can be:

Global (Default)

Apply to all entries in the strategy.

Targeted

Apply only to specific entries. Connect the entry to the manage rule in the workflow editor.

This allows different rules for different entry types:

Long Entry 1 → Stop Loss (tight), Take Profit (2R)
Long Entry 2 → Stop Loss (wider), Take Profit (4R)

Rule Execution Order

When multiple rules could trigger:

  1. Stop Loss — Checked first for capital protection
  2. Take Profit — Checked next
  3. Exit — Conditional exits
  4. Move Stop — Stop adjustments
  5. Trailing Stop — Trail updates
  6. Add — Position additions

Position-Aware Expressions

Manage rules can use position-specific functions:

FunctionDescription
entry_price()Price at position entry
position_profit_pct()Current profit as percentage
bars_since_entry()Bars since position opened
highest_since_entry()Highest price since entry
lowest_since_entry()Lowest price since entry

Example: Trail from highest high:

trail_stop: highest_since_entry() * 0.95

Prediction Market Rules

For prediction markets, use specialized rules:

RuleDescription
Odds StopExit if odds move against you
Odds Take ProfitExit at odds target
Odds TrailingTrail with odds movement
Time ExitExit before market resolution

Best Practices

  • Always use stop losses — Protect capital on every trade
  • Risk-based targets — Use R-multiples for consistency
  • Move stops to breakeven — Reduce risk after profit
  • Trail in trends — Let winners run with trailing stops
  • Match rules to entry type — Different setups need different exits

On this page