Whitebox Strategy Engine » Order Size Settings


Overview

The general way of configuring the size of each order is done via the Order Size input under the Properties tab of the strategy settings panel:

Properties Tab

This Properties tab is provided by TradingView automatically for all strategy scripts, and the settings therein is what the strategy uses by default to size each order it makes.

Unfortunately TradingView does not provide a way for you to configure how much of your equity you are willing to risk per trade. (The equity is the sum of the initial capital, net profit, and unrealised profit/loss).

We can work around this 'limitation' by creating our own setting for this, and ignore whatever the Order Size is set to under the Properties tab. By enabling the Activate Custom 'Order Size' Settings checkbox, you tell the strategy to ignore whatever is set in the Order Size input under the Properties tab, and instead use the Order Size settings provided below.

Settings

Each strategy script provides the following options for configuring a custom order size:

Custom Order Size Settings

Let's review each of these options one by one.

Order Size

The size of the order the strategy will use for each entry it makes.

  1. Contracts: Number of contracts/shares/lots/units to trade (e.g. setting this to 1 will result in the strategy buying/selling 1 BTC per order)
  2. Cash: The amount of cash to use from your equity per order (e.g. setting this to 1000 will result in the strategy buying/selling $1000 worth of BTC per trade)
  3. % of equity: The percentage of the strategy's equity to use per order (e.g. with an account size of $1000 and this set to 10, will result in the strategy buying/selling $100 worth of BTC per trade)
  4. % risk of equity: The percentage of your account size you want to risk per trade.
    For example, with an account size of $100,000, if you enter a trade at $1000 per unit with a take profit target set to $1200 and a stop loss target set to $900 (Risk/Reward 1:2), using 1.0% risk, will result in an order size of 10 units for a total value of $10,000. Why? Because 1.0% of your account size is $1000 (this is the money you are comfortable with risking per trade), and by buying 1 unit at $1000 with a stop loss set to $900, you are essentially risking $100 per each unit bought. $100 is 10 times less than the money you are willing to risk per trade ($1000), therefore you can buy 10 units to arrive to your risk of $1000 per trade (which is 1% of your account size).
  5. Fixed risk: The maximum amount of cash to risk on each trade (to learn more about how the position size is calculated, please see above)

All of these options are currency aware. For example, if you set order size to 1000, and you set the sizing type to Cash, if your account's currency is set to GBP, then the strategy will open positions in the value of £1000 (e.g. $1300) per order.

Order Sizing Mode

Imagine the following situation:

  • You are looking at the BTC/USD chart on a 1 hour time frame, with 1 Bitcoin trading for $50,000
  • Your initial capital is $10,000
  • You set % risk of equity to 1% (i.e. $100 of your account), or you set a Fixed risk of $100
  • The strategy signals a long entry at $50,000 with a stop loss set to $49,950 and the take profit set to $50,100 (Risk/Reward 1:2)
  • In order to open a position risking $100 of your account, you need to buy 2 Bitcoins. (If you were to buy 1 Bitcoin, the risk would be only $50, half of what your desired risk is)

In order to buy 2 Bitcoins, you need $100,000, but you only have $10,000 on your account. How do you want the strategy to proceed?

You have the following options:

  1. Allow infinitely large position size: The strategy will assume that you have access to more money than what you have on your account (i.e. via leverage), and it will open a position for 2 Bitcoins. Risk will be $100 (1% of your account size).
  2. Limit position value to account size: The strategy will assume that you don't have access to leverage, and it will open the biggest position you can afford ($10,000 / $50,000 = 0.2 BTC). Risk will be $10 (0.1% of your account size).
  3. Skip entry if can't afford desired position size: The strategy will assume that you don't want to enter into a position, if in order to meet your risk settings you would have to take on a position bigger than your account size.

Max. Allowed Risk

The maximum % of equity or Cash the strategy should risk on any given trade. When set to 0, this config is ignored.

Think of this as a safety net. If you use an order sizing mechanism that doesn't control the risk (such as % of equity), you are going to risk a random amount on each trade. However, if you configure a Max. Allowed Risk of 100 Cash for example, your position size will always be capped, so that you only risk at most $100 on each trade.

Max. Allowed Position Size

The maximum size of the position the strategy is allowed to take on any given order. When set to 0, this config is ignored.