Reusable Candlestick Screening Code
Forums › ProRealTime English forum › ProScreener support › Reusable Candlestick Screening Code
- This topic has 9 replies, 4 voices, and was last updated 7 years ago by Nicolas.
-
-
04/08/2017 at 2:39 AM #31408
Hello there,
I’m completely new to ProRealTime and its programming language. I would like to create a number of individual “functions” that represent a single Candlestick pattern that I want to scan for. So, say, morning star, hammer, bullish harami and so on.
Then, I would like to write a screener that might reference two or three of my Candlestick pattern functions as well as other technical conditions eg: oversold stochastics etc.,
I’ve noticed that there is a CALL command but it specifies it’s use for calling indicator code whereas I want to call individual candlestick pattern screening functions.
Is this kind of library/function calling possible in the language. If, are there any examples I could see?
Many thanks.
04/08/2017 at 7:18 PM #31444Hi Geester
You have to write the code for the pattern that you want.
But it may be all done for you … have you searched for candlestick patterns on this site?
I find it quicker and better using google … just enter prorealcode.com and candlestick pattern and you will see Nicolas has done some very good codes to identify loads of patterns.
Cheers
GraHal04/08/2017 at 10:01 PM #31453Hi GraHal,
Thanks for your response!
I’m happy to write the code. I just want to be able to re-use each pattern with other pieces of code. From what I can see, because you can’t call the code as a function, you would have to replicate the code each time you want to use it [the same pattern] in a different situation.
For example, I wrote some code for a morning star and evening star and tried to return the value. However, the compiler said that you can only return a value from an indicator. The system seems very capable so I would have thought there would be some way to write a library of candlestick patterns that can be called/invoked from other pieces of code.
If I wrote some code where I want to screen for RSI oversold with a Morning Star pattern and a different screener for Stochastics oversold with a Morning Star pattern, it looks like I would have to have the Morning Star pattern code in the two screeners. I just want to be able to call a function that re-uses the Morning Star pattern code from just one place.
Cheers,
–G
04/09/2017 at 11:01 AM #31493Ah gotcha Geester, I understand now, yes a good idea.
Nicolas may be along to say if there is a way, or anyway you could email PRT directly and ask them or even suggest it via the PRT Contact Form.
https://www.prorealtime.com/en/contact?suggestion=1
Cheers
GraHal04/12/2017 at 7:32 PM #31887You’ll have to write an indicator with ProBuilder, named “morningstar” for instance, that return true is this pattern is found. Then you’ll be able to use a CALL to get this value in any screener you’d like to create. Same for any other functions/patterns/indis, …
04/12/2017 at 7:39 PM #31889Do you mean literally:
RETURN true
from the indicator?
I don’t understand how I can return the condition from “morningstar” to include in the SCREENER argument list?
so:
morningStarResult = CALL “morningstar”
// Is morningStarResult == true ??
SCREENER [morningStarResult] // Surely this won’t work – it needs the filter expression that was in the indicator called “morningstar”
See where I am coming from?
04/13/2017 at 1:15 PM #31940Ok, let’s make it step by step:
1/ firstly create your indicator for the morning star pattern and name it “morningstar” (case sensitive for the CALL function we’ll use in the next step):
123456789101112body=close-openabody=abs(body)longcandle= (ratio>0.6)if range>0 thenratio=abody/rangeelseratio=0endifMorningStar=(body[2]<0 and body>0 and longcandle[2] and open[1]<close[2] and open>close[1] and ratio[1]<0.3 and abody[1]<abody[2] and abody[1]<abody and low[1]<low and low[1]<low[2] and high[1]<open[2] and high[1]<close)return MorningStarThis indicator will return “1” if the pattern is found (boolean variable)
2/ in your screener, you can now include this returned variable value easily:
123mstar = call morningstarscreener[mstar]and of course add it to any other conditions you’d like to include into your own screener formula.
04/13/2017 at 1:33 PM #31943Hey Nicolas,
Thank you very much indeed for taking the time to explain this so that I could understand it! 🙂
I’ve called the indicator from a screener and it works beautifully! This is great news and will allow me much greater re-use, now I know the “secret”! 🙂
Again, I really appreciate your help with this!
Cheers,
–G
12/14/2017 at 7:53 AM #5562812/14/2017 at 8:50 AM #55629Hi John, unfortunately, there is no way to define ‘subroutine’ or ‘function’ like the way you think about (like other programming languages). But use CALL instruction is almost the same like the way I did in my above post. Possibilities are enormous with reusable CALL “functions” 🙂
-
AuthorPosts
Find exclusive trading pro-tools on