Dynamic variable change according to an indicator
Forums › ProRealTime English forum › ProBuilder support › Dynamic variable change according to an indicator
- This topic has 8 replies, 2 voices, and was last updated 6 years ago by fxbravo.
-
-
11/26/2018 at 12:17 PM #85720
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:
12345if (averagetruerange[14](close)>50) or (averagetruerange[14](close)<40) thenVariableRSI=21elsif (averagetruerange[14](close)<50) or (averagetruerange[14](close)>40) thenVariableRSI=51endifThe 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.
11/26/2018 at 12:34 PM #85721Do 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.
11/26/2018 at 12:43 PM #8572211/26/2018 at 12:49 PM #85723It works the way you wrote it, it returns data filtered as you asked. Try this indicator:
1234567VariableRSI = 0if (averagetruerange[14](close)>50) or (averagetruerange[14](close)<40) thenVariableRSI=21elsif (averagetruerange[14](close)<50) or (averagetruerange[14](close)>40) thenVariableRSI=51endifRETURN VariableRSIAtr is ALWAYS < 40 so line 2 will ALWAYS be true. If you switch lines 2 and 4 you’ll always get 51!
11/26/2018 at 12:57 PM #85725Thank 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.
11/26/2018 at 1:32 PM #85733Apart 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.
11/26/2018 at 3:45 PM #8575011/26/2018 at 4:44 PM #85754There you go
1234VariableRSI=21if (averagetruerange[14](close)<50) AND (averagetruerange[14](close)>40) thenVariableRSI=51endif11/29/2018 at 3:08 PM #85998 -
AuthorPosts
Find exclusive trading pro-tools on