zathura643

Color Changing Moving Average

zathura643 ที่อัปเดต:   

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 :)
เอกสารเผยแพร่:
Fixed the offset function so it actually works
เอกสารเผยแพร่:
Made the colors brighter
เอกสารเผยแพร่:
Added alert condition
เอกสารเผยแพร่:
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)
เอกสารเผยแพร่:
Changed demonstration ticker
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?