TradingView
OVARIDE
Jan 10, 2022 11:26 AM

Percentage Change Tool 

NEAR / TetherUSBinance

描述

Here is a script that will allow you to see the percentage change from any entry to the current price. You will manually enter the price you bought at in the indicator price menu. The indicator will calculate and display the percentage difference(change) between the buy price and current price, in REAL TIME.

See Screenshot (TOP_RIGHT) for indicator.

Double Click on the Yellow Block and insert your entry price. Click OK. Indicator will display percentage.

版本注释


Funtion
This indicator will allow you to see the percentage change between any entry price and current price of an asset. You will need to input the price of your entry from within the indicator menu. The indicator will then calculate and display the percentage difference(change) between the buy/sell price that you input and current price. The displayed percentage value will continue to update in REAL TIME.

How to use[

1. Add the indicator to your chart.
2. It will appear in the top-right of the screen.
3. Double-Click on the indicator to access the menu where you can input your entry price, change the text size or change where the indicator appears on the chart.
4. Once you input your entry price, the indicator should display a percentage value as shown in the sample images.

Added to this version
1. Ability to change indicator size and position.
2. Indicator only displays percentage within the same amount of decimals as the ticker.
3. Indicator changes color when value is positive (green) or negative (red).

版本注释

Script Rework by /bfr

BUG -

Colors do not change as scripted. This is a bug that is outside of the actual script.

Added menu item to choose color and transparency .See code notes.

版本注释

Fixed Bug that reversed color when value is positive/negative and changed randomly on any value over 1. The indicator will now appear green for all positive values and red for all negative values by default. Colors and transparency can be changed for short/long positions or to make it easier to see on custom charts.

版本注释

Updated formula with correct percentage increase formula.

版本注释

Corrected new code errors and updated the code to include the following -

- Percentage Multiplier built-in.
- Calculation now returns rounded off values to 4 decimal places.
- Arranged the input menu into groups

PLEASE SEND ME A MESSAGE IF THE CODE DOES NOT WORK!

评论
digitalhero
Hello, I have this error message "Set the "EntryPrice" price for "PCT" X ??? thanks
OVARIDE
@digitalhero, You should see a slider appear that you can move to set the EntryPrice. Alternatively, you can go into the settings of the indicator and input the EntryPrice manually.
halfbeerhalfhuman
Since there is no way to have multiple instances of this without dublicating the indicator x times.

I want to track price change over time from certain fixed events in time. For example FOMC minutes. I want to see how all my tickers moved since this event.

TLDR: Is there a way to have a formula to get the price at certain date, and time?

Thank you. <3
OVARIDE
@halfbeerhalfhuman, If you know what the price was at the time of the event, then you can just enter that price into the calculator manually. I don't see why this needs to be in the formula? You can use bar replay to go back in time and find the price at any particular event that you want to track. If you want to be able to get a close price of a particular point in time, it may require you to reference a timestamp and requestsecurity in Pine. Unfortunately this is above my Pine coding skill knowledge and will be something that you need to research on your own.
halfbeerhalfhuman
@OVARIDE,
I got it working.
The reason is i want to calclate percentage for every symbol after specific event in time.

EntryPriceD = input.time(timestamp("2024-01-03 11:00:00 GMT+1"), "Input Timestamp", confirm=true) f_get_timestamp_open_price(t) => start_date = time >= t first_bar = not start_date[1] and start_date ta.valuewhen(first_bar, open, 0) t = EntryPriceD EntryPrice = f_get_timestamp_open_price(t)


PriceC = input.color(color.rgb(143, 143, 143), "PriceColor", inline="colors", group="Color settings") plot(EntryPrice, color=PriceC)
OVARIDE
@halfbeerhalfhuman, not sure how this will work without using request.security
specificGMTTimestamp = input.time(defval = timestamp("20 Jul 2023 00:00 +0200") specificLocalTimestamp = specificGMTTimestamp + 2 * 60 * 60 closePriceAtTimestamp = request.security(syminfo.tickerid, "D", close[specificLocalTimestamp])


Something like this. You also must not forget to convert from UTC to GMT. GMT+2 used as an example. Please test this as I am just snipping code from other projects I am working with that use similar logic.
Seawater1
It is not working (???). I receive a message saying that the script contains an error…Thanks
OVARIDE
@Seawater1, Thank you! I have updated the code. There was some conflict in the indicator() line. Seems like TradingView changed how that line works. The code should be fine now.
Seawater1
@OVARIDE, thank you so much! it perfectly works now. Amazing tool! Thank you!!!
Horizon_Tradings
Absolutely Great solution and work!!!
I've been searching for a long time for a script that will display on the chart the daily change in % of the underlying ticker.

I tweaked 2 lines for that as follows:
Changed: EntryPrice = close[1]
Added (for displaying only 2 numbers after the decimal): Percent := int(Percent * 100) / 100

So many thanks again.
更多