PROTECTED SOURCE SCRIPT
MACD Support/Resistance(Ayhan)

1) Support/Resistance from MACD crosses (your blue/orange horizontal lines)
When MACD crosses DOWN (macdDown): it looks back ~5 bars and takes the highest high → saves it as a Resistance (orange horizontal line + diamond).
When MACD crosses UP (macdUp): it looks back ~5 bars and takes the lowest low → saves it as a Support (blue horizontal line + diamond).
So the blue line you circled is: a new Support level created right after a MACD UP cross.
2) Removes levels when they break
If price low goes below a Support level → “Support Broken” event, and that level is removed.
If price high goes above a Resistance level → “Resistance Broken” event, and that level is removed.
3) Finds nearest Support/Resistance + calculates risk/reward
From all active levels it finds:
Nearest Support below price (nearSup)
Nearest Resistance above price (nearRes)
Then it calculates:
Distance to each in %,
R/R for a long (buy) (stop at support, target at resistance),
Position size (lots) using account size + risk % per trade.
4) ADX (trend strength) + table
It calculates ADX (Wilder style) and shows Weak / Medium / Strong in the table.
5) Alerts (this is what you choose in TradingView)
Alert conditions included:
MACD Crossover Up
MACD Crossunder Down
New Support Created
New Resistance Created
Support Broken
Resistance Broken
In TradingView alarms, you select one of these under Condition.
6) ATF (if enabled)
ATF searches different periods, chooses the one with best fit (Pearson R), and draws:
A sloped midline + upper/lower channel, plus a small ATF table.
If you tell me which exact event should be your “BUY” (New Support? MACD UP? plus ADX filter?), I can align the alert to that logic and make the alert message clean (Telegram-ready if needed).
When MACD crosses DOWN (macdDown): it looks back ~5 bars and takes the highest high → saves it as a Resistance (orange horizontal line + diamond).
When MACD crosses UP (macdUp): it looks back ~5 bars and takes the lowest low → saves it as a Support (blue horizontal line + diamond).
So the blue line you circled is: a new Support level created right after a MACD UP cross.
2) Removes levels when they break
If price low goes below a Support level → “Support Broken” event, and that level is removed.
If price high goes above a Resistance level → “Resistance Broken” event, and that level is removed.
3) Finds nearest Support/Resistance + calculates risk/reward
From all active levels it finds:
Nearest Support below price (nearSup)
Nearest Resistance above price (nearRes)
Then it calculates:
Distance to each in %,
R/R for a long (buy) (stop at support, target at resistance),
Position size (lots) using account size + risk % per trade.
4) ADX (trend strength) + table
It calculates ADX (Wilder style) and shows Weak / Medium / Strong in the table.
5) Alerts (this is what you choose in TradingView)
Alert conditions included:
MACD Crossover Up
MACD Crossunder Down
New Support Created
New Resistance Created
Support Broken
Resistance Broken
In TradingView alarms, you select one of these under Condition.
6) ATF (if enabled)
ATF searches different periods, chooses the one with best fit (Pearson R), and draws:
A sloped midline + upper/lower channel, plus a small ATF table.
If you tell me which exact event should be your “BUY” (New Support? MACD UP? plus ADX filter?), I can align the alert to that logic and make the alert message clean (Telegram-ready if needed).
Mã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Telegram kanalımızdakı sinyaller ücretsizdir.
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ã được bảo vệ
Tập lệnh này được đăng dưới dạng mã nguồn đóng. Tuy nhiên, bạn có thể sử dụng tự do và không giới hạn – tìm hiểu thêm tại đây.
Telegram kanalımızdakı sinyaller ücretsizdir.
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.