Screener ignores condition
Forums › ProRealTime English forum › ProScreener support › Screener ignores condition
- This topic has 14 replies, 2 voices, and was last updated 4 years ago by
robertogozzi.
-
-
07/26/2020 at 3:26 PM #140142
Hi Pro Real code community,
I have created the next simple screener:
12345678910111213141516171819/////////////////////////////////////////////TIMEFRAME(5 minutes)c2 = high >= ExponentialAverage[20](close)c3 = low[intradaybarindex] >= low[intradaybarindex-1] and high[intradaybarindex-1] >= high[intradaybarindex-2]Timeframe(30 minutes)c1 = DOpen(0) >= ExponentialAverage[20](close)c = c1 and c2 and c3/////////////////////////////////////////////SCREENER [ c ]The problem is that, with condition c3 in the code, the screener completely ignores condition c1. I know this because in the following code condition c1 is executed properly:
1234567891011121314151617/////////////////////////////////////////////TIMEFRAME(5 minutes)c2 = high >= ExponentialAverage[20](close)Timeframe(30 minutes)c1 = DOpen(0) >= ExponentialAverage[20](close)c = c1 and c2/////////////////////////////////////////////SCREENER [ c ]Any idea on how to make both c1 and c3 work at the same time?
Thank you for your attention.
Roberto.
07/26/2020 at 5:19 PM #140147I cannot test it, but the cause could be that [INTRADAYBARINDEX -n] may return a negative value and INTRADAYBARINDEX by itself could exceed the 254-bar limit of ProScreener, since 24 hours * 12 5-minute bars = 288 bars.
I also wonder why you are using DOPEN, since OPEN is available on a Daily TF.
07/26/2020 at 6:42 PM #140153To give you some context Roberto, what I try to do is to find those stocks (not forex, so they have 77 5-minute candle per day) whose 5-minute high is above ExponentialAverage[20](close) in 5min TF, whose open price for the day is above ExponentialAverage[20](close) in 30min TF, and whose first 5-minute candle has a low above the second 5-minute candle (plus a condition about the third candle but let’s make it simpler).
If you test the code with a short list of stocks of your choice, you can see results but with the whole US market group it throws an error inferring that some stocks have 0 intraday candles. I do not know why, but anyway.
How would you code this?
07/27/2020 at 11:54 AM #140187There you go:
123456789101112Timeframe(Daily)DailyOpen = openTimeframe(30 minute)c1 = DailyOpen > Average[20,1](close)Timeframe(5 minute)c2 = high > Average[20,1](close)IF IntraDayBarIndex = 1 THENc3 = low < low[1]ENDIFTimeframe(default)Cond = c1 AND c2 AND c3SCREENER[Cond]1 user thanked author for this post.
07/27/2020 at 1:37 PM #140198Thank you Roberto for your help but I believe that your code does not work either. It finds me stocks (using the whole US market) like the following whose Daily Open is below the EMA20 30min.
Only if I remove all conditions related to the 5min TF (c2 and c3 in this case), then c1 works. Do you obtain similar results Roberto?
07/27/2020 at 3:15 PM #140206Your pics doesn’t show all data for the 3 TF’s with the values of each MA involved.
As you can see from my pic, it works (it’s on CFD’s, but this won’t change with FUTURES or whatever, since rules don’t change).
07/27/2020 at 8:15 PM #14023807/27/2020 at 11:16 PM #140247C1 is true, since the Daily OPEN (72.630) is above Ema20 on the 30-minute TF (71.064).
1 user thanked author for this post.
07/28/2020 at 6:57 AM #14025007/28/2020 at 7:15 AM #140252I completely understand now Roberto. I did not explain myself properly in the definition of the code. I learn a great lesson here. Just for the record: my intention was that the Daily Open was above the EMA20 30min TF at the Opening not at the current level. I have modified the code accordingly and works perfectly now. Thank you for help!
As an aside I have a question related to the code:
Does the command “intradaybarindex” always ignore the command TIMEFRAME(x minutes) and takes the TF in which it counts the candles from the set Default TF?
I infer this because, for example, to get the EMA20 30min TF at the Opening, I have to define it from the 5-minute rather than directly using the 30min TF using “intradaybarindex” if I still want my 5min TF conditions including the command “intradaybarindex” to work. Code:
12345678910111213TIMEFRAME(5 minutes)open30EMA20 = ExponentialAverage[120](close)[intradaybarindex]c1 = DOpen(0) >= open30EMA20c2 = high >= ExponentialAverage[20](close)c3 = low[intradaybarindex] >= low[intradaybarindex-1]c = c1 and c2 and c3 and c4SCREENER [ c ]In here c1 works vs. This other similar code in which c1 does not:
12345678910111213TIMEFRAME(30 minutes)c1 = DOpen(0) >= ExponentialAverage[20](close)[intradaybarindex]TIMEFRAME(5 minutes)c2 = high >= ExponentialAverage[20](close)c3 = low[intradaybarindex] >= low[intradaybarindex-1]c = c1 and c2 and c3 and c4SCREENER [ c ]Both with Default TF set as 5min.
07/28/2020 at 8:58 AM #140274BarIndex and IntraDayBarIndex always return the bar number of the TF where they are used.
07/28/2020 at 9:00 PM #140337For what I see the intradaybarindex always takes the TF from the Default TF regardless of the TIMEFRAME(x minutes) I used above the command. I do not know whether I’m missing something but have a look at these pictures and maybe you can point out what is is.
I show the same ProScreener with the Default TF of 5min, 15min, and 30min. You can see the criteria #Bars changing along the Default TF and not corresponding to the value of “x” which is defined within the section TIMEFRAME(30 minutes).
07/29/2020 at 1:18 AM #140349You are right. That’s weird!
07/29/2020 at 7:24 AM #14035407/29/2020 at 9:09 AM #140359I think you should.
Please post their answer when available.
-
AuthorPosts
Find exclusive trading pro-tools on