Dynamic variable change according to an indicator

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #85720 quote
    fxbravo
    Participant
    Average

    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:

    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.

    #85721 quote
    robertogozzi
    Moderator
    Master

    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.

    #85722 quote
    fxbravo
    Participant
    Average

    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.

    #85723 quote
    robertogozzi
    Moderator
    Master

    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!

    #85725 quote
    fxbravo
    Participant
    Average

    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.

    #85733 quote
    robertogozzi
    Moderator
    Master

    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.

    #85750 quote
    fxbravo
    Participant
    Average

    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

    #85754 quote
    robertogozzi
    Moderator
    Master

    There you go

    VariableRSI=21
    if (averagetruerange[14](close)<50) AND (averagetruerange[14](close)>40) then
       VariableRSI=51
    endif
    #85998 quote
    fxbravo
    Participant
    Average

    Tanks you very much Roberto, it works great!

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Dynamic variable change according to an indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
fxbravo @fxbravo Participant
Summary

This topic contains 8 replies,
has 2 voices, and was last updated by fxbravo
7 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/26/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...