sabyasachi27

SMA corssover strategy

NIFTY
The script is called "SMA Crossover Strategy" and is an indicator that uses two Simple Moving Averages (SMA) with different lengths to generate buy and sell signals. The script has two user inputs, "Short MA Length" and "Long MA Length" that allow the user to set the lengths of the two moving averages. The short moving average is plotted in green, while the long moving average is plotted in red.

The script uses the sma() function to calculate the short and long moving averages, and the plot() function to display them on the chart. The if-else statements generate the buy and sell signals based on the crossover of the two moving averages. If the short moving average crosses above the long moving average, a long position is entered, and if the short moving average crosses below the long moving average, a short position is entered.

It is worth noting that this is a basic example, and you should always do your own research and testing before making any trades.

EXPLANATION :-

The Simple Moving Average (SMA) Crossover strategy is a technical analysis strategy that uses moving averages to identify potential buy or sell opportunities in the market. Here is a step-by-step explanation of how the strategy works:

Step 1: Identify the stock or asset you want to trade. The strategy can be applied to any stock or asset that is traded on a public exchange.

Step 2: Select the time frame for the analysis. The length of the time frame will depend on the research question and the objectives of the analysis, it could be short term or long term.

Step 3: Choose the moving average lengths. The strategy typically uses a short-term moving average and a long-term moving average. The length of the moving averages will depend on the research question and the objectives of the analysis. Commonly used lengths are 50 and 200 days moving averages.

Step 4: Plot the moving averages on the chart of the stock or asset. The short-term moving average will be plotted on top of the long-term moving average.

Step 5: Identify the crossover points. When the short-term moving average crosses above the long-term moving average, it is a bullish signal, indicating that the stock or asset is likely to rise in value. Conversely, when the short-term moving average crosses below the long-term moving average, it is a bearish signal, indicating that the stock or asset is likely to decrease in value.

Step 6: Take action based on the crossover points. If the short-term moving average crosses above the long-term moving average, it is a signal to buy. If the short-term moving average crosses below the long-term moving average, it is a signal to sell.
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?