stratester.com

Actions · action block

Sell a fixed dollar amount

The sell $ action sells BTC worth a fixed dollar amount at the fill price, never more than the position.

How the engine evaluates it

The quantity is amount / fill price, capped at the BTC held. At market the fill is the close less slippage, or a wick-triggered level. Sales worth under one cent are skipped.

By default the action sells at market. limit X% instead places a sell limit at close × (1 + X/100), to take profit higher: it fills on the first candle whose high reaches it, at the higher of that candle's open and the limit, with no slippage. stop X% places a sell stop at close × (1 − X/100), to get out lower: it fills on the first candle whose low reaches it, at the lower of the open and the stop, less slippage.

A limit or stop order is placed at the close of the candle where the rule fired and works on the next N candles (expires N, 12 by default); if none reaches its price, it lapses with no trade. Working orders are checked at the start of each candle, before that candle's rules, in rule order. Each rule has at most one working order, so the rule firing again while its order works places nothing. The size is worked out when the order fills, from the cash or position at that moment, and if there is nothing to trade the order is used up without a trade.

Every fill pays the fee set on the bot, a percent of the fill's value charged in dollars (0.1% for new bots; bots created before fees existed keep 0%). Market and stop fills also pay the bot's slippage, which moves the fill price against you; limit fills get none. The fee is taken from the proceeds, so the cash received is slightly less than the amount.

Formula
BTC sold = min(amount / fill price, BTC held)
notional = BTC sold × fill price
fee paid = notional × fee
cash received = notional − fee paid

Botscript syntax

In the Lab you pick this block from the Actions group and fill in its fields. In the code view the same action is written like this:

sell $500
sell $2000
sell $500 limit 2%

Settings

SettingValuesDefaultNotes
Amountany dollar amount$1,000Worth of BTC sold, before the fee.
Ordermarket, limit, stopmarketLimit and stop orders wait for a price; see above.
Offset0.01 – 50%1%Distance of the order price from the close of the candle where the rule fired.
Expires1 – 1,000 candles12How many candles a limit or stop order works for.

How traders use it

  • Regular profit taking: sell $500 each time RSI is overbought.
  • Rebalancing a position built with fixed-dollar buys.

Example bot

botscript
bot "Trim Into Strength"

guard stacking on

when rsi(14) < 30 and cooldown 24
then buy $1000

when rsi(14) > 70 and cooldown 24
then sell $500
  • Adds $1,000 on oversold readings, at most once per 24 candles.
  • Trims $500 on overbought readings.

Pitfalls

  • A dollar amount larger than the position simply sells everything.

Sell $: frequently asked questions

What if the position is worth less than the amount?

The whole position is sold.

At what price?

At market, the candle's close less slippage, or the trigger level of a wick-based P&L condition in the same rule. A limit or stop order fills at its own price, or at the candle's open when the candle opens beyond it.

Does selling reset the cooldown?

Yes, any trade does.

Is the amount in USD?

In USDT, which tracks the US dollar.

Simulated results are hypothetical. They include only the fee and slippage you set on the bot, not every real-world cost or market condition, and past performance does not guarantee future results. Nothing here is financial advice.