4-Candlestick pattern detection
Forums › ProRealTime English forum › ProBuilder support › 4-Candlestick pattern detection
- This topic has 9 replies, 2 voices, and was last updated 5 years ago by robertogozzi.
-
-
03/04/2019 at 12:37 AM #92778
Dear all,
Please help me to develop the following detection system.
The pattern is based on 4 candles in sequence. Here the requirements/parameters in example:
1)First candle must have a size = *multiplier* of ATR (let’s assume 1,2*ATR(20)) and 60% of his Volume must be constituted by the body.
2)Second candle must have the same direction of the previous one (so, both green or red) and must have the same features with 20% of tolerance (so, 1,2*ATR +/20% and/or 60% +/-20% of body over total). 20% is considered on 60% value (so, equal to +/- 12% in this example)
3)The third Candle has to be “opposite” (so, for 2 green, it must be red or vise versa) and must engulf the previous candle (it must close above or below, i don’t care about high or low)
4)The fourth one needs just to make a new low (if third is red) or new high (if third is green) to validate the pattern. No additional requirements needed.
Please, i need an indicator which allow me to customize the parameters explained without modifying the code (i don’t know coding language). So, parameters customizable for each first 2 candles are:
- ATR period;
- ATR Multiplier (from 0,1 to 3 is enough);
- Body % over total size (i used 60% in this case, but should be customizable as described);
- Tolerance %.
Thanks for help!
03/04/2019 at 2:05 AM #92780This is the code I wrote. I only tested it for syntax errors.
I attach the ITF file to be imported into ProBuilder.
123456789101112131415161718192021222324252627282930DEFPARAM CalculateOnLastBars = 10000//AtrMultiplier = 1.20 //1.20 ATR multiplier//BodySize = 0.60 //60% minimum Body size (compared to Range)//Tolerance = 0.20 //20% toleranceMaxTolerance = 1 + ToleranceMinTolerance = 1 - ToleranceBody = abs(close - open)MaxBody = BodySize * MaxToleranceMinBody = BodySize * MinToleranceBullish = close > openBearish = close < openMyAtr = AverageTrueRange[14](close) * AtrMultiplierMyAtrMax = MyAtr * MaxToleranceMyAtrMin = MyAtr * MinToleranceCandle1 = (range[3] >= MyAtr[3]) AND (Body[3] >= (range[3] * BodySize))Candle2 = (Bullish[3] AND Bullish[2]) OR (Bearish[3] AND Bearish[2])Candle2 = Candle2 AND ((range[2] >= MyAtrMin[2]) AND (range[2] <= MyAtrMax[2]))Candle2 = Candle2 AND ((Body[2] <= (range[2] * MaxBody)) AND (Body[2] >= (range[2] * MinBody)))Candle3 = (Bullish[3] AND Bullish[2] AND Bearish[1]) OR (Bearish[3] AND Bearish[2] AND Bullish[1])IF Bullish[3] THENCandle3 = (Candle3 AND (close[1] < open[2]))ELSIF Bearish[3] THENCandle3 = (Candle3 AND (close[1] > open[2]))ELSECandle3 = 0ENDIFCandle3 = (Candle3 AND (range[1] >= MyAtr))Candle4 = ((Bullish[1]) AND (high > high[1])) OR ((Bearish[1]) AND (low < low[1]))Result = Candle1 AND Candle2 AND Candle3 AND Candle4RETURN ResultWhen you post your feedback, in case of unexpected results, please post:
- instrument
- TF used
- value set with the indicator properties for the three variables
- opentime/date of the candle when the pattern has incorrectly been reported or when it should have been correctly reported.
Thank you.
03/04/2019 at 10:03 AM #92799Buongiorno Roberto,
Ho importato l’indicatore. Dovrebbe visualizzarmi il pattern anche nei dati storici vero? Non solo su quelli in real time?
Ad un primo acchitto non vedo nessuna segnalazione di pattern conforme. Cmq adesso farò delle prove e le farò saprere. Intanto ringrazio
PS
Come dovrei visualizzare il pattern? Intendo…c’è una colorazione speciale delle quattro candele? Una freccia? Grazie
Good morning Roberto,
I imported the indicator. Should the pattern be displayed in historical data too? Not only on those in real time?
At first glance I do not see any conformal pattern signaling. Anyway now I will do some tests and I will let them know. Meanwhile, thank you
PS
How should I view the pattern? I mean … is there a special coloring of the four candles? An arrow? Thank you
03/04/2019 at 10:19 AM #92800Nel frattempo allego un immagine in cui mi “aspettavo” una segnalazione.
Dax 5 min TF, 25/02/2019 ore 15:30. Ho impostato ATR a 0,01 e Body a 0,2 per ridurre al “minimo” il filtraggio. Tolerance sempre a 0,2.
A me a occhio pare che il pattern rispetti a pieno i requisiti. L’ellisse è disegnata un pò male, taglia la quarta candela che cmq di fatto va sotto la terza, che engulfa perfettamente la seconda.
Inoltre mi pare che l’ATR non sia modificabile in periodi (mi serve customizzabile)
Grazie
In the meantime I am attaching an image in which I “expected” a report.
Dax 5 min TF, 25/02/2019 at 15:30. I set ATR to 0.01 and Body to 0.2 to reduce filtering to “minimum”. Tolerance always at 0.2.
It seems to me that the pattern fully complies with the requirements. The ellipse is drawn a little bad, cut the fourth candle that cmq actually goes under the third, which engulfs the second perfectly.
Also I think that the ATR is not editable in periods (I need customizable)
Thank you
03/04/2019 at 10:46 AM #9280403/04/2019 at 11:28 AM #92806Please speak english on the english forum.
03/04/2019 at 11:36 AM #92807The indicator returns a line having values of either 0 or 1, so it will look like a triangle when a pattern is detected.
I can draw arrows on the price chart, if you prefer.
I will add a variable for the ATR.
I will also take a look at your pics later this evening or tomorrow morning.
03/04/2019 at 1:04 PM #9281703/06/2019 at 10:19 AM #9294003/06/2019 at 11:51 AM #92952This is version 2:
12345678910111213141516171819202122232425262728293031//-----------------------------------------------------------------------------------------------------------------------------------------//// Versione 2//DEFPARAM CalculateOnLastBars = 5000//AtrMultiplier = 1.20 //1.20 ATR multiplier//BodySize = 0.60 //60% minimum Body size (compared to Range)//Tolerance = 0.20 //20% tolerance//AtrPeriods = 14 //14 periodsMinTolerance = 1 - ToleranceBody = abs(close - open)MinBody = BodySize * MinToleranceBullish = close > openBearish = close < openMyAtr = AverageTrueRange[AtrPeriods](close) * AtrMultiplierMyAtrMin = MyAtr * MinToleranceCandle1 = (range[3] >= MyAtr[3]) AND (Body[3] >= (range[3] * BodySize))Candle2 = (Bullish[3] AND Bullish[2]) OR (Bearish[3] AND Bearish[2])Candle2 = Candle2 AND ((range[2] >= MyAtrMin[2]))Candle2 = Candle2 AND (Body[2] >= (range[2] * MinBody))Candle3 = (Bullish[3] AND Bullish[2] AND Bearish[1]) OR (Bearish[3] AND Bearish[2] AND Bullish[1])IF Bullish[2] THENCandle3 = (Candle3 AND (close[1] < open[2]))ELSIF Bearish[2] THENCandle3 = (Candle3 AND (close[1] > open[2]))ELSECandle3 = 0ENDIFCandle4 = ((Bullish[1]) AND (high > high[1])) OR ((Bearish[1]) AND (low < low[1]))Result = Candle1 AND Candle2 AND Candle3 AND Candle4RETURN ResultI added a variable to set ATR periods with the indicator’s properties.
As for Dax 5 min TF, 25/02/2019 at 15:30, candles 4 and 3 were not the same direction. There should be a valid pattern on 25/02/2019 at 17:05.
1 user thanked author for this post.
-
AuthorPosts