2

While backtesting a pine strategy on tradingview I noticed that the docs allow to and use couple of options to set a leverage (just like you have on exchanges while trading futures/contracts).

Hence, as per the docs recommendations, I added the following parameters in the first line of the script (a.k.a strategy declaration) in order to use *2 leverage (200%):

strategy("Strategy", 
  overlay = true, 
  calc_on_every_tick=true, 
  max_bars_back = 1000, 
  max_lines_count = 400, 
  max_labels_count = 400, 
  process_orders_on_close=true, 
  default_qty_value=200, 
  default_qty_type=strategy.percent_of_equity, 
  initial_capital=2000, 
  precision=8
)

Nevertheless, when i look into performance summary and list of trades, I have the exact same results I had without leverage. For the record, if I open the strategy input panel manually, i see that everything seems to be correctly set up (% of equity, 200% of capital..)

Is it anything else I need in order to take leverage into account while backtesting?

Any input appreciated

Bjorn Mistiaen
  • 6,459
  • 3
  • 18
  • 42
gastngouron
  • 461
  • 1
  • 5
  • 15
  • 1
    Try to add the additional parameters: `, margin_long=50, margin_short=50` – Andrey D Dec 07 '21 at 14:15
  • Thanks a lot for taking the time to reply and come up with this working solution Andrey D. I'm upvoting your answer while looking a little deeper for what these magin_long/short values really stand for. Thank you again – gastngouron Dec 07 '21 at 14:30

0 Answers0