
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
I have an indicator made in Pine Editor, for Trading View. and i want to make the same for MQL5 MT5. and i have a question and see if someone can aid me...
This is how it looks like in Pine Editor in the attachment,
as you can see when a strong movement appears and gets over level 70, it turns RED. if it goes past it into 80, it turns YELLOW.
If it goes below 30, it turns GREEN. If it's strong enough to go into 20, it turns CYAN.
Now take a look, it doesn't stay green above 70, just when it rises. Once it's coming back it's blue again. This effect i really like. Same for under 30, once it goes back up it turns blue.
In Between 30-70, it's a regular blue. Sometimes when a really strong movement happens it turns into color even if it's inside 30-70 range.
I've already have added the lines 20, 30, 40, 50, 60, 70, 80 with their proper color to identify quickly what's going on.
But i want to duplicate this into MQL5 language. In PINE EDITOR, it looks like this the code to change color when RSI data is above/below certain value.
#######
if rsi >= 71 and rsi >= rsi[1]
clr := #ff0000ff
if rsi >= 71 and rsi <= rsi[1]
clr := #ff0000ff
if rsi <= 29 and rsi <= rsi[1]
clr := #00ff00ff
if rsi <= 29 and rsi >= rsi[1]
clr := #00ff00ff
if rsi >= 78
clr := #ffff00ff
if rsi <= 22
clr := #00ffffff
plot(rsi, color=clr, linewidth = 2)
##########
Very simple code, MQL5 looks more complicated.
How can i do that? So far, the only way i've found to change color of RSI is like this
https://www.thewaveacademy.net/wp-content/uploads/rsi2.jpg
These codes above successfully adds the horizontal lines as i want them to appear. Check Screenshot 2
But the RSI value doesn't change color depending on where it is.
The code i found made it blend/fade into multiple colors, i could only separate the code to make it green below 50, red above 50.
This is the part responsible of adding color, and i have no idea why it's using i<=25, i+25, etc.
The logic is this:
IF RSI is above 70, turn red. If above 80, turn yellow.
IF RSI is below 30, turn green. if below 20, turn cyan.
Can someone help me code this? i know it's simple, but i'm new to this language.
Thanks!
FULL CODE BELOW ▼