Bar Index – Proscreener

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #50785 quote
    hamid1736
    Participant
    New

    Can anyone help me on this matter ? I have a problem of finding a way to rerun a bar index of highest or lowest criteria. For example I want to find out what is bar index of this statement?

    highest [250](rsi[14](close)).

    Is it possible to get the bar index of such statement. Just to make it clear, I want to know what is bar index that maximum or minimum RSI  happened in the last 250 bars?
    Thanks in advance for your help.
    Hamid

    #50792 quote
    Nicolas
    Keymaster
    Master

    This could be possible by making a loop through the last 250 periods to find the lowest low and highest high of the RSI:

    mrsi = rsi[14]
    hrsi = 0
    
    for i = 0 to 250 do 
     if mrsi[i]>hrsi then 
      hrsi=mrsi[i]
      hbar=barindex[i]
     endif
    next
    
    return hbar
    mrsi = rsi[14]
    lrsi = 10000
    
    for i = 0 to 250 do 
     if mrsi[i]<lrsi then 
      lrsi=mrsi[i]
      lbar=barindex[i]
     endif
    next
    
    return lbar

    Not tested, please give us feedback if these codes are working correctly.

    #50811 quote
    hamid1736
    Participant
    New

    Thank you for your reply. But I have tested this method before, But I don’t know why proscreener doesn’t accept any loop more than 100, it will give an error as infinite loop exit in the code. I want to write a code to find trend of rsi in rising or falling channel. For example something like the image attached. Below is the code I have done so far, sometime it will work fine sometime not. did you come with this idea before or do you have this kind of code?

     

    MinimumRsi=100
    meet=0
    For x=1 to 100 Do //loop through 100 bar to find Min Rsi
    IF rsi[14](close)[x] < MinimumRsi THEN
    MinimumRsi=rsi[14](close)[x]
    barNb=x
    ENDIF
    
    
    
    NEXT
    
    isBearish=0
    For x=1 to 20 Do // if first 20 bar RSI is less than 40 is bearish mode
    IF rsi[14](close)[x] < 40 THEN
    isBearish=1
    break
    ENDIF
    
    NEXT
    fail=1
    m=(rsi[14](close)[0]-MinimumRsi)/(0-barNb) //find equation of a line with two points y=mx+b m is slope and b is is the y-intercept.
    
    b=MinimumRsi-(barNb*m)
    
    FOR i=1 to barNb DO
    y=m*i+b
    IF y+0.1 > rsi[14](close)[i] AND y-0.1 < rsi[14](close)[i] THEN
    meet=meet+1
    
    ENDIF
    
    IF y -0.1 > rsi[14][i] THEN
    fail=0
    break
    ENDIF
    NEXT
    condition=0
    IF meet >=1 THEN
    condition=1
    ENDIF
    
    // if current stock rsi is close to the line
    
    SCREENER [condition AND fail AND isBullish]
    rsi-trendline.png rsi-trendline.png
    #50822 quote
    Nicolas
    Keymaster
    Master

    Test if barNb is superior to 0 prior of using it as the target of new loop at line 26 (not tested, first thing that come in mind now).

    #55622 quote
    maximus78
    Participant
    Senior

    Hello Hamid and Nicolas, i came to this post casually only now.

    To find the barindex of the highest[250] of RSI you can use this code:

    //RSI highest high BARINDEX
    myrsi = rsi[14]
    c1=myrsi>highest[250](myrsi)[1]
    if a then
    myindex=barindex
    endif
    barHH=barindex[0]-myindex
    return barHH

    When it gives you 0, it means the highest or lowest value of RSI is in the current bar.

    //RSI lowest low BARINDEX
    myrsi = rsi[14]
    c1=myrsi<lowest[250](myrsi)[1]
    if c1 then
    myindex=barindex
    endif
    barLL=barindex[0]-myindex
    return barLL

    I hope this can help you!

    Max

    matteo166 thanked this post
    #111956 quote
    matteo166
    Participant
    Junior
    Hello maximus78, your code is correct and working perfectly, thank you! I miss only one thing: how can I exclude from the calculation a certain number of latest bars? For example if I want to find the Bar Index of highest RSI of last 250 excluding last month (20 bars)? Thank you in advance Matteo
    #111958 quote
    robertogozzi
    Moderator
    Master
    ProScreen only supports the last 254 bars. Maximus78’s code should not work. It’s odd if it does!
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Bar Index – Proscreener


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
hamid1736 @hamid1736 Participant
Summary

This topic contains 6 replies,
has 5 voices, and was last updated by robertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 10/28/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...