Screener – capturing three possible states?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #122473 quote
    robdav
    Participant
    Veteran

    I’m trying to write a screener that can catch three possible states.

    They are:

    • Time signal only
    • Price signal only
    • Price & time signal together

    I want to be able to return one result which identifies which one it is but can only get two states.

    Is it possible, if so how? Could I capture six if need be?

    Thanks again

    Rob

    IF TimeAlertLong = 1 THEN
    SignalAlert = 10
    ENDIF
    
    IF PriceAlertLong = 1 THEN
    SignalAlert = SignalAlert + 10
    ENDIF
    
    IF PriceAlertLong = 1 AND TimeAlertLong = 1 THEN
    SignalAlert = SignalAlert + 20
    ENDIF
    
    #122489 quote
    robertogozzi
    Moderator
    Master

    There you go, each 1 (true) will have its own position as well as each 9 (false). “99” means ALL conditions are false:

    IF TimeAlertLong = 1 THEN
       SignalAlert = 1
    else
       SignalAlert = 9
    ENDIF
     
    IF PriceAlertLong = 1 THEN
       SignalAlert = SignalAlert + 10
    else
       SignalAlert = SignalAlert + 90
    ENDIF
    
    IF SignalAlert = 99 THEN
       SignalAlert = 0
    Endif
    SCREENER[SignalAlert](SignalAlert AS "11")

    the third signal is not needed, it is when the returned criterion is “11”, while the other two values can be “91” or “19”.

    robdav thanked this post
    #122499 quote
    robdav
    Participant
    Veteran

    Thanks Roberto.

    If I wanted to do the same but incorporate SHORT signals within the same screener (same principle applies, three possible states) is that possible?

    Hope you’re staying out of the way of this damn virus!

    #122509 quote
    robertogozzi
    Moderator
    Master

    You can use 2 and 20 for short signals, leaving 9 and 99 to have these combinations:

    • 99 = 0 = NO signal
    • 19
    • 91
    • 11
    • 29
    • 92
    • 22

    If both opposite signals can occur you might also have:

    • 12
    • 21
    robdav thanked this post
    #122510 quote
    robertogozzi
    Moderator
    Master

    I am fine, just staying longer in front of my PC, so I have more time to reply 🙂

    #122515 quote
    robdav
    Participant
    Veteran

    Thanks again Roberto

    I think I’m with you. I will work on this in the morning and share the alert code back just in case it’s helpful for anyone else in the future.

    Glad you’re staying out of the way of things. We aren’t quite in lock down here in the UK but the supermarket shelves were very bare earlier when we went out 🙁

    #122573 quote
    robdav
    Participant
    Veteran

    Hi Roberto

    I seem to have something wrong in my logic as I cannot get the short signals to activate at all. Can you help pelase?

    Thnaks agian, Rob

    I have converted the code to an indicator to help debug it…

    // Hardcoded variables
    
    // Can be either 0 or 2
    TimeAlertShort = 2
    PriceAlertShort = 0
    
    // Can be either 0 or 1
    TimeAlertLong = 0
    PriceAlertLong = 0
    
    // Short signals
    
    // 29 = Price
    // 92 = Time
    // 22 = Price & Time
    // 9 = no signal
    
    IF TimeAlertShort = 2 THEN
    SignalAlert = 2
    ELSE
    SignalAlert = 9
    ENDIF
    
    IF PriceAlertShort = 2 THEN
    SignalAlert = SignalAlert + 20
    ELSE
    SignalAlert = SignalAlert + 90
    ENDIF
    
    // Long signals
    
    // 19 = Price
    // 91 = Time
    // 11 = Price & Time
    // 99 = no signal
    
    IF TimeAlertLong = 1 THEN
    SignalAlert = 1
    ELSE
    SignalAlert = 9
    ENDIF
     
    IF PriceAlertLong = 1 THEN
    SignalAlert = SignalAlert + 10
    ELSE
    SignalAlert = SignalAlert + 90
    ENDIF
     
    IF SignalAlert = 99 THEN
    SignalAlert = 0
    ENDIF
    
    RETURN SignalAlert as "Signal Alert"
    #122579 quote
    robertogozzi
    Moderator
    Master

    Your line 53 ahould read (you coded it as if it were an indicator):

    SCREENER[SignalAlert](SignalAlert as "99")

    Moreover when SHORT conditions are true, lines 40 and 46 will reset signal to 99.

    This is the correct code:

    // Hardcoded variables
     
    // Can be either 0 or 2
    TimeAlertShort = 2
    PriceAlertShort = 0
     
    // Can be either 0 or 1
    TimeAlertLong = 0
    PriceAlertLong = 0
     
    // Short signals
     
    // 29 = Price
    // 92 = Time
    // 22 = Price & Time
    // 9 = no signal
    
    // Long signals
     
    // 19 = Price
    // 91 = Time
    // 11 = Price & Time
    // 99 = no signal
    
    IF TimeAlertShort = 2 THEN
       SignalAlert = 2
    ELSIF TimeAlertLong = 1 THEN
       SignalAlert = 1
    ELSE
       SignalAlert = 9
    ENDIF
     
    IF PriceAlertShort = 2 THEN
       SignalAlert = SignalAlert + 20
    ELSIF PriceAlertLong = 1 THEN
       SignalAlert = SignalAlert + 10
    ELSE
       SignalAlert = SignalAlert + 90
    ENDIF
     
    IF SignalAlert = 99 THEN
       SignalAlert = 0
    ENDIF
     
    SCREENER[SignalAlert](SignalAlert as "99")
    robdav thanked this post
    #122584 quote
    robdav
    Participant
    Veteran

    Perfect, thanks again Roberto.

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

Screener – capturing three possible states?


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
robdav @robdav Participant
Summary

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

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/18/2020
Status: Active
Attachments: No files
Logo Logo
Loading...