OPEN-SOURCE SCRIPT

MAD Ratio with Buy/Sell Signals

This code creates an indicator that generates Buy and Sell signals based on the Moving Average Distance (MAD) Ratio and the crossover/crossunder of two Simple Moving Averages (SMA). Here's a breakdown of what it does:

What the Indicator Shows:
Moving Averages:

21-day SMA (shortMA): Plotted in blue.
200-day SMA (longMA): Plotted in red.
These lines visually represent short-term and long-term trends in price.
Horizontal Reference Line:

A gray horizontal line at Ratio = 1 marks when the 21-day SMA and 200-day SMA are equal. This is the neutral point for the MAD ratio.
Buy and Sell Signals:

Buy Signal (Green Label):

Triggered when:
MAD Ratio > 1 (shortMA is greater than longMA, indicating upward momentum).
The 21-day SMA crosses above the 200-day SMA.
Displays a green "BUY" label below the price chart.
Sell Signal (Red Label):

Triggered when:
MAD Ratio < 1 (shortMA is less than longMA, indicating downward momentum).
The 21-day SMA crosses below the 200-day SMA.
Displays a red "SELL" label above the price chart.
Trend Analysis

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?


更多:

免责声明