tijan84

X% Drop in X Days, sold X Days after

tijan84 Updated   
It identifies potential buy signals based on a specified percentage drop in price over a set number of days and calculates the total profit or loss (P/L) over a predefined period. Here's a breakdown of the script and its key parameters:

Script Description:
Indicator Name: "X% Drop in X Days, sold X Days after"

Functionality:
The script signals a buy opportunity when the price of an asset drops by a certain percentage (percentage_drop) within a specified length (length) in days.
It calculates the profit or loss percentage after a set number of days (hold_days) from the buy signal.
The script also displays the cumulative total profit or loss over a specified time frame, from a start date (start_period) to an end date (end_period), which is by default set to the current date.
Display:
Buy signals are marked on the chart.
The profit or loss for each trade after the hold period is displayed.
A label showing the total cumulative profit or loss, along with the start and end dates, is displayed on the chart.
Key Parameters:
percentage_drop (10.0% by default): The percentage decrease in price that triggers a buy signal. It represents the threshold for the price drop to consider a buying opportunity.

length (3 days by default): The period over which the drop in price is considered. It's the timeframe used to evaluate the percentage drop.

hold_days (30 days by default): The duration for holding the asset after the buy signal before selling. This parameter defines the time after which the profit or loss is calculated.

start_period (Set to "2022-11-21" by default): The beginning date for calculating the cumulative total profit or loss. This parameter allows the user to define a specific starting point for the analysis.

end_period (Set to the current date by default): The end date for the cumulative total profit or loss calculation. It defaults to the current date but can be set to a specific date for backtesting purposes.

Script Mechanics:
Buy Signal Logic: A buy signal is generated when the closing price is below the highest price of the last 'length' days, adjusted by the 'percentage_drop'.
Profit/Loss Calculation: For each buy signal, the script calculates the profit or loss percentage after 'hold_days' from the purchase. This is displayed on the chart for each trade.
Total P/L Display: The script calculates and displays the cumulative total profit or loss in the defined period (from 'start_period' to 'end_period') in a label on the chart.
Usage:
This script is useful for traders who follow a strategy based on buying assets after significant price drops and holding for a predetermined period. It automates the detection of potential buy opportunities and the calculation of profit or loss, aiding in decision-making and performance analysis.
Release Notes:
It identifies potential buy signals based on a specified percentage drop in price over a set number of days and calculates the total profit or loss (P/L) over a predefined period. Here's a breakdown of the script and its key parameters:

Script Description:
Indicator Name: "X% Drop in X Days, sold X Days after"

Functionality:
The script signals a buy opportunity when the price of an asset drops by a certain percentage (percentage_drop) within a specified length (length) in days.

Key Parameters:
percentage_drop (5.0% by default): The percentage decrease in price that triggers a buy signal. It represents the threshold for the price drop to consider a buying opportunity.

length (3 days by default): The period over which the drop in price is considered. It's the timeframe used to evaluate the percentage drop.

hold_days (14 days by default): The duration for holding the asset after the buy signal before selling. This parameter defines the time after which the profit or loss is calculated.

start_period (Set to "2022-11-21" by default): The beginning date for calculating the cumulative total profit or loss. This parameter allows the user to define a specific starting point for the analysis.

end_period (Set to the current date by default): The end date for the cumulative total profit or loss calculation. It defaults to the current date but can be set to a specific date for backtesting purposes.

Script Mechanics:
Buy Signal Logic: A buy signal is generated when the closing price is below the highest price of the last 'length' days, adjusted by the 'percentage_drop'.
Profit/Loss Calculation: For each buy signal, the script calculates the profit or loss percentage after 'hold_days' from the purchase. This is displayed on the chart for each trade.
Total P/L Display: The script calculates and displays the cumulative total profit or loss in the defined period (from 'start_period' to 'end_period') in a label on the chart.
Usage:
This script is useful for traders who follow a strategy based on buying assets after significant price drops and holding for a predetermined period. It automates the detection of potential buy opportunities and the calculation of profit or loss, aiding in decision-making and performance analysis.
Release Notes:
It identifies potential buy signals based on a specified percentage drop in price over a set number of days and calculates the total profit or loss (P/L) over a predefined period. Here's a breakdown of the script and its key parameters:

Script Description:
Indicator Name: "X% Drop in X Days, sold X Days after"

Functionality:
The script signals a buy opportunity when the price of an asset drops by a certain percentage (percentage_drop) within a specified length (length) in days.

Key Parameters:
percentage_drop (5.0% by default): The percentage decrease in price that triggers a buy signal. It represents the threshold for the price drop to consider a buying opportunity.

length (3 days by default): The period over which the drop in price is considered. It's the timeframe used to evaluate the percentage drop.

hold_days (30 days by default): The duration for holding the asset after the buy signal before selling. This parameter defines the time after which the profit or loss is calculated.

start_period (Set to "2022-11-21" by default): The beginning date for calculating the cumulative total profit or loss. This parameter allows the user to define a specific starting point for the analysis.

end_period (Set to the current date by default): The end date for the cumulative total profit or loss calculation. It defaults to the current date but can be set to a specific date for backtesting purposes.

Script Mechanics:
Buy Signal Logic: A buy signal is generated when the closing price is below the highest price of the last 'length' days, adjusted by the 'percentage_drop'.
Profit/Loss Calculation: For each buy signal, the script calculates the profit or loss percentage after 'hold_days' from the purchase. This is displayed on the chart for each trade.
Total P/L Display: The script calculates and displays the cumulative total profit or loss in the defined period (from 'start_period' to 'end_period') in a label on the chart.
Usage:
This script is useful for traders who follow a strategy based on buying assets after significant price drops and holding for a predetermined period. It automates the detection of potential buy opportunities and the calculation of profit or loss, aiding in decision-making and performance analysis.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?