Hello gentlemen,
I am testing a lot of things and I realize that I can not really code a need that looks pretty simple: change a variable compared to the dynamic value of another indicator.
An example is better than a long explanation, I put the code in question below:
if (averagetruerange[14](close)>50) or (averagetruerange[14](close)<40) then
VariableRSI=21
elsif (averagetruerange[14](close)<50) or (averagetruerange[14](close)>40) then
VariableRSI=51
endif
The code is not good because it does not give me the expected result at all.
If you had a solution to my problem, it would be great 😉
Thank you in advance for your help.
Excellent day.
Do not double post the same topic in different language.
This won’t earn you faster replies, while shattering info among related topics making that info harder to retrieve. Thanks.
Hello Roberto,
Ok, I understand. I just wanted to have more opinions (differents culture, differents point of view, maybe)
However, thank you for your advice.
I wish you a good day.
It works the way you wrote it, it returns data filtered as you asked. Try this indicator:
VariableRSI = 0
if (averagetruerange[14](close)>50) or (averagetruerange[14](close)<40) then
VariableRSI=21
elsif (averagetruerange[14](close)<50) or (averagetruerange[14](close)>40) then
VariableRSI=51
endif
RETURN VariableRSI
Atr is ALWAYS < 40 so line 2 will ALWAYS be true. If you switch lines 2 and 4 you’ll always get 51!
Thank you very much for you quick answer Roberto!
I see in your screenshot that it’s Daily Time you chose.
I wanted to add this indicator on 5 minutes or 15 minutes time. So ATR can be higher than 40, like DJ or DAX,…
And it’s when I add this indicator in “minutes” time that it’s not working. Values are not update at end of each bar.
Thank you again for yout help.
Have a good day.
Apart from using it on a different instrument and TF, there is something wrong in the logic, because, as I pointed out, because if you switch lines and get ALWAYS the opposit outcome it means conditions are not correct.
What do lines 2 and 4 mean, why did you write conditions almost identical, if in line 2 ATR is < 40 line, line 4 will NEVER be executed.
Maybe you wanted to use AND instead of OR? AND can replace OR in line 4, not in line 2.
Please tell me what you want to check exactly.
Hello Roberto,
Here are an image to show you exactly what I want to code 😉
Thanks you for your kind help
Have a perfect day
There you go
VariableRSI=21
if (averagetruerange[14](close)<50) AND (averagetruerange[14](close)>40) then
VariableRSI=51
endif
Tanks you very much Roberto, it works great!