zathura643

Color Changing Moving Average


Hello everybody!

I'm not much of a coder but I do make indicators for myself for fun sometimes and found this one super cool. Hope it helps!


Basically it's a moving average that changes colors based on the trend. How does it do it, you may ask? Simply put, it checks and makes sure that the open and close price is above the moving average, then it checks and sees if the 50-period RSI (length adjustable) is above 50. If both conditions are met, the moving average turns green. Simple as that.

If the price is below the moving average and the RSI is below 50, the moving average turns red.

If the price is above the moving average but the RSI is below 50, the line is grey and I advise to simply waiting for the trend direction to be decided. Likewise, if the price is below the moving average, but the RSI is above 50, the line is also grey.


This is NOT a comprehensive system, and the changing color of the moving average does not indicate a buy or sell signal. It simply indicates that the price is trending. You should use your own entry and exit strategy, such as the MACD , Wave Trend, Schaff Trend Cycle , etc.

As well, I would recommend waiting for confirmation of a trend change when the color changes, since in a range price can cross multiple times before deciding on the right direction.

The slope of the moving average can help too, since in a range the moving average is typically flat.

I would recommend using a fixed risk to reward ratio, to limit emotions. But, this would also help with a trend-following strategy due to the trend filter functionality.


The length of the moving average is adjustable, as well as the RSI period- though I wouldn't recommend selecting an RSI lower than 30 because it will whipsaw more. Disabling the EMA option will give you an SMA that does the same thing as the EMA . You can also disable the RSI filter and simply have a moving average that changes color when the price is above/below- but that's pretty boring, huh?


Anyways, hope this helps, happy trading everybody :)
Phát hành các Ghi chú: Fixed the offset function so it actually works
Phát hành các Ghi chú: Made the colors brighter
Phát hành các Ghi chú: Added alert condition
Phát hành các Ghi chú: Added Alert for when the line turns grey (MA Buy = line is green, MA Sell = line is red, and MA Cancel Buy/Sell = the line has turned grey)
Phát hành các Ghi chú: Changed demonstration ticker
Mã nguồn mở

Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?

Bình luận

VERY GOOD
Phản hồi
zathura643 padmakp050
@padmakp050, Thank you :)
Phản hồi
I tried the alerts on my paper trade bot, the Buy signal was on a perfect spot to buy, but when I added the sell alerts, the sell alert was triggered on the 2nd candle above the green line and it didn't the grey area. what could possibly be the reason for that ?
Phản hồi
TimmyXavier TimmyXavier
@TimmyXavier, so let's say it did buy in a good price and sold few seconds later like both are triggering almost the same time, I used this condition to sell:

alertcondition(out<open and out<close and rsi<50, title="MA Cancel Buy", message="Moving average has turned grey (from green)")
Phản hồi
zathura643 TimmyXavier
@TimmyXavier, Is it set up similar to this? https://photos.app.goo.gl/UjuSReJ2zPNKjwYW7

I managed to get the strategy tester to work like that https://photos.app.goo.gl/DEefe2TuQfoN6a5x6
Phản hồi
zathura643 zathura643
@zathura643, I also want to reiterate that this indicator is not meant to be a standalone indicator, it's meant to be used with other indicators. It's based off the RSI 50 cross strategy if you want to look into that.
Phản hồi
Beautiful indicator, thanks a lot. Wondering how can I add buy & sell alerts for the green moving average line !! I was trying to fiddle around with the code but an error occurred
Phản hồi
zathura643 TimmyXavier
@TimmyXavier, Thanks for your comment, I added it to the newest version!
Phản hồi
JPTradingWorld zathura643
@zathura643, Can you please share the newest version ?
Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Giới thiệu Tính năng Biểu đồ Trả phí Giới thiệu bạn Quy tắc Áp dụng Trung tâm Trợ giúp Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Blog & Tin tức Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Xu Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Tin nhắn riêng Trò chuyện Đăng xuất