Variables with String data

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #61770 quote
    Patrik BorgPatrik Borg
    Participant
    Junior

    Hi,

    I’ve searched around manuals and this forum, and I fail to find an answer. Not finding how to do it, neither finding a confirmation that it’s not possible. So I turn to all you guys here for help.

    Is there a way to get a variable to hold a text string?

    I wrapped up some very simple example code. (just a sample to visualize my question, not an idea for a good scanner 😉

    With the bellow scanner, I would get a column in the proscreener window with the name “Bull or Bear”, and in the column the number 1 or 2 would show.

    Is there a way to get the variable “varBullOrBear” to hold a text string instead? I many other programming scenarios I would use varBullOrBear = “Bull”, and so forth, but it doesn’t seem to work in this language.

    I would like to display text info in the column in Proscreener instead of a number. Is it possible, if so, how?

    thanks in advance

     

     

     

    —————————

    condition1 = Average[100](close) > Average[200](close)
    condition2 = Average[100](close) < Average[200](close)

    if condition1 then
    varBullOrBear = 1
    endif

    if condition2 then
    varBullOrBear = 2
    endif

    screener [condition1 or condition2] (varBullOrBear as “Bull or Bear”)

    #61773 quote
    NicolasNicolas
    Keymaster
    Legend

    The way you have coded your screener is the best way to handle the 2 different results you look for. Variables can’t be text strings, only numbers.

    #61776 quote
    Patrik BorgPatrik Borg
    Participant
    Junior

    Thank for the very quick response!

    Even though it wasn’t the answer I wished for, I accept the limitation. 🙂

    #62657 quote
    Patrik BorgPatrik Borg
    Participant
    Junior

    A follow-up question using the same example above. I didn’t find any answer in the programming guide.

    Using the above example the sorting will always be high to low. Let’s say that I value the result “1” higher than “2”, then I obviously would like to show the 1’s on top of the list. Is there a way to reverse the sorting?

    thanks in advance

    #62694 quote
    NicolasNicolas
    Keymaster
    Legend

    To change the sorting you can:

    • modify your sorting criteria with any variable values
    • change the sorting order with the dedicated button in the proscreener window (right below the timeframe selection)
    #62707 quote
    Patrik BorgPatrik Borg
    Participant
    Junior

    Hi,

    I was more looking for a code way of doing it. You might have more than one scanner with different preferences, then it would be nice to be able to do it from the code.

    #62710 quote
    NicolasNicolas
    Keymaster
    Legend

    Well, sorting is only based on ascending or descending numeric value. You can also separate your screener into 2 different ones: a bullish one and a bearish one.

Viewing 7 posts - 1 through 7 (of 7 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

Variables with String data


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 02/06/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...