OPEN-SOURCE SCRIPT

SMA

SMA Indicator
This indicator is designed to help traders make informed decisions by identifying buy and sell signals using three key Simple Moving Averages (SMAs): 200-day, 50-day, and 20-day. It also tracks the actual number of calendar days between buy and sell signals, as well as the percentage gain or loss for each trade. The indicator visually plots key moments on the chart, helping traders with trend analysis, entry/exit points, and strategy backtesting.


Three Simple Moving Averages:

200-day SMA: A widely used long-term trend indicator plotted in black.
50-day SMA: A mid-term trend indicator plotted in red.
20-day SMA: A short-term trend indicator plotted in green.

Buy Signal: A buy signal is generated when the following conditions are met:
The current price is below the 200-day, 50-day, and 20-day SMAs.
The 200-day SMA is greater than the 50-day SMA, and the 50-day SMA is greater than the 20-day SMA. This condition signals a potential buying opportunity, indicating that the price may be undervalued relative to its moving averages.

Sell Signal: A sell signal is generated when the following conditions are met:
The current price is above the 200-day, 50-day, and 20-day SMAs.
The 200-day SMA is less than the 50-day SMA, and the 50-day SMA is less than the 20-day SMA. This condition signals a potential selling opportunity, indicating that the price may be overextended.
Percentage Gain/Loss Calculation:

The indicator automatically calculates the percentage gain or loss between the buy and sell points.
The percentage gain or loss is displayed as a label on the chart once the sell signal is triggered.

Days Between Buy and Sell:
The indicator calculates the exact number of calendar days between the buy and sell signals.
This allows traders to track the length of each trade and understand the time taken for each position to realize a profit or loss.
The number of days is displayed on the label alongside the percentage gain or loss.

Dynamic Label with Color Coding:
Green Label: Indicates a positive trade (profit/gain).
Red Label: Indicates a negative trade (loss).
The labels appear well above the candles to ensure they are not hidden behind price action, making it easy to visualize key data points.
How to Use:

Buy Opportunities: When a buy signal is triggered (green triangle), the price is expected to rise from a low point relative to the moving averages. This could be an ideal entry point for long trades.

Sell Opportunities: When a sell signal is triggered (red triangle), the price may have peaked and is expected to reverse. This could be an ideal exit point for locking in profits or minimizing potential losses.

Tracking Performance: After each sell signal, traders can view the number of days the trade was held and the percentage gain or loss directly on the chart. This allows for easy review of trade performance and decision-making based on historical data.

Ideal For:
Trend-following traders looking to identify long and short-term trends.
Traders who want to visualize and optimize entry/exit points based on moving averages.
Traders who prefer clear, data-driven insights such as days between trades and percentage gains or losses.
Backtesting strategies that involve buy and sell decisions based on key SMAs.

Disclaimer: This indicator is not a buy or sell recommendation. It is a tool designed to assist traders in their decision-making process based on historical data. Always conduct your own research and consider multiple factors before making any financial decisions.
educationalSimple Moving Average (SMA)
ashishsingh1331

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明