对应外汇交易的Pine策略配置

Pine strategy configuration for corresponding to Forex trading

我想模拟一个交易策略,就像我在外汇上使用这个策略一样。

假设我有一个 1000 美元的账户,杠杆为 100。如果我没记错的话,它对应于 set :

initial_capital=1000

我将能够购买 100 000 个单位,对应于:

default_qty_value=100000

如果这两个设置正确,如果我想为每笔交易“冒险”20 美元,我应该将 default_qty_value 设置为等于 2000 吗? (确实,20$ 是我资本的 2%,那么 ( 2 / 100 ) * 100 000 = 2000 $ )

如果您使用 cash 进行交易,您需要将其设置为 20。

TSLA, 1D 上查看:

//@version=5
strategy("strategy.cash", overlay = true, default_qty_value = 20, default_qty_type = strategy.cash, initial_capital = 1000)

if bar_index == 0
    // As ‘qty’ is not defined, the previously defined values for the `default_qty_type` and `default_qty_value` parameters are used to enter trades, namely 20 units of cash in the currency of `strategy.account_currency`.
    // `qty` is calculated as (default_qty_value)/(close price). If current price is , then qty = 20/5 = 4.
    strategy.entry("EN", strategy.long)
    
if bar_index == 100
    strategy.close("EN")

其他类型是strategy.fixed and strategy.percent_of_equity