stratester.com

Actions · action block

Sell a percentage of the position

The sell % action sells a share of the BTC the bot currently holds: at market, at the close of the candle where the rule fired, or with a limit or stop order. sell 100% closes the position.

How the engine evaluates it

The quantity sold is X% × BTC held when the sell fills. At market the fill price is the close less slippage, or the level of a wick-triggered P&L condition in the same rule. 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.

When the position reaches zero the round trip is complete: it counts as a win if the proceeds after fees beat the total cost including fees, and the average entry resets.

Formula
BTC sold = held × X / 100
notional = BTC sold × fill price
fee paid = notional × fee
cash received = notional − fee paid
market fill = close × (1 − slippage)

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 100%
sell 50%
sell 100% limit 3%
sell 100% stop 2% expires 24

Settings

SettingValuesDefaultNotes
Percent of position0 – 100%100%Of the BTC held when the sell fills.
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

  • Full exits: sell 100%.
  • Scaling out: sell 50% at a first target, sell 100% at a second.
  • Resting take profit: sell 100% limit 3% waits for price to trade 3% above the signal close.

Example bot

botscript
bot "Two Targets"

when pnl up 4%
then sell 50%

when pnl up 8% or pnl down 3%
then sell 100%

when breakout high 24
then buy 100%
  • Sells half at +4%.
  • Sells the rest at +8%, or everything at −3%.
  • Enters on a 24-candle breakout.

Pitfalls

  • sell 50% twice leaves 25% of the original position.
  • Win rate counts complete round trips, not individual sells.

Sell %: frequently asked questions

Can a bot sell more than it holds?

No. Bots are long-only and sells are capped at the position.

When is a trade counted as a win?

When the position is fully closed and the total received from sells, after fees, exceeds the total spent on buys, fees included, in that round trip.

What happens to the average entry after a partial sell?

It stays the same. It only resets when the position is fully closed.

Are fees deducted?

Yes. The fee set on the bot comes out of the sale proceeds, and market and stop sells also pay its slippage.

What if the position is gone when a sell order fills?

The size is worked out when the order fills. If the bot holds nothing by then, the order is used up without a trade.

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.