Using a variable in the screener ?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #97826 quote
    bewoke2
    Participant
    Average

    Hello Folks !

    Is it possible to use a variable in a screener ? let say for example I want to find gappers, my code will be something like:

    myGap = close[1]/open[0]
    
    if myGap > X then
    myResult = 1
    else
    myResult = 0
    endif
    
    screener(myResult)

     

    So when I launch my screener, I may use X as input (X = 1.1 for example for a gap of 10%), is this kind of manoeuvre possible with PRT ?
    Thanks !

    #97829 quote
    robertogozzi
    Moderator
    Master

    Yes.

    Replace last line with:

    screener[myResult]
    #97833 quote
    Vonasi
    Moderator
    Master

    bewoke2– Please always use the ‘Insert PRT Code’ button when posting any code as it makes it far more readable for everyone else. I have tidied up your post for you 🙂

    bewoke2 thanked this post
    #97933 quote
    bewoke2
    Participant
    Average

    It didn’t do quite as I want ! I think I wasn’t clear enough.
    Here is how “exactly” my code will like.

    myRSI = 0
    
    if Rsi[14](close) > X then
    myRSI = 1
    else
    myRSI = 0
    endif
    
    SCREENER(myRSI)

    So when I run the scanner, I should be able to input the variable “X” (65, 70, or 80…), it’s like having a global scanner for an RSI above a certain value.
    It is like making a function in C code which takes an input from the user before displaying the result.

    But now, I get “X” is not defined (which is true)

    Thanks!

    #97951 quote
    Vonasi
    Moderator
    Master

    It is not possible to have externally adjustable variables in a screener. You will need to manually modify the screener to change the value or set up multiple screeners one for each chosen value.

    bewoke2 thanked this post
    #97952 quote
    robertogozzi
    Moderator
    Master

    First, replace the last line with:

    screener[myResult]

    Then you will have to hard code X inside the code; screeners and strategies do not allow users to change data (only indicators can).

    bewoke2 thanked this post
    #97959 quote
    bewoke2
    Participant
    Average

    Thanks ! resolved.

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

Using a variable in the screener ?


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
bewoke2 @bewoke2 Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by bewoke2
6 years, 10 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 05/07/2019
Status: Active
Attachments: No files
Logo Logo
Loading...