Hi Everyone.
I just wanted to see if anyone had any code for the stochastic indicator? I’m ideally looking for a screener to look for a crossover above the 80 line or below the 20 line.
Thanks,
Rob
This should work, le me know
// Constant definitions
// OverBought/OverSold tresholds
ONCE StocOB = 80 //80 - 20
ONCE StocOS = 100 - StocOB
// Stochastic parameters
ONCE Stoc1 = 5 //5
ONCE Stoc2 = 3 //3
ONCE Stoc3 = 3 //3 (average for the D line)
StocK = Stochastic[Stoc1,Stoc2](close) //K line
StocD = Average[Stoc3](StocK) //D line
CrossOB = StocK CROSSES UNDER StocD AND StocK > StocOB //Crossing occurred while K line is still OB
CrossOS = StocK CROSSES OVER StocD AND StocK < StocOS //Crossing occurred while K line is still OS
SCREENER[CrossOB OR (CrossOS * 2)] //1=crossing while OB, 2=crossing while OS
Roberto
Lines 15-16 may make the screener return different occurrences if you require line K not to be OS/OB (still line D will), by replacing them with the following two:
CrossOB = StocK CROSSES UNDER StocD AND StocD > StocOB //Crossing occurred while D line is still OB
CrossOS = StocK CROSSES OVER StocD AND StocD < StocOS //Crossing occurred while D line is still OS
You may change all constants tu best suit your needs.
Lines 17-18 shold be replaced by the following to show correct results:
Result = CrossOB OR (CrossOS * 2)
SCREENER[Result](Result AS "Cross") //1=crossing while OB, 2=crossing while OS
Hi Roberto,
Thank you so much for your help and advice.
I am however very sorry, I’m slightly confused and have zero coding knowledge.
Do I just copy and paste your first reply onto Pro real time?#
Thanks,
Rob
You can Copy & Paste the following code to ProScreen or you may either import the attached file into ProScreener.
// Constant definitions
// OverBought/OverSold tresholds
ONCE StocOB = 80 //80 - 20
ONCE StocOS = 100 - StocOB
// Stochastic parameters
ONCE Stoc1 = 5 //5
ONCE Stoc2 = 3 //3
ONCE Stoc3 = 3 //3 (average for the D line)
StocK = Stochastic[Stoc1,Stoc2](close) //K line
StocD = Average[Stoc3](StocK) //D line
CrossOB = StocK CROSSES UNDER StocD AND StocK > StocOB //Crossing occurred while K line is still OB
CrossOS = StocK CROSSES OVER StocD AND StocK < StocOS //Crossing occurred while K line is still OS
Result = CrossOB OR (CrossOS * 2)
SCREENER[Result](Result AS "Cross") //1=crossing while OB, 2=crossing while OS
This is a link to help import code, of cource you’ll have import the screener to ProScreener, not ProOrder (for automated Strategies) or ProBuilder (for Indicators/Oscillators) https://www.prorealcode.com/import-export-prorealtime-code-platform/
I also attach 3 screenshots to help you import the .ITF file.
The last step step, not shown, is to select the file to import from the same folder where you saved it, usually the DOWNLOAD folder on Windows.
Thank you so much for your help.
On a totally different note.
Whats your favorite scanner/strategy? 🙂
I regularly use a similar stochastic crossover, engulfing pattern detection and stochastic divergences.
Thanks again for your help Roberto.