Advice on combining conditions
Forums › ProRealTime English forum › ProScreener support › Advice on combining conditions
- This topic has 47 replies, 3 voices, and was last updated 6 years ago by thetragiccircle.
-
-
10/22/2017 at 2:23 PM #50227
Hi Guys,
I am totally new to this and would appreciate some advice on how to build my scanner. I have “built” 2 scanners using the easy creation facility on ProScreener but would appreciate advice on how to combine both into the one scanner.
At the moment I have built one scanner with the conditions – Stochastic level above 80 on 1hr timeframe + MACD signal value>MACD value on 4hr timeframe…..ie I want this to signal when overbought (ie>80) on the 1hr when MACD indicator on 4hr timeframe is red over green. (ie to signal a 1hr pullback into potential resistance, into the direction of indicated MACD movement on the 4hr timeframe in order to short the market from 1hr chart)
The other scanner is the opposite, and has the conditions where Stochastic level moves below 20 on 1hr timeframe + MACD value>MACD signal value on 4hr timeframe…..ie I want this to signal when oversold (ie <20) on the 1hr when MACD indicator on 4hr timeframe is green over red. (to signal a 1hr pullback into potential support, into the direction of indicated MACD movement on the 4hr timeframe in order to go long in the market).
I hope I have explained myself fully, and would appreciate any advice to combine these 2 scanners into one, which will be set to scan the 1hour timeframe.
Many thanks.
David
10/22/2017 at 6:25 PM #50239I suggest that you post the code for your scanners so anyone can work on combining them rather than writing them from scratch.
Roberto
1 user thanked author for this post.
10/23/2017 at 7:36 AM #50269Thanks Roberto.
Is this the correct way to post code?..or a cut and paste into the post?
10/23/2017 at 7:40 AM #50272Cut & Past pleae, so we don’t have to rewrite it. Thanks.
1 user thanked author for this post.
10/23/2017 at 3:05 PM #50332Thanks Roberto, I appreciate your advice
As per the layout of the photos above, here is the 1hr Short code:
indicator1, ignored, ignored = CALL “Pro-OBS”
c1 = (indicator1 >= 80)indicator2 = MACDline[12,26,9](close)
c2 = (indicator2 <= 0)indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))
indicator4 = MACDline[12,26,9](close)
c3 = (indicator3 >= indicator4)SCREENER[c1 AND c2 AND c3] (Variation AS “%Chg prev bar”)
and here is the 1hr Long code:
indicator1, ignored, ignored = CALL “Pro-OBS”
c1 = (indicator1 <= indicator1)indicator2 = MACDline[12,26,9](close)
c2 = (indicator2 > 0)indicator3 = MACDline[12,26,9](close)
c3 = (indicator3 >= 0)SCREENER[c1 AND c2 AND c3] (null AS “null”)
For return of results, is it possible to add prefix – to a short? (ie minus)
Thank you very much, I really appreciate this
David
10/23/2017 at 4:35 PM #50338When posting code (be it a strategy, screener or indicator) you should use the “Insert PRT code” on the grey bar (identified by <>) when writing your post, to make your code easier to read.
This is the result of combining the two indicators, though you can only return ONE criteria and there’s no way to change the displayed data to tell between long and short.
12345678910111213141516// SHORTindicator1, ignored, ignored = CALL "Pro-OBS"c1 = (indicator1 >= 80)indicator2 = MACDline[12,26,9](close)c2 = (indicator2 <= 0)indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))indicator4 = MACDline[12,26,9](close)c3 = (indicator3 >= indicator4)//LONGindicator1a, ignored, ignored = CALL "Pro-OBS"c4 = (indicator1a <= indicator1)indicator2a = MACDline[12,26,9](close)c5 = (indicator2a > 0)indicator3a = MACDline[12,26,9](close)c6 = (indicator3a >= 0)SCREENER[(c1 AND c2 AND c3) OR (c4 AND c5 AND c6)] (Variation AS "%Chg prev bar")3 users thanked author for this post.
10/25/2017 at 9:26 AM #50445Thank you very much Roberto, I am grateful for your expertise and advise, and really appreciate everything you have done.
10/30/2017 at 7:53 PM #50958Hi Roberto,
Thanks again for joining both pieces of code together as per my last post, however it did not work as I had not included the references to different time frames.
I will again post the 2 “halves” of the screener below and would be obliged if you could again “join” them together as one please. I could`nt post both in the <> section above, so the code for the long signal below will be in a separate post
below this post
The first half is a short signal, when conditions are : 15 minute “ProOBS” (RSI) >80 + 60 min MACD (green) < 0 + 240 min MACD red signal line over green
The second half is a long signal, when conditions are : 15 min “ProOBS” <20 + 60 min MACD (green) > 0 + 240 min MACD green over red signal line
Short signal1234567891011121314151617181920// The following code is related to this timescale:15 minutesTIMEFRAME(15 minutes)indicator1, ignored, ignored = CALL "Pro-OBS"c1 = (indicator1 >= 80)// The following code is related to this timescale:1 hourTIMEFRAME(1 hour)indicator2 = MACDline[12,26,9](close)c2 = (indicator2 <= 0)// The following code is related to this timescale:4 hoursTIMEFRAME(4 hours)indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))indicator4 = MACDline[12,26,9](close)c3 = (indicator3 >= indicator4)// The following code is related to this timescale:DEFAULTTIMEFRAME(DEFAULT)SCREENER[c1 AND c2 AND c3] (Variation AS "%Chg prev bar")10/30/2017 at 7:54 PM #50959Long signal1234567891011121314151617181920// The following code is related to this timescale:15 minutesTIMEFRAME(15 minutes)indicator1, ignored, ignored = CALL "Pro-OBS"c1 = (indicator1 <= 20)// The following code is related to this timescale:1 hourTIMEFRAME(1 hour)indicator2 = MACDline[12,26,9](close)c2 = (indicator2 >= 0)// The following code is related to this timescale:4 hoursTIMEFRAME(4 hours)indicator3 = MACDline[12,26,9](close)indicator4 = ExponentialAverage[9](indicator3)c3 = (indicator3 >= indicator4)// The following code is related to this timescale:DEFAULTTIMEFRAME(DEFAULT)SCREENER[c1 AND c2 AND c3] (Variation AS "%Chg prev bar")10/30/2017 at 9:11 PM #50969In your first post you also did not include the Exponential Average in the LONG code. Now you have, but with the same relational operators as for the SHORT one and I left it unchanged (you may change it as you prefer).
Here’s the updated code (I changed the names for variables c4, c5 and c6, to match the ones in the first part of the code):
123456789101112131415161718192021222324// SHORTTIMEFRAME(15 minutes)indicator1, ignored, ignored = CALL "Pro-OBS"c1 = (indicator1 >= 80)TIMEFRAME(1 hour)indicator2 = MACDline[12,26,9](close)c2 = (indicator2 <= 0)TIMEFRAME(4 hours)indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))indicator4 = MACDline[12,26,9](close)c3 = (indicator3 >= indicator4)//LONGTIMEFRAME(15 minutes)indicator1a, ignored, ignored = CALL "Pro-OBS"c1a = (indicator1a <= indicator1)TIMEFRAME(1 hour)indicator2a = MACDline[12,26,9](close)c2a = (indicator2a > 0)TIMEFRAME(4 hours)indicator3a = ExponentialAverage[9](MACDline[12,26,9](close))indicator4a = MACDline[12,26,9](close)c3a = (indicator3 >= indicator4a)TIMEFRAME(default)SCREENER[(c1 AND c2 AND c3) OR (c1a AND c2a AND c3a)] (Variation AS "%Chg prev bar")1 user thanked author for this post.
10/31/2017 at 8:35 AM #51015Thanks again Roberto
10/31/2017 at 11:16 AM #51045Sorry, but these lines have to be changed.
line 15 should read:
1c1a = (indicator1a <= 20)line 22 should read:
1c3a = (indicator3a >= indicator4a)And, I want to point it out again, lines 11 and 22 share the same relational operators, which I assume is a logical error.
Sorry for the inconvenience, but modifying code with copy & paste may often lead to such errors.
1 user thanked author for this post.
10/31/2017 at 3:25 PM #51087Hi Roberto,
Thanks for that. I actually spotted these as soon as I saw the post this morning and changed them accordingly. Lines 11 and 22 are correct.
I have noticed some days ago when I was trying to learn this and experiment with code, that cutting and pasting tends to lead to automatic syntax errors, which I presume is something to do with Windows (not sure if this also happens on a MAC). I also found that I could not remove the errors from the coding box (as highlighted by the yellow triangle in the margin and a red character, usually a comma or bracket.). I found the only way to remove this was not to cut and paste, but to delete the whole box and input it manually character by character.
Anyway, it is all good and the screener is working perfectly. Thanks again Roberto, your assistance has been tremendous.
David
1 user thanked author for this post.
10/31/2017 at 4:20 PM #51095Syntax errors are only due to miswriting or miscopying code. If the code has been selected properly it cannot generate syntax errors, as far as I experienced so far.
Logic errors are easier to be made because when you write something (looking at the source code) you may easily notice those errors but copying a whole line will make you overlook those errors relying on the code you are just copying!
It was a pleasure to help you as well as other traders novice to programming PRT.
Have fun autotrading!
1 user thanked author for this post.
11/02/2017 at 11:07 AM #51276How to copy/paste codes from prorealcode forums (picture attached).. without weird syntax errors! 🙂
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on