Simple screener not working, can't find mistake
Forums › ProRealTime English forum › ProScreener support › Simple screener not working, can't find mistake
- This topic has 14 replies, 2 voices, and was last updated 6 years ago by robertogozzi.
-
-
11/29/2017 at 12:58 AM #54313
Hi, I’m trying to make a simple screener that alerts me when a stock’s highest/lowest price in the first 1 hour of the day is at least 0.5% from the prev-day close and also down/up at 1% on prev-day close. In case that explanation wasn’t very good, here’s a picture explaining it; https://gyazo.com/7a62b441759ee8c7a9a572de9f0a6923
Here’s my code(V1 and V2)
I suspect it might be a syntax mistake since my screener is listing way more stocks than it should be, from my experience, which is what tends to happen whenever a syntax is wrong.
Can anyone correct my mistake(s) and help me out? Posting here is my last resort, after search everywhere I could.
Thanks in advance.
V1123456789101112131415161718192021222324252627282930313233343536373839timeframe (1hour)Hour1Start = 080000Hour1End = 090000if time > Hour1Start and time < Hour1End thenH1low = dlow(0)endifif time > Hour1Start and time < Hour1End thenH1High = dhigh(0)endiftimeframe (daily)BullOnDay = variation>1BearOnDay = variation<-1GapUp = (H1High-Close[1])/H1HighGapDown = (Close[1]-H1Low)/Close[1]HighCheck = H1High > Close[1]LowCheck = H1Low < Close[1]GapCheckUp = GapUp >= 0.005GapCheckDown = GapDown >= 0.005CheckUp = GapCheckUp and HighCheckCheckDown = GapCheckDown and LowCheckUpGap = GapUp and CheckUpDownGap = GapDown and CheckDownBull = DownGap and BullOnDayBear = UpGap and BearOnDaySCREENER [Bull or Bear] (Bull as "Bull")V21234567891011121314151617181920212223242526272829303132333435363738394041timeframe (1hour)Hour1Start = 080000Hour1End = 090000if time > Hour1Start and time < Hour1End thenH1low = dlow(0)endifif time > Hour1Start and time < Hour1End thenH1High = dhigh(0)endiftimeframe (daily)BullOnDay = variation>1BearOnDay = variation<-1if H1low < Close[1] thenGapDown = (Close[1]-H1Low)/Close[1]GapCheckDown = GapDown >= 0.005DownGap = GapDown and GapCheckDownendifif H1High > Close[1] thenGapUp = (H1High-Close[1])/H1HighGapCheckUp = GapUp >= 0.005UpGap = GapUp and GapCheckUpendifBull = DownGap and BullOnDayBear = UpGap and BearOnDaySCREENER [Bull or Bear] (Bull as "Bull")11/29/2017 at 10:33 AM #54340To make a link clicky, please use the “insert/edit link” button identified by a chain connector on the grey bar when you write your post so it becomes https://gyazo.com/7a62b441759ee8c7a9a572de9f0a6923.
You should replace lines 6-12 (both versions) with:
1234if time >= Hour1Start and time <= Hour1End thenH1low = lowH1High = highendifbecause time > Hour1Start is 9 AND time < Hour1End is 8 and they exclude each other. Adding “=” should make it work!
Also, since you are in a HOURLY timeframe, the highest & lowest prices between 080000 and 090000 are returned by the keywords HIGH and LOW of the candle closing at 090000 (which started at 080000), so you should replace lines 3-4 with:
12Hour1Start = 090000Hour1End = 090000They are just the more visible mistakes I can easily spot. I will try to code it my own way and then post it later today.
Roberto
1 user thanked author for this post.
11/29/2017 at 10:39 AM #54341Hi, I’m trying to make a simple screener that alerts me when a stock’s highest/lowest price in the first 1 hour of the day is at least 0.5% from the prev-day close and also down/up at 1% on prev-day close.
So 0.5% is +0.5% (not -0.5%)?
1 user thanked author for this post.
11/29/2017 at 2:04 PM #54356Hi, I’m trying to make a simple screener that alerts me when a stock’s highest/lowest price in the first 1 hour of the day is at least 0.5% from the prev-day close and also down/up at 1% on prev-day close.
So 0.5% is +0.5% (not -0.5%)?
Thanks for above corrections, I have added them to my code but it still doesn’t work. I am no longer getting too many stocks in my screener, I now have none.
0.5% is just a minimum benchmark from the close to the high or low. The difference between the close and high/low has got to be at least 0.5%.
It can be either +0.5% or -0.5% depending on if it’s a bull or bear signal. In the picture/screenshot I previously sent, the signal is bullish so the 0.5% is -0.5%. If that chart was flipped to become bearish, it would be +0.5%. Hope thats makes things more clear.
12/05/2017 at 7:18 PM #54816Hi, I’m trying to make a simple screener that alerts me when a stock’s highest/lowest price in the first 1 hour of the day is at least 0.5% from the prev-day close and also down/up at 1% on prev-day close.
Since you used AND, there’s no need to check +-0.5%, checking 1% will do both.
I tried to write this code, please test it and give me some feedback. I did not test it much:
12345678910111213141516171819202122ONCE DayLow = 0ONCE DayHigh = 0ONCE Hlow = 0ONCE Hhigh = 0ONCE HourStart = 090000MyAlert = 0timeframe (daily)DayHigh = Dhigh(0)DayLOw = Dlow(0)timeframe (1 hour)if time = HourStart thenHlow = lowHhigh = highMyAlert = (Hlow >= (DayHigh * 1.01)) OR (Hhigh <= (DayLow * 0.09))endiftimeframe (default)SCREENER [MyAlert] (MyAlert as "Bull/Bear")1 user thanked author for this post.
12/05/2017 at 11:08 PM #54832Hi, thanks for getting back to me.
I just pasted your code into a new screener, and I get no new results; it still doesn’t work.
I’m not sure what you mean by the following “Since you used AND, there’s no need to check +-0.5%, checking 1% will do both.” since the first hourly low/high being 0.5% from close is a key requirement, and I only want to be alerted once the stock has reached 1% from close. Maybe I misunderstood what you said, but it seems like theres some confusion I hope this clears any.
Thanks in advance
12/06/2017 at 12:40 PM #54887Hi, thanks for getting back to me. I just pasted your code into a new screener, and I get no new results; it still doesn’t work. I’m not sure what you mean by the following “Since you used AND, there’s no need to check +-0.5%, checking 1% will do both.” since the first hourly low/high being 0.5% from close is a key requirement, and I only want to be alerted once the stock has reached 1% from close. Maybe I misunderstood what you said, but it seems like theres some confusion I hope this clears any. Thanks in advance
Since you wrote “I only want to be alerted once the stock has reached 1% from close” you only need to check 1%, since it includes 0.5%.
1 user thanked author for this post.
12/06/2017 at 3:50 PM #54900I’m confused as to why you wouldn’t need to check if the distance between the close and highest/lowest is 0.5%, since the 0.5% distance isn’t counted from close, since it is either below or above the close.
I’ve attached a picture showing what I want my screener to achieve. The distance between the red circles has to be atleast -0.5% and I need the screener to tell me when the difference between the blue circles is +1%.
Thanks
12/06/2017 at 4:31 PM #54902Please attach a detailed example, you might use a spreadsheet to make it, with each candle tagged with the time it is formed.
I can’t understand why you drew a red circle below the red candle and the other one below the green candle by its side.
1 user thanked author for this post.
12/06/2017 at 4:57 PM #54903I drew a red circle around the previous day close, and around the lowest point of the opening hour the next day. I included the time/day bar at the bottom of the screen in hopes of showing this.
Bull example:
Stock price at previous day close = 10
Stock price at low of first hour candle = 9.9
Difference between close and lowest point in first hour = -1%
-1% is bigger than the minimum requirement of -0.5%, which is what we are looking for.
Stock price then increases to 10.1
Difference between previous day close(10) and current price(10.1) is +1%, at this point, the screener alerts.
Bear example:
Stock price at previous day close = 10
Stock price at high of first hour candle = 10.1
Difference between close and lowest point in first hour = +1%
+1% is bigger than the minimum requirement of +0.5%, which is what we are looking for.
Stock price then decreases to 9.9
Difference between previous day close(10) and current price(9.9) is -1%, at this point, the screener alerts.
No alert bull example:
Stock price at previous day close = 10
Stock price at low of first hour candle = 9.98
Difference between close and lowest point in first hour = -0.2%
-0.2% is below the minimum requirement of -0.5%, which means we dont care about it.
I hope this helps
12/06/2017 at 5:03 PM #54904Now I got it!
I’ll try to arrange something tomorrow morning.
1 user thanked author for this post.
12/06/2017 at 5:08 PM #54905Great! I’m glad that got cleared up.
Just seen a small typo in my comment;
Under “Bear example”, the line “Difference between close and lowest point in first hour = +1%”, should be; “Difference between close and HIGHEST point in first hour = +1%”
12/08/2017 at 10:55 AM #55044Try this one (I did not test it, though):
12345678910111213ONCE MaxPercent = 0.01IF IntradayBarIndex = 0 THEN //Check the first hourly bar each dayYesterdayClose = close[1] //Data from yesterday's last bar// BullishFirstHourHigh = YesterdayClose * (1 + MaxPercent)// BearishFirstHourLow = YesterdayClose * (1 - MaxPercent)ELSEBullAlert = close >= FirsrHourHighBearAlert = close <= FirsrHourLowMyAlert = BullAlert OR BearAlertENDIFSCREENER [BullAlert OR BearAlert] (MyAlert as "Bull/Bear")This will work on a hourly TF, to make it work on, say, 5min TF a bit more work is needed. If it works on an hourly TF we can further adapt it to other TFs.
Still, I have no idea what to do with 0.5%; it is useless, since you only want to be alerted when the price reaches +-1% (which is bigger than+-0.5%).
12/15/2017 at 2:11 PM #55733Hi, thanks for the help. I apologize for not responding instantly, as I have been away from internet access for the last week.
I have tried your new code, it still doesn’t work. It returns lots of stocks that don’t have anything to do with what I’m looking for.
Still, I have no idea what to do with 0.5%; it is useless, since you only want to be alerted when the price reaches +-1% (which is bigger than+-0.5%).
As I explained before, the 0.5% is not measuring anything but the difference in price from the previous days close, and the high(Bear) or low(Bull) of the first candle. If the difference is bigger than -0.5% then I want to be alerted once the stock reaches +1%(Bull signal) and if the difference is bigger than +0.5%, then I need to be alerted when the stock reaches -1%(Bear signal). So, the 0.5% is definitely needed, since it’s the opposite direction of the 1%.
Here’s a visual of what I would like to achieve. This chart attached is a bull signal.
Chart Key;
1 = Previous day close (30/10/17)
2 = Low of first hour (31/10/17)
3 = Stock reaches +1% difference from Previous day close(1)
As you can see; the difference between the Previous day close, labelled “1”(px : 1203.5) and the low of the first hour, labelled “2”(px: 1261) is -2.51%. -2.51% is above the minimum requirement of -0.5% for a Bull signal, so this is what we are looking for. For the screener to alert, we need the difference between the previous day close(“1”) and the current price to be +1%. The stock pictured, reaches +1% at point “3” on the chart.
The general idea of this pattern is the stock price going from negative to positive(Bull) or positive to negative(Bear) within the first hour of the day.
Hope this helps
12/15/2017 at 3:46 PM #55751What I did not understand was that 0.05% had to be -0.05% for BULLish setups and +0.05% for BEARish setups. Now it’s clear.
I hope it works as you asked (any feedback is always and highly welcomed):
12345678910111213141516ONCE MaxPercent = 0.01ONCE PreviousHighLowPercent = 0.005IF IntradayBarIndex = 0 THEN //Check the first hourly bar each dayYesterdayClose = close[1] //Data from yesterday's last bar// BullishFirstHourHigh = YesterdayClose * (1 + MaxPercent)FirstHourMinimumLow = low <= (YesterdayClose * (1 - PreviousHighLowPercent)) //true if low <= -0.5% of the previuos day// BearishFirstHourLow = YesterdayClose * (1 - MaxPercent)FirstHourMinimumHigh = high >= (YesterdayClose * (1 + PreviousHighLowPercent)) //true if high >= 0.05% of the previous dayELSEBullAlert = (close >= FirstHourHigh) AND FirstHourMinimumLowBearAlert = (close <= FirstHourLow) AND FirstHourMinimumHighMyAlert = BullAlert OR BearAlertENDIFSCREENER [BullAlert OR BearAlert] (MyAlert as "Bull/Bear")1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on