Screener – capturing three possible states?
Forums › ProRealTime English forum › ProScreener support › Screener – capturing three possible states?
- This topic has 8 replies, 2 voices, and was last updated 4 years ago by robdav.
Tagged: multiple signals, multiple states
-
-
03/18/2020 at 5:24 PM #122473
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
Screener capture three states1234567891011IF TimeAlertLong = 1 THENSignalAlert = 10ENDIFIF PriceAlertLong = 1 THENSignalAlert = SignalAlert + 10ENDIFIF PriceAlertLong = 1 AND TimeAlertLong = 1 THENSignalAlert = SignalAlert + 20ENDIF03/18/2020 at 6:31 PM #122489There you go, each 1 (true) will have its own position as well as each 9 (false). “99” means ALL conditions are false:
12345678910111213141516IF TimeAlertLong = 1 THENSignalAlert = 1elseSignalAlert = 9ENDIFIF PriceAlertLong = 1 THENSignalAlert = SignalAlert + 10elseSignalAlert = SignalAlert + 90ENDIFIF SignalAlert = 99 THENSignalAlert = 0EndifSCREENER[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”.
1 user thanked author for this post.
03/18/2020 at 7:54 PM #12249903/18/2020 at 9:45 PM #122509You 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
1 user thanked author for this post.
03/18/2020 at 9:47 PM #122510I am fine, just staying longer in front of my PC, so I have more time to reply 🙂
03/18/2020 at 10:01 PM #122515Thanks 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 🙁
03/19/2020 at 1:21 PM #122573Hi 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…
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253// Hardcoded variables// Can be either 0 or 2TimeAlertShort = 2PriceAlertShort = 0// Can be either 0 or 1TimeAlertLong = 0PriceAlertLong = 0// Short signals// 29 = Price// 92 = Time// 22 = Price & Time// 9 = no signalIF TimeAlertShort = 2 THENSignalAlert = 2ELSESignalAlert = 9ENDIFIF PriceAlertShort = 2 THENSignalAlert = SignalAlert + 20ELSESignalAlert = SignalAlert + 90ENDIF// Long signals// 19 = Price// 91 = Time// 11 = Price & Time// 99 = no signalIF TimeAlertLong = 1 THENSignalAlert = 1ELSESignalAlert = 9ENDIFIF PriceAlertLong = 1 THENSignalAlert = SignalAlert + 10ELSESignalAlert = SignalAlert + 90ENDIFIF SignalAlert = 99 THENSignalAlert = 0ENDIFRETURN SignalAlert as "Signal Alert"03/19/2020 at 2:01 PM #122579Your line 53 ahould read (you coded it as if it were an indicator):
1SCREENER[SignalAlert](SignalAlert as "99")Moreover when SHORT conditions are true, lines 40 and 46 will reset signal to 99.
This is the correct code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445// Hardcoded variables// Can be either 0 or 2TimeAlertShort = 2PriceAlertShort = 0// Can be either 0 or 1TimeAlertLong = 0PriceAlertLong = 0// Short signals// 29 = Price// 92 = Time// 22 = Price & Time// 9 = no signal// Long signals// 19 = Price// 91 = Time// 11 = Price & Time// 99 = no signalIF TimeAlertShort = 2 THENSignalAlert = 2ELSIF TimeAlertLong = 1 THENSignalAlert = 1ELSESignalAlert = 9ENDIFIF PriceAlertShort = 2 THENSignalAlert = SignalAlert + 20ELSIF PriceAlertLong = 1 THENSignalAlert = SignalAlert + 10ELSESignalAlert = SignalAlert + 90ENDIFIF SignalAlert = 99 THENSignalAlert = 0ENDIFSCREENER[SignalAlert](SignalAlert as "99")1 user thanked author for this post.
03/19/2020 at 2:35 PM #122584 -
AuthorPosts