How to calculate RSI2 at a price

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #81210 quote
    VonasiVonasi
    Moderator
    Master

    I’m trying to calculate what the value of RSI[2] would be if on the next bar price had dropped to a certain value.

    I’ve tried several ideas but nothing seems to return the correct values. Anyone know how to do this?

    #81213 quote
    NicolasNicolas
    Keymaster
    Legend

    You can try to reverse engineer the RSI or start from this version: RSI Reverse Engineering indicator

    #81267 quote
    VonasiVonasi
    Moderator
    Master

    I’ve reverse engineered the reverse engineered RSI indicator!… and I think I have something that works. In this code the value for RSI2 is returned if price is at the Average[2](Low).

    My plan was to have RSI2 based position sizing and buy on a pending order if price fell to the Average[2](low) so hopefully this can now be done. I’m sure there is most likely a more elegant solution to find this info but I’ll use this until someone else can tell me what that solution is.

    RSIPeriod = 2
    
    for i = 0 to 10000
    RSIRevValue = i/100
    
    REM Original RSI values
    RSIOri = RSI[RSIPeriod](close)
    UPOri = MAX(0, close - open) //higher close then previous
    DOWNOri = MAX(0, open - close) //lower close then previous
    upMAOri = wilderAverage[RSIPeriod](UPOri)
    downMAOri = wilderAverage[RSIPeriod](DOWNOri)
     
     
    REM Reversed Engineered RSI Value to Price
    RSRev = (100/((-1*RSIRevValue)+100))-1
     
    if RSIRevValue < RSIOri THEN
    upMARev = upMAOri*(1-(1/RSIPeriod))
    downMARev = upMARev/RSRev
    DOWNRev = (downMARev - (downMAOri * (1-(1/RSIPeriod))))/(1/RSIPeriod)
    RSIPriceRev = close - DOWNRev
    elsif RSIRevValue > RSIOri THEN
    downMARev = downMAOri*(1-(1/RSIPeriod))
    upMARev = downMARev*RSRev
    UPRev = (upMARev - (upMAOri * (1-(1/RSIPeriod))))/(1/RSIPeriod)
    RSIPriceRev = close + UPRev
    endif
    
    if RSIPriceRev >= average[2](low) then
    myRSI = RSIRevValue
    break
    endif
    next
    
    //Dummy Trade
    if average[2] = -1 then
    buy at market
    endif
    
    graph myRSI
     
    

    [attachment file=”81268″]

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

How to calculate RSI2 at a price


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by VonasiVonasi
8 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/24/2018
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...