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.
Script open-source

Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.

Vuoi usare questo script sui tuoi grafici?