@strategy decorator.
Some parameters are identical to those used in the @indicator decorator and serve the same purpose for both indicators and strategies. However, there are also specific parameters designed exclusively for strategies, such as those controlling commission and leverage, and other execution settings.
Parameters
Basic script parameters
These parameters work the same way as they do for regular indicators:abbrev_title— a short title for the strategyoverlay_main_pane— whether the strategy is overlaid on the main chart paneformat— specifies the format of the output values displayed on the chartprecision— sets the precision of the output values displayed on the chart
Strategy and backtesting parameters
These parameters are important for simulating realistic trading conditions and evaluating the performance of your strategy. They allow you to configure aspects like initial capital, transaction costs, and how orders are handled during strategy execution. Let’s first look at the general syntax for configuring strategy parameters, and then analyze each parameter separately. Common parameters syntax:initial_capital- the initial capital allocated for the strategy. If the strategy does not have enough money (and enough leverage) to execute an order, the order will be transferred to the REJECTED status. Write strategies so that they take into account your existing cash and the cost of securities. For example:
commission- defines the order execution commission for the strategy. It can be specified as a percentage of the order value (e.g., 0.2% is written as 0.002) or as a fixed amount per order.
leverage- the leverage applied to the strategy. If set to 1.0 (the default), the strategy trades only with its own funds, without margin.
intrabar_order_filter- specifies the filter for intrabar orders.
market_order_price- determines the price for market orders.
risk_free_rate- the risk-free rate used in statistics calculations. This only affects the calculation of statistics (Sharpe ratio), but not the operation of the strategy.
UI configuration
The parameter values specified in the code will be the default values for your strategy. All these parameters can be configured not only in code but also through the UI before launching the strategy.