Sidechair

strategy.default_entry_qty()

Browse the reference

The order quantity the strategy's default sizing would give for a fill at a chosen price.

Try it in the editor

strategy.default_entry_qty(fill_price) applies default_qty_type and default_qty_value from the strategy() header to the current equity and to fill_price. With a fixed quantity it returns that quantity; with strategy.percent_of_equity or strategy.cash it divides the allotted money by the price.

A market entry fills at a price you cannot know when the order is placed, so the default sizing handles it. For a limit or stop entry the price is known up front, and this function lets you reproduce the default sizing for that price and pass it as qty.

Syntax

Pine Script
strategy.default_entry_qty(fill_price: series int/float) -> series float

Arguments

NameTypeDefaultDescription
fill_priceseries int/floatrequiredThe price the order is expected to fill at; the default quantity is worked out for this price.

Returns

series float: The quantity strategy.entry would use at that price under the strategy's default sizing.

Remarks

  • It follows the same rounding and point value rules as an entry with no qty argument.
  • The value depends on equity at the moment of the call, so it changes as the strategy wins and loses.

Example

Pine ScriptSize a limit order with the default ruleOpen in editor
//@version=6
strategy("Dip buy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10)
dip = ta.lowest(low, 10)
if barstate.isconfirmed and close > open
    strategy.entry("Dip", strategy.long, qty = strategy.default_entry_qty(dip), limit = dip)
plot(dip, "10-bar low", color.red)

See also

Runs on Sidechair