OPEN-SOURCE SCRIPT
Cập nhật Multi MA (Daily/Weekly Source TF)

# Multi MA (Daily/Weekly Source TF)
Multi MA (Daily/Weekly Source TF) is a flexible multi-timeframe moving average indicator built for traders who want one MA system for daily and non-weekly charts, and a different MA system for weekly charts, without constantly changing settings by hand. Each line can be configured independently for type, length, source, source timeframe, visibility, color, and width, making it possible to track daily-based structure on higher timeframes while keeping a separate weekly trend framework inside the same script.
This script is a multi-moving-average indicator designed for traders who want different moving average configurations on daily charts and weekly charts, while still being able to display daily-based moving averages on higher timeframes such as monthly or yearly charts.
Traditional moving average indicators are usually limited to a single chart timeframe context. That creates a common workflow problem: the moving average set that makes sense on a daily chart is often not the same set you want on a weekly chart. As a result, traders end up manually changing inputs every time they switch timeframes.
This script solves that problem by allowing each moving average line to have independent settings for:
- Daily / non-weekly charts
- Weekly charts
In addition, each line can use its own source, moving average type, length, source timeframe, visibility settings, color, and width.
## What This Script Does
The indicator supports up to 10 moving average lines. For each line, you can configure:
- Daily type: `SMA` or `EMA`
- Daily length
- Daily price source
- Daily source timeframe
- Whether to show the line on daily / other non-weekly charts
And separately:
- Weekly type: `SMA` or `EMA`
- Weekly length
- Weekly price source
- Weekly source timeframe
- Whether to show the line on weekly charts
This means the same line can behave differently depending on whether the current chart is weekly or not.
## Core Idea
The script uses two logic layers:
1. Display logic based on the current chart timeframe
2. Calculation logic based on the selected source timeframe
When the current chart is weekly, the script uses the weekly configuration for that line.
When the current chart is anything other than weekly, the script uses the daily configuration for that line.
Because the moving averages are calculated using the selected source timeframe instead of the current chart timeframe alone, you can do things like:
- View a 5-day EMA on a monthly chart
- View a 200-day SMA on a yearly chart
- Use a different weekly structure without changing the daily structure
This is especially useful for traders who anchor their analysis on daily trend structure but still want to inspect that same structure from higher-level chart views.
## Example Use Case
A common setup might look like this:
On daily and other non-weekly charts:
- Line 1 = EMA 5-day
- Line 2 = EMA 9-day
- Line 3 = EMA 21-day
- Line 4 = SMA 50-day
- Line 5 = SMA 150-day
- Line 6 = SMA 200-day
On weekly charts:
- Line 4 = SMA 10-week
- Line 5 = SMA 30-week
- Line 6 = SMA 40-week
In this workflow:
- Daily charts show the shorter-term and long-term daily trend structure
- Weekly charts automatically switch to a cleaner higher-timeframe structure
- Monthly and yearly charts can still display daily-based moving averages if desired
## Why This Script Is Useful
This script is built to address several practical issues that appear in real trading workflows:
- Switching between daily and weekly charts often requires different MA systems
- Standard MA indicators usually force one configuration across all timeframes
- Higher timeframe charts often hide the daily structure traders still want to track
- Multiple indicators or repeated manual adjustments create clutter and inefficiency
By separating daily and weekly configurations per line, this script keeps your charting workflow more consistent and more efficient.
## Key Features
- Up to 10 moving average lines
- Per-line `SMA` / `EMA` selection
- Per-line daily and weekly lengths
- Per-line daily and weekly source price selection
- Per-line daily and weekly source timeframe selection
- Per-line daily and weekly visibility control
- Works on any chart timeframe
- Can display daily-based moving averages on higher timeframe charts
- Useful for multi-timeframe trend analysis
## How To Use
1. Set `Number of lines` to define how many moving average lines you want active.
2. For each active line, configure the daily / non-weekly settings:
- Daily Type
- Daily Length
- Daily Source Timeframe
- Daily Source
- Show On Daily/Other Charts
3. Configure the weekly settings for the same line:
- Weekly Type
- Weekly Length
- Weekly Source Timeframe
- Weekly Source
- Show On Weekly Charts
4. Adjust line color and width as needed.
## Intended Use
This indicator is best suited for:
- Multi-timeframe traders
- Trend-following systems
- Swing trading workflows
- Market structure analysis
- Traders who want daily and weekly moving average systems inside a single script
## Notes
- Weekly settings are only used when the current chart timeframe is weekly.
- All non-weekly charts use the daily configuration.
- Because the script can request data from a specific source timeframe, a moving average such as `EMA 5D` can still be displayed on monthly or yearly charts.
Multi MA (Daily/Weekly Source TF) is a flexible multi-timeframe moving average indicator built for traders who want one MA system for daily and non-weekly charts, and a different MA system for weekly charts, without constantly changing settings by hand. Each line can be configured independently for type, length, source, source timeframe, visibility, color, and width, making it possible to track daily-based structure on higher timeframes while keeping a separate weekly trend framework inside the same script.
This script is a multi-moving-average indicator designed for traders who want different moving average configurations on daily charts and weekly charts, while still being able to display daily-based moving averages on higher timeframes such as monthly or yearly charts.
Traditional moving average indicators are usually limited to a single chart timeframe context. That creates a common workflow problem: the moving average set that makes sense on a daily chart is often not the same set you want on a weekly chart. As a result, traders end up manually changing inputs every time they switch timeframes.
This script solves that problem by allowing each moving average line to have independent settings for:
- Daily / non-weekly charts
- Weekly charts
In addition, each line can use its own source, moving average type, length, source timeframe, visibility settings, color, and width.
## What This Script Does
The indicator supports up to 10 moving average lines. For each line, you can configure:
- Daily type: `SMA` or `EMA`
- Daily length
- Daily price source
- Daily source timeframe
- Whether to show the line on daily / other non-weekly charts
And separately:
- Weekly type: `SMA` or `EMA`
- Weekly length
- Weekly price source
- Weekly source timeframe
- Whether to show the line on weekly charts
This means the same line can behave differently depending on whether the current chart is weekly or not.
## Core Idea
The script uses two logic layers:
1. Display logic based on the current chart timeframe
2. Calculation logic based on the selected source timeframe
When the current chart is weekly, the script uses the weekly configuration for that line.
When the current chart is anything other than weekly, the script uses the daily configuration for that line.
Because the moving averages are calculated using the selected source timeframe instead of the current chart timeframe alone, you can do things like:
- View a 5-day EMA on a monthly chart
- View a 200-day SMA on a yearly chart
- Use a different weekly structure without changing the daily structure
This is especially useful for traders who anchor their analysis on daily trend structure but still want to inspect that same structure from higher-level chart views.
## Example Use Case
A common setup might look like this:
On daily and other non-weekly charts:
- Line 1 = EMA 5-day
- Line 2 = EMA 9-day
- Line 3 = EMA 21-day
- Line 4 = SMA 50-day
- Line 5 = SMA 150-day
- Line 6 = SMA 200-day
On weekly charts:
- Line 4 = SMA 10-week
- Line 5 = SMA 30-week
- Line 6 = SMA 40-week
In this workflow:
- Daily charts show the shorter-term and long-term daily trend structure
- Weekly charts automatically switch to a cleaner higher-timeframe structure
- Monthly and yearly charts can still display daily-based moving averages if desired
## Why This Script Is Useful
This script is built to address several practical issues that appear in real trading workflows:
- Switching between daily and weekly charts often requires different MA systems
- Standard MA indicators usually force one configuration across all timeframes
- Higher timeframe charts often hide the daily structure traders still want to track
- Multiple indicators or repeated manual adjustments create clutter and inefficiency
By separating daily and weekly configurations per line, this script keeps your charting workflow more consistent and more efficient.
## Key Features
- Up to 10 moving average lines
- Per-line `SMA` / `EMA` selection
- Per-line daily and weekly lengths
- Per-line daily and weekly source price selection
- Per-line daily and weekly source timeframe selection
- Per-line daily and weekly visibility control
- Works on any chart timeframe
- Can display daily-based moving averages on higher timeframe charts
- Useful for multi-timeframe trend analysis
## How To Use
1. Set `Number of lines` to define how many moving average lines you want active.
2. For each active line, configure the daily / non-weekly settings:
- Daily Type
- Daily Length
- Daily Source Timeframe
- Daily Source
- Show On Daily/Other Charts
3. Configure the weekly settings for the same line:
- Weekly Type
- Weekly Length
- Weekly Source Timeframe
- Weekly Source
- Show On Weekly Charts
4. Adjust line color and width as needed.
## Intended Use
This indicator is best suited for:
- Multi-timeframe traders
- Trend-following systems
- Swing trading workflows
- Market structure analysis
- Traders who want daily and weekly moving average systems inside a single script
## Notes
- Weekly settings are only used when the current chart timeframe is weekly.
- All non-weekly charts use the daily configuration.
- Because the script can request data from a specific source timeframe, a moving average such as `EMA 5D` can still be displayed on monthly or yearly charts.
Phát hành các Ghi chú
remove `linewidth` in every line settings. Phát hành các Ghi chú
Removed the color fields from the Inputs tab and kept color control only in the Style tab, so Style is now the single source of truth for line colors and no longer gets overridden by Inputs. Also performed a light internal refactor to reduce repeated MA calculation logic without changing the script’s behavior or UI.Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.