Fedra_Algotrading

PnL and Buy & Hold Tracker

Fedra_Algotrading Zaktualizowano   
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.
Informacje o Wersji:
Added Closed trades counter and win ratio to the backtest panel
Informacje o Wersji:
Version 2.5
Fixed Profit ratio label

Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?