P
PipsGrowth

النقاط الرئيسية

الصعوبة:Beginner
الموثوقية:High
الفئة:trend
الأطر الزمنية:1H, 4H, Daily

Simple Moving Average (SMA)

trend📊 1H, 4H, Daily, Weekly

The SMA calculates the average price over a specific number of periods, smoothing out price data to identify trend direction.

المعادلة

Code
SMA = (P₁ + P₂ + P₃ + ... + Pₙ) / n

شرح تفصيلي

The Simple Moving Average (SMA) is one of the most fundamental technical indicators in trading. It calculates the arithmetic mean of prices over a specified period, creating a smoothed line that helps traders identify the overall trend direction.

**How It Works:** The SMA adds up the closing prices for a set number of periods and divides by that number. For example, a 20-period SMA adds the last 20 closing prices and divides by 20.

**Key Concepts:** - **Trend Direction**: Price above SMA = bullish, below = bearish - **Dynamic Support/Resistance**: SMAs often act as support in uptrends and resistance in downtrends - **Crossover Signals**: When a faster SMA crosses a slower SMA, it generates trading signals

**Popular SMA Periods:** - 20 SMA: Short-term trend - 50 SMA: Medium-term trend - 200 SMA: Long-term trend (institutional level)

المعاملات

Period
Default: 20
Number of bars to average
Source
Default: Close
Price data to use (Open, High, Low, Close)

📈 إشارات صعودية

Price crosses above SMA or faster SMA crosses above slower SMA

📉 إشارات هبوطية

Price crosses below SMA or faster SMA crosses below slower SMA

تطبيق بايثون

Using pandas-ta for SMA calculation with crossover detection

Python
import pandas_ta as ta
# Calculate SMA
df['SMA_20'] = ta.sma(df['close'], length=20)
df['SMA_50'] = ta.sma(df['close'], length=50)
df['SMA_200'] = ta.sma(df['close'], length=200)
# Generate crossover signals
df['golden_cross'] = (df['SMA_50'] > df['SMA_200']) & (df['SMA_50'].shift(1) <= df['SMA_200'].shift(1))
df['death_cross'] = (df['SMA_50'] < df['SMA_200']) & (df['SMA_50'].shift(1) >= df['SMA_200'].shift(1))

كود TradingView

JavaScript
//@version=5
indicator("SMA Strategy", overlay=true)
// Input parameters
fast_len = input.int(20, "Fast SMA")
slow_len = input.int(50, "Slow SMA")
// Calculate SMAs
fast_sma = ta.sma(close, fast_len)
slow_sma = ta.sma(close, slow_len)
// Plot
plot(fast_sma, "Fast SMA", color=color.blue)
plot(slow_sma, "Slow SMA", color=color.red)
// Crossover signals
bullish = ta.crossover(fast_sma, slow_sma)
bearish = ta.crossunder(fast_sma, slow_sma)
plotshape(bullish, style=shape.triangleup, location=location.belowbar, color=color.green)
plotshape(bearish, style=shape.triangledown, location=location.abovebar, color=color.red)
📊 استخدم TradingView للرسوم البيانية المتقدمة
أدوات تحليل احترافية مع أكثر من 100 مؤشر فني
احصل على TradingView Pro

كود MT5

C++
// MQL5 SMA Indicator Access
int sma_handle = iMA(_Symbol, _Period, 50, 0, MODE_SMA, PRICE_CLOSE);
double sma[];
ArraySetAsSeries(sma, true);
CopyBuffer(sma_handle, 0, 0, 3, sma);
// Current SMA value
double current_sma = sma[0];
// Check price vs SMA
bool above_sma = iClose(_Symbol, _Period, 0) > current_sma;

أخطاء شائعة

Using SMA in ranging/choppy markets leads to whipsaws
Relying solely on SMA without confirmation from other indicators
Using too short periods in volatile markets
Ignoring the lag inherent in moving averages

إشارات التأكيد

Volume spike on crossover
RSI confirming momentum direction
Price breaking key support/resistance
Multiple timeframe alignment

الأفضل لـ

Trend identificationSupport/resistance levelsCrossover strategies

💡 نصائح احترافية

  • SMA lags price action - better for confirming trends than predicting them
  • Use multiple SMAs (e.g., 20, 50, 200) for stronger confirmation
  • Works best in trending markets, generates false signals in ranging markets
آخر تحديث: ٢٩ ديسمبر ٢٠٢٤

إخلاء مسؤولية تعليمي

هذا المحتوى للأغراض التعليمية فقط ولا يُعد نصيحة مالية أو استثمارية. التداول ينطوي على مخاطر كبيرة وقد تفقد رأس مالك. استشر مستشارًا ماليًا مرخصًا قبل اتخاذ أي قرارات استثمارية.

الأسئلة الشائعة