RingsCherrY

How to use Leverage in PineScript

RingsCherrY 已更新   
I believe there are many friends who have been confused by the leverage problem of TradingView strategy, when backtesting, it is always unable to bring its own leverage, so it is impossible to do leverage sustained compounding, this key point, and many friends are looking forward to solve. In particular, the default_qty_value = 100, where 100 is the upper limit.

Here I have used the official RSI strategy for demonstration, using the qty to place orders. Through strategy.equity, leverage and close price, and rounding, directly calculate the specific number of contracts need to be opened.

I hope you can enjoy solving the leverage problem, and I look forward to your pointing out my problems and shortcomings to me. Thank you.
發布通知:
Margin settings have been added, but note that because of TradingView's restrictions, the margin rate must be set to a constant, so it is necessary for the user to change the leverage while modifying the margin rate.
The default leverage is 2 and the margin burst rate is 80%, which can be modified by yourself.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?