TradingView
dreamalittle
4 de Mai de 2023 05:05

Manual PnL (Profit and Loss) % Tracker - spot long only 

Bitcoin / TetherUSBinance

Descrição



This is a manual profit and loss tracker. It takes the user's manual input of total cost and quantity, and then outputs a table on the bottom right of the chart showing the profit or loss %, average purchase price, gross profit or loss, and market value.

Instructions:

1. Double click the indicator title at the top left of the chart
2. Select the "Inputs" tab and click the empty field next to "Symbol" to enter the traded symbol+exchange. This entry MUST be the same as the chart you are on, for example BTCUSDT/BINANCE (indicator will not display otherwise)
3. Enter the Total Cost and Qty of shares/coins owned
4. Optional - change positive or negative colors
5. Optional - under the "Style" tab, change the color of the average price (AVG) line

Note that for the average price (AVG) line to be shown/hidden you must enable/disable "Indicator and financials labels" in the scales settings.

For crypto or other tickers that have prices in many decimal places I would suggest, for the sake of accuracy, adjusting the decimal places in the code so that for prices under $1 you will display more info.

For example let's say you purchase x number of crypto at a price of 0.031558 you should change the code displaying "0.00" on line 44 to "0.000000"

This will ensure that the output table and plotted line will calculate an average price with the same number of decimals.
Comentários
dreamalittle
Modified version of RaenonX's PnL script.
pacifiedPython97816
The indicator is perfect, except it doesn't save the inputs. The inputs (symbol, total cost, etc.) reset to default, and the info panel goes away when TV is closed and reopened. Maybe its my system, but this is what's happening.
dreamalittle
@pacifiedPython97816, Interesting feedback. On my browser, and the separate app, it saves the inputs on any chart/ticker combo. You might have an issue with cookies or something. Have you tried their separate app? It's just a skinned browser, worth a shot.
pacifiedPython97816
@dreamalittle, Thank you for the response. Yes I am using a desktop version. I tried again, and had the same issue. It did keep the indicator 'open' on one of the symbols 'AMZN for example', the indicator was still visible in the upper left 'indicator area' of all the other symbol tabs, but not 'opened or active' on the chart. I open it to the input tab, and it showed the AMZN inputs in all the other symbols also. Ironically, I had a problem with one other profit trackers I tried. I also notice TV does not save my 'dark theme' upon closing. It reverts to the 'light theme'. It sounds like a problem on my end. I have a 'cleaner' program that may be messing this up upon closing. Thank you
CTDX
@dreamalittle, I have the same issue. I'm using Brave Browser. Awesome indicator otherwise. Any other alternative I may have to ensure it saves the inputs for each chart? maybe via code?
Mais