Hi, I tried to modify the morning/evening star screener from @Francesco into a Three inside up/down screener. The screener seems to work but picks the pattern anywhere in the past.
I think the problem starts with identifying the base candle………?????
Does anybody (@Fransesco?) has an idea how to scan the last recent build patterns only?
//Author: Francesco modified: Marcel van Vliet
//Date: 20-01-2017 Date: 16-09-2017
//BaseCandle parameter = first candle of the pattern, starting from right (it is possible to run screener staring from any past candle)
BaseCandle = 0
Open0 = Open[BaseCandle]
Close0 = Close[BaseCandle]
Open1 = Open[BaseCandle + 1]
Close1 = Close[BaseCandle + 1]
Open2 = Open[BaseCandle + 2]
Close2 = Close[BaseCandle + 2]
Open3 = Open[BaseCandle + 3]
Close3 = Close[BaseCandle + 3]
Open4 = Open[BaseCandle + 4]
Close4 = Close[BaseCandle + 4]
//Three inside up
C1=Open0<Close0 andClose1>Open0 and Close2<Close1 and Close3< Close2 and Open4≤Close3 and Open4<Close4
//Three inside down
C2=Open0>Close0 andClose1<Open0 and Close2>Close1 and Close3> Close2 and Open4≥Close3 and Open4>Close4
//Go Short Signal = -1
If C2 then
Go = -1
endif
//Go Long Signal = 1
If C1 then
Go = 1
endif
Condition = (C1 or C2)
SCREENER[Condition] (Go AS "Go")
I discovered that the ‘greater than or equal sign’ and the ‘smaller than or equal sign’ are not valid in PRT language.
Can anyone, maybe @Nicolas help me out with this?
Thank you.
The problem in your code is that once you set your ‘Go’ variable to a value, the program keep this value until the code has finished reading the whole data history. You need to reset it to its default state if your C1 or C2 conditions are not true:
//Go Short Signal = -1
If C2 then
Go = -1
//Go Long Signal = 1
elsIf C1 then
Go = 1
else
Go = 0
endif
It should do the trick, please tell us.
@Nicolas, Thanks a lot.
Please, can you post me the ‘greater than or equal sign’ and the ‘smaller than or equal sign’ which are used in PRT?
I can’t find this in the manual.
Thanks you.
IF close >= open THEN //Greater Than OR Equal to
IF close <= open THEN //Smaller Than OR Equal to
@robertogozzi Thanks a lot.
Is it worth the effort to upload the screener for the library?
Is it worth the effort to upload the screener for the library?
Sure! It could serve as a reference to other users around here 🙂 Thanks for sharing Marcel.
Here is the result of our ‘author combined screener’ for the three inside up/down candlestick pattern. Unfortunately I only have acces to Euronext stocks and Forex to test it. Is there somebody willing to test it on other securities before I load it up in the library?
//Author: Francesco modified: Marcel van Vliet
//Date: 20-01-2017 Date: 16-09-2017
//BaseCandle parameter = first candle of the pattern, starting from right (it is possible to run screener staring from any past candle)
BaseCandle = 0
Open0 = Open[BaseCandle]
Close0 = Close[BaseCandle]
Close1 = Close[BaseCandle + 1]
Close2 = Close[BaseCandle + 2]
Close3 = Close[BaseCandle + 3]
Open4 = Open[BaseCandle + 4]
Close4 = Close[BaseCandle + 4]
//Three inside up
C1=Open0<Close0 and Close1>Open0 and Close2<Close1 and Close3< Close2 and Open4<=Close3 and Open4<Close4 and Close4>=Close0
//Three inside down
C2=Open0>Close0 and Close1<Open0 and Close2>Close1 and Close3> Close2 and Open4>=Close3 and Open4>Close4 and Close4 <=Close0
//Go Short Signal = -1
If C2 then
Go = -1
//Go Long Signal = 1
elsIf C1 then
Go = 1
else
Go = 0
endif
Condition = (C1 or C2)
SCREENER[Condition] (Go AS "Go")
Seems ok on NYSE and NASDAQ stocks lists.
Ok, Thank you sure enough for me to upload it.