Fedra_Algotrading

PnL and Buy & Hold Tracker

Fedra_Algotrading 已更新   
In this script I use a simple, not necessarily profitable, strategy of a cross of MAs to teach how to calculate and plot the PnL of each trade made by the indicator. I also show how to calculate the cumulative PnL of all trades and the Buy and Hold of the same period.
These calculations which are natively available in any strategy script, require a bit of resourcefulness to work in an indicator script.
It can be very useful to optimize parameters for the best performance of an indicator-based strategy.

I use variables to store the price of the asset at each buy signal to calculate the PnL with the closing price of that particular trade and another variable to store the price value of the first trade, which calculates the Buy and Hold percentage with the current price of the asset.

I plot the values of the trades in labels and the accumulated values in a table.
I also show how to calculate and plot the unrealized PnL of open trades.
發布通知:
Added Closed trades counter and win ratio to the backtest panel
發布通知:
Version 2.5
Fixed Profit ratio label

開源腳本

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

免責聲明

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

想在圖表上使用此腳本?