Hi,
I create an indicator to check BULL and NON-BULL signals. If BULL the signal = 1. If NON-BULL the signal = 0. It looks like the screenshot in attachment.
Now I want to create a screener to find stocks which just change from NON-BULL to BULL (i.e from 0 to 1).
The following is my code but it screens nothing out.
indicator = CALL "Check_BULL"[10, 20]
c1 = indicator >=1
c2 = indicator[1] <= 0
SCREENER[c1 and c2] ((close/DClose(1)-1)*100 AS "%Chg yest.")
Where is the problem?
0 cannot be returned by indicators.
You can return any other value. Usually 1 is returned for bullish signals and -1 for bearish ones.
Your screener cannot return anything because you are asking that it returns only when opposite conditions are both true, which is impossible!
With the SCREENER keyword use OR within brackets, instead of AND.
thomas2004ch – Please use the ‘Insert PRT Code’ button when putting code in your posts as required by the few simple forum rules that you are asked to follow. I have edited your post to tidy it up for you on this occasion. 🙂
Hi robertogozzi ,
“Your screener cannot return anything because you are asking that it returns only when opposite conditions are both true, which is impossible!”
That is not correct. indicator and indicator[1] mean different, right? I want to scan stocks which changes from NON-BULL (yesterday) to BULL (today) as shown in my screenshot.
I tried your method and use 1 for BULL and -1 for NON-BULL. But it doesn’t work. I find nothing.
Here is my Check Indicator:
// MA
MA1 = ExponentialAverage[10](close)
MA2 = ExponentialAverage[30](close)
MA3 = ExponentialAverage[50](close)
cL1 = (MA1 > MA2) and (MA2 > MA3)
cL2 = close > MA1
cL3 = (close crosses over MA3) and (close crosses over MA2)
cL4 = (close crosses over MA2) and (close crosses over MA1)
cE1 = (close crosses under MA1) and (close crosses under MA2)
cE2 = (close crosses under MA2) and (close crosses under MA3)
cE3 = (close[1] crosses under MA1) and (close crosses under MA2)
cE4 = (close[1] crosses under MA2) and (close crosses under MA3)
cE5 = (close[1] crosses under MA3) and (close < MA3)
exit = cE1 or cE2 or cE3 or cE4 or cE5
if not exit and cL1 then
output = 1
else
output = -1
endif
RETURN output as "Check Triple MA"
And here again my Screener:
indicator = CALL "20200716_Check_MA_10_20_30"[10, 20, 30]
c1 = indicator > 0 // today is BULL
c2 = indicator[1] < 0 // yesterday NON-BULL
SCREENER[c1 and c2] ((close/DClose(1)-1)*100 AS "%Chg yest.")
You are righe about my remark, I did not notice the difference between c1 and c2. That’s because in such cases I usually write just one line:
c1 = indicator CROSSES OVER 0
I have tried several changes, but nothing worked. I also posted some code, but within seconds I realized it did not work and I deleted it (you may have received an email about this).
It still does not return what you want.
I suggest that you hit Ctrl+M from your platform to open a ticket with PRT’s assistance.
You should try to avoid the CALL instruction and copy/paste your indicator’s code directly into your screener and see how it goes.
Hi Nicolas,
Now I combine the indicator and screener as follow but it still doesn’t work. :-\
// sample screener code
// MA
MA1 = ExponentialAverage[10](close)
MA2 = ExponentialAverage[30](close)
MA3 = ExponentialAverage[50](close)
cL1 = (MA1 > MA2) and (MA2 > MA3)
//cL2 = close > MA1
//cL3 = (close crosses over MA3) and (close crosses over MA2)
//cL4 = (close crosses over MA2) and (close crosses over MA1)
cE1 = (close crosses under MA1) and (close crosses under MA2)
cE2 = (close crosses under MA2) and (close crosses under MA3)
cE3 = (close[1] crosses under MA1) and (close crosses under MA2)
cE4 = (close[1] crosses under MA2) and (close crosses under MA3)
cE5 = (close[1] crosses under MA3) and (close < MA3)
exit = cE1 or cE2 or cE3 or cE4 or cE5
if not exit and cL1 then
output = 1
else
output = -1
endif
c1 = output crosses over 0
SCREENER[c1] ((close/DClose(1)-1)*100 AS "%Chg yest.")
At line 22 use a positive digit for bearish values.
Ngative values are accepted by indicators, but not by screeners.
Ok. Now I change the code as follow, but still doesn’t work:
...
if not exit and cL1 then
output = 3
else
output = 1
endif
c1 = output crosses over 2
...
You are right, there’s no way to make it work.
I suggest that you press Ctrl+M from the platform to ask for assistance from PRT.