Count confirmations on RSI cross

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #187226 quote
    bob320
    Participant
    New

    Hi, I’m trying to build an indicator that I can later use in a back test and auto trade that opens positions on the second occurrence of an RSI cross.

    So when the RSI crosses above 30 once, the indicator shows 1, then if it dips below and crosses above again (without going above 70), it shows 2 (and I enter long).

    If the RSI crosses above 30 once, it show 1, then goes over 70 and crosses back down the indicator shows -1.

    Likewise in opposite direction entering short at -2. So I only want to open long when its crosses above 30 a second time and only open short when it crosses below 70 twice in a row without reaching below 30.

    Hope that makes sense?

    Thanks in advance

    #187260 quote
    JC_Bywan
    Moderator
    Master

    Hi, something like that, count is there for visual check, for easier visualisation of separate indicator lines, “result” is set at +0.5 for  when buy would occur or -0.5 for short entry

    myrsi=RSI[14](close)
    
    result=0
    if myrsi crosses over 30 and count=1 then
     count=2
     result=+0.5
    endif
    if myrsi crosses over 30 and count=0 then
     count=1
    endif
    if myrsi crosses over 70 and count>0 then
     count=0
    endif
    
    if myrsi crosses under 70 and count=-1 then
     count=-2
     result=-0.5
    endif
    if myrsi crosses under 70 and count=0 then
     count=-1
    endif
    if myrsi crosses under 30 and count<0 then
     count=0
    endif
    
    return count, result
    bob320 thanked this post
    #187272 quote
    bob320
    Participant
    New

    Excellent, just what I wanted, thank you

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

Count confirmations on RSI cross


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
bob320 @bob320 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by bob320
4 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/01/2022
Status: Active
Attachments: No files
Logo Logo
Loading...