strategy
Declares the script as a strategy (a backtest): the first statement instead of indicator(). strategy.* orders given on a bar fill from the next bar on the simulated account (market at the open, stops and limits when the bar reaches them).
strategy(title: const string, shorttitle: const string = na, overlay: const bool = false, precision: const int = na, max_lines_count: const int = 50, max_boxes_count: const int = 50, max_labels_count: const int = 50, initial_capital: const float = 1000000, default_qty_type: const string = "fixed", default_qty_value: const float = 1, pyramiding: const int = 0, commission_type: const string = "cash_per_contract", commission_value: const float = 0, slippage: const int = 0, process_orders_on_close: const bool = false, fill_model: const string = "touch", format: const string = na, scale: const string = na, explicit_plot_zorder: const bool = false, behind_chart: const bool = false, calc_bars_count: const int = na, max_polylines_count: const int = na, dynamic_requests: const bool = false, calc_on_every_tick: const bool = false, calc_on_order_fills: const bool = false, close_entries_rule: const string = na, margin_long: const float = na, margin_short: const float = na, risk_free_rate: const float = na, use_bar_magnifier: const bool = false, backtest_fill_limits_assumption: const int = na, currency: const string = na, calc_on_every_history_tick: const bool = false)
Parameters
titleconst string: The strategy's name, shown in the legend.shorttitleconst string: A shorter name (default: the title).overlayconst bool: true draws on the price pane, false in a new pane below.precisionconst int: Decimals shown for values; default is the symbol tick precision.max_lines_countconst int: Lines kept before the oldest are deleted (1 to 500).max_boxes_countconst int: Boxes kept before the oldest are deleted (1 to 500).max_labels_countconst int: Labels kept before the oldest are deleted (1 to 500).initial_capitalconst float: starting balance in dollarsdefault_qty_typeconst string: strategy.fixed (contracts), strategy.percent_of_equity or strategy.cashdefault_qty_valueconst float: per entry when strategy.entry gives no qty: contracts, percent of equity or dollars (default_qty_type)pyramidingconst int: entries allowed in one direction; 0 and 1 both mean onecommission_typeconst string: strategy.commission.cash_per_contractcommission_valueconst float: dollars per contract per sideslippageconst int: ticks against the strategy on market and stop fillsprocess_orders_on_closeconst bool: true: market orders fill at the close of the bar they are given on (with slippage); false: at the next openfill_modelconst string: "touch": a limit fills when price touches it (like Pine); "conservative": only when price trades a tick through itformatconst string: Accepted for scripts from Pine and ignored: values show with the script precision.scaleconst string: Accepted for scripts from Pine and ignored: the script uses the scale of its pane.explicit_plot_zorderconst bool: Accepted for scripts from Pine and ignored: it changes nothing on PROLYNT.behind_chartconst bool: Accepted for scripts from Pine and ignored: plots draw under the candles anyway; tables over them.calc_bars_countconst int: Accepted for scripts from Pine and ignored: the script runs on every loaded bar.max_polylines_countconst int: Accepted for scripts from Pine and ignored: polylines keep their own limit of 100.dynamic_requestsconst bool: Accepted for scripts from Pine and ignored: request.security still needs fixed symbols and timeframes at the top level.calc_on_every_tickconst bool: Accepted for scripts from Pine and ignored: orders are given at the bar close; on the chart the forming bar is drawn but trades fill from the next bar.calc_on_order_fillsconst bool: Accepted for scripts from Pine and ignored: the script does not run again after a fill inside a bar, so results can differ from Pine.close_entries_ruleconst string: Accepted for scripts from Pine and ignored: one netted position per symbol, closed as a whole (results differ from Pine with "ANY").margin_longconst float: Accepted for scripts from Pine and ignored: no margin calls are simulated.margin_shortconst float: Accepted for scripts from Pine and ignored: no margin calls are simulated.risk_free_rateconst float: Accepted for scripts from Pine and ignored: the report has no Sharpe ratio from it.use_bar_magnifierconst bool: Accepted for scripts from Pine and ignored: fills use the chart bars (or the exact fill bars the backtest is given).backtest_fill_limits_assumptionconst int: Accepted for scripts from Pine and ignored: limits fill by fill_model.currencyconst string: Accepted for scripts from Pine and ignored: amounts are in the symbol currency.calc_on_every_history_tickconst bool: Accepted for scripts from Pine and ignored: history runs once per bar.
Example
strategy("MA cross", overlay=true, commission_value=2.5, slippage=1)