sma 9/20 crossThis Pine Script is designed to visualize the crossover between two Simple Moving Averages (SMAs) on a chart: a fast SMA (9-period) and a slow SMA (20-period). The script will dynamically adjust the background color based on whether the fast SMA is above or below the slow SMA.
Key Components of the Script:
Inputs for SMA Lengths:
The script allows you to adjust the lengths of the two SMAs by inputting values for smaFastLength (default = 9) and smaSlowLength (default = 20). These lengths define how many periods (candles) the SMAs consider when calculating the moving averages.
SMA Calculations:
The script calculates two SMAs using the close price:
smaFast is the 9-period SMA.
smaSlow is the 20-period SMA.
These are calculated using TradingView’s built-in ta.sma function, which computes the simple moving average for the given period.
Background Color Logic:
The background color is dynamically updated based on the crossover condition:
Green background: When the fast SMA (smaFast) is above the slow SMA (smaSlow), indicating a bullish trend.
Red background: When the fast SMA is below the slow SMA, indicating a bearish trend.
The bgcolor function is used to change the background color on the chart. The transparency of the background color is set to 35% using color.new(color.green, 35) or color.new(color.red, 35).
Plotting the SMAs:
The two SMAs are plotted on the chart for visual reference:
The fast SMA is plotted in lime green (color.blue).
The slow SMA is plotted in red (color.red).
Sma-cross
sma 9/20 crossThis Pine Script is designed to visualize the crossover between two Simple Moving Averages (SMAs) on a chart: a fast SMA (9-period) and a slow SMA (20-period). The script will dynamically adjust the background color based on whether the fast SMA is above or below the slow SMA.
Key Components of the Script:
Inputs for SMA Lengths:
The script allows you to adjust the lengths of the two SMAs by inputting values for smaFastLength (default = 9) and smaSlowLength (default = 20). These lengths define how many periods (candles) the SMAs consider when calculating the moving averages.
SMA Calculations:
The script calculates two SMAs using the close price:
smaFast is the 9-period SMA.
smaSlow is the 20-period SMA.
These are calculated using TradingView’s built-in ta.sma function, which computes the simple moving average for the given period.
Background Color Logic:
The background color is dynamically updated based on the crossover condition:
Green background: When the fast SMA (smaFast) is above the slow SMA (smaSlow), indicating a bullish trend.
Red background: When the fast SMA is below the slow SMA, indicating a bearish trend.
The bgcolor function is used to change the background color on the chart. The transparency of the background color is set to 35% using color.new(color.green, 35) or color.new(color.red, 35).
Plotting the SMAs:
The two SMAs are plotted on the chart for visual reference:
The fast SMA is plotted in lime green (color.lime).
The slow SMA is plotted in red (color.red).
MA-KIRILDIM-SANAThis is a lower block indicator. It helps us to follow the moving average crosses in the lower section in a single indicator without adding any moving averages in the main window.
When MA1 breaks MA2 up, the background color turns green or otherwise, the background becomes red. If you want, you can follow the lines of moving averages in here.
Three averages can be used in the system.
- SMA(Simple Moving Average)
- EMA(Exponential Moving Average)
- WMA(Weighted Moving Average)
Thanks
SMA Cross Entry & Exit StrategyThis is a TradingView Strategy Script meaning you can't execute real trades using your exchange API connected to your TradingView account, it is designed for backtesting only
This is a basic backtesting script for charting the bullish and bearish cross of two user defined simple moving averages, select the cog next to the name of the script ON the price chart in the left hand corner. The script will print to the screen either "Long Entry" or "Short Entry" depending on the direction of the cross. The script using TradingView strategies will subsequently close the opposite of the position that is executed when the bullish or bearish cross occurs. Simply put, if you are short and a bullish cross occurs, your short trade will close and be logged in strategies and the long will fire. You can pyramid the long and short positions to continue entering as long as the trend doesn't flip. You will find this in the script settings. Since this script is for backtesting you can manually set the "backtesting range" for TradingView Strategies and firing the "Long Entry" and "Short Entry". This as well, is in the settings.
Notice: When the SMA cross occurs, you have to wait till the next candle before TradingView Strategy will print the "Long Entry" or "Short Entry" to the screen
TradingView - How To Use Strategies: www.tradingview.com
SMA Cross (Short X Long)Its a graph for detecting the SMA cross points.
When short SMA crosses the long SMA downside up it may be a buy signal and the opposite is may be a sell signal.
GoldenCross Strategy by ClefsphereGolden cross when 50SMA crosses 200SMA. Can be used for any market. Day time frame is ideal.