Paul Boyd:
I'm trying to get a draw line to change colours - green when the line has a positive slope, red when the line slope is negative.
Not to thwart your learning by doing, but here's another coder's highly universal MA that changes colors.
Files:
AllAverages_v4.9_MT5.mq5
82 kb
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Fernando Carreiro #:
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Thanks Fernando - I was worried that my request was too basic to be considered a "technical indicator" - appreciate the move
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
Ryan L Johnson #:
No, not at all.... this indicator is fantastic, I'm just trying to do something that isn't covered in this one.Not to thwart your learning by doing, but here's another coder's highly universal MA that changes colors.
Saying that - I definitely figured out how to use the INDICATOR_COLOR_INDEX function so mission accomplished.
Thanks for your input - greatly appreciated
Cheers,
Paul
Files:
Working.png
34 kb

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I'm trying to get a draw line to change colours - green when the line has a positive slope, red when the line slope is negative. What I'm trying to achieve is essentially a multi coloured line drawn over the candles to indicate the change in a value over time.
I've tried both the DRAW_LINE and the DRAW_COLOR_LINE functions, but I can't get them to change just the segment - any changes to the colour changes the entirety of the line.
Here's a modified version of the code I've created to test (produces the same result as my more complicated indicator). This is the first time that I've tried to create a custom indicator so I'm hoping that it's something dumb or simple that I'm missing.
I've also included some screenshots to show how the whole line changes, rather than the line segment to make it a bit clearer.
What I'm trying to achieve is something like:
https://www.mql5.com/en/docs/customind/indicators_examples/DRAW_COLOR_LINE#:~:text=The%20example%20shows%20the%20feature%20of%20the%20%22color%22,is%20set%20new%20colors%20in%20a%20special%20array.