Hi Again,
I would appreciate your assistance for a code screener. I have a good talent to complicate things.
For this screening I must use 7 and 23 period moving averages, Parabolic SAR, MACD, Stochastic and Bollinger Bands on two timeframes: daily and weekly. The settings of the indicators are a little bit different:
- 7 and 23 period simple moving averages
- MACD (9, 17,6)
- Stochastic (15, 5, 5) – method: exponential
- Parabolic, default settings (0.02, 0.02, 0.2)
- Bollinger Bands, default settings (20,2), the only exception is that an average of high, low and close must be used.
Now I write some abbreviations to avoid writing long sentences.
- Price (1) = today’s price at close
- Price (8) = price at close in the 8th day (8 days ago)
- Parabolic SAR (1) = parabolic SAR as today
- M7 (1) = 7 period simple moving average as today at close
- M23 (1) = 23 period simple moving average as today at close
- M7 (2) = 7 period simple moving average as yesterday at close
- M23 (2) = 7 period simple moving average as yesterday at close
- UB (1) = upper Bollinger Band as today
- UB (2) = upper Bollinger Band as yesterday
- LB (1) = lower Bollinger Band as today
- LB (2) = lower Bollinger Band as yesterday
- (UB-LB) = difference between upper and lower Bollinger Bands
- Max(UB-LB)50 = largest difference between upper and lower Bollinger Bands in the last 50 periods
- Max(UB-LB)100 = largest difference between upper and lower Bollinger Bands in the last 100 periods
- BMA = Bollinger moving average
- %K = slow down fast %K by exponential moving average
- %D = slows down %D by exponential moving average – see attached excel spreadsheet for calculations)
To enter
| Indicator |
Timeframe – week |
Timeframe – day |
| price |
Price (1) > price (8)
Price (1) > parabolic SAR (1) |
Price (1) > price (8)
Price (1) > parabolic SAR (1) |
| 7/23 |
M7 (1) > M23 (1)
M7(1) > M7 (2)
M23 (1) > M23 (2) |
M7 (1) > M23 (1)
M7(1) > M7 (2)
M23 (1) > M23 (2) |
| Bollinger Bands |
UB )1) > UB (2)
(UB – LB) < or = 0.7*(UB – LB)50 |
UB )1) > UB (2)
(UB – LB) < or = 0.5*(UB – LB)100
LB (1) < LB (2) |
| MACD |
MACD > Signal |
MACD > Signal |
| Stochastic |
%K > %D |
%K > %D |
| Volume |
|
500 000 |
To exit
| Indicator |
Timeframe – week |
Timeframe – day |
| Price, Parabolic SAR and Bollinger moving average |
Parabolic (1) > price (1) (price closes bellow parabolic SAR)
BMA (1) > Price (1) (price closes bellow Bollinger moving average) |
|
Thank you very much,
Petru
Hi, in that case I’m moving your post to the pro-screener forum, where it has more chances to be read by members able to help in that area
For future reference, the list of PRC forums to choose from is here: https://www.prorealcode.com/forums/
Regards
Hi,
I am considering myself very lucky that I discovered this forum with lots of great people that share their ideas and very helpful.
I am using excel spreadsheets to back test my idea (if some is interested please let me know and I will share it with you), but to find opportunities unfortunately it is impossible to screen the market using excel. My programming skills are not great, but I determined to learn even I am not young.
I would like to explain my previous message. I want to screen on two different timeframes, week and day, in a bullish market.
On both time frames parabolic should serve as support and price at close must be higher than the price at close on the 8th day. The short (7 period) and long (23 period) simple moving averages should trend upward direction with short moving average above long moving average. MACD must be greater than signal and for stochastic %K greater than %D (not necessarily on daily timeframe).
On daily timeframe we should see a Bollinger squeeze, upper and lower bands should be at minimum compared to the past 100 days. A bullish closing price above the upper Bollinger band with a divergence of bands and a %K greater than %D for stochastic should give a buy signal.
For exit I am going to use excel since I feel more comfortable, this until I will improve my programming skills. Exit signal will be given when parabolic SAR becomes resistance and price closes below Bollinger moving average on the weekly timeframe.
I know it is a very very difficult to get to taste the success, but this is something that I like. Thank you all for making this forum wonderful.
Best Regards,
Petru
Thanks for the explanation @Petru, let’s see what I can do for help.
Here is the code of the screener you requested:
timeframe(weekly)
maw7 =average[7]
maw23 = average[23]
ubolw = BollingerUp[20](close)
lbolw = BollingerDown[20](close)
wmacd = macd[12,29,9]
wsmacd = exponentialaverage[9](wmacd)
wsto = Stochastic[14,3](close)
wssto = average[6](wsto)
w1 = close>close[8]
w2 = close>SAR[0.02,0.02,0.2]
w3 = maw7>maw23
w4 = maw7>maw7[1]
w5 = maw23>maw23[1]
w6 = ubolw>ubolw[1]
w7 = (ubolw-lbolw)<=0.7*(highest[50](ubolw)[1]-lowest[50](lbolw)[1])
w8 = wmacd>wsmacd
w9 = wsto>wssto
wconditions = w1 and w2 and w3 and w4 and w5 and w6 and w7 and w8 and w9
timeframe(daily)
mad7 =average[7]
mad23 = average[23]
ubold = BollingerUp[20](close)
lbold = BollingerDown[20](close)
dmacd = macd[12,29,9]
dsmacd = exponentialaverage[9](dmacd)
dsto = Stochastic[14,3](close)
dssto = average[6](dsto)
d1 = close>close[8]
d2 = close>SAR[0.02,0.02,0.2]
d3 = mad7>mad23
d4 = mad7>mad7[1]
d5 = mad23>mad23[1]
d6 = ubold>ubold[1]
d7 = (ubold-lbold)<=0.5*(highest[100](ubold)[1]-lowest[100](lbold)[1])
d8 = dmacd>dsmacd
d9 = dsto>dssto
d10 = volume>500000
dconditions = d1 and d2 and d3 and d4 and d5 and d6 and d7 and d8 and d9 and d10
screener [wconditions and dconditions] sort by Volume
Thank you very much Nicolas,
I just got home and now I am trying your code. Thank you again for helping me.
Best Regards,
Petru