How to find the largest number of times a candlestick pattern appears within 2 hours to 15 minute timeframes
Asked Answered
L

1

8

I am trying to search figure out how to search for a pattern within a range of timeframes. Obviously, it is likely that the pattern would occur several times based on the timeframes, that’s why I’m particularly interested in the largest number of times it repeats.

To explain what I’m trying to achieve further, say I am searching for a pattern from 2 hour to 15 minute chart and I find it on the 2 hour chart, then I drill into the next timeframe 1 hour, and I end up with two of the patterns on the 1 hour chart, I’ll continue to the 30 minute (in both 1 hour patterns) and to 15 minutes till I get the largest time it occurs.

I believe that a method that returns the next lower timeframe would be needed. I’ve been able to write that, see code below. I would really appreciate some help.

ENUM_TIMEFRAMES findLowerTimeframe(ENUM_TIMEFRAMES timePeriod)
{
   int timeFrames[5] = {15, 20, 30, 60, 120};

   int TFIndex=ArrayBsearch(timeFrames, (int)timePeriod);

   return((ENUM_TIMEFRAMES) timeFrames[TFIndex - 1]);
}

EDIT

I didn't add the specific candlestick pattern because I believe it isn't the most important part of my problem. The crux of the question is how to search for a pattern on several consecutive timeframes to find the largest number of times it occurs within the range of times.

Lakeshialakey answered 15/10, 2019 at 14:57 Comment(3)
I do not quite understand what you want to achieve. Is it MQL4 or MQL5 (you've added both tags). In MQL5, PERIOD_H1 (for example) wont cast to 60, so your casting won't work. In MQL4 it will, but 20- and 120- minute tfs are custom chartsLeatherman
@DanielKniaz okay, I want a solution in MQL5. I've edited the tags.Lakeshialakey
@DanielKniaz I asked another question a bit similar but with more detail and provided a working EA with a precise candlestick pattern here #62480081Lakeshialakey
L
0
const ENUM_TIMEFRAMES DEFAULT_TIMEFRAMES[5] = {PERIOD_M15, PERIOD_M20, PERIOD_M30, PERIOD_H1, PERIOD_H2};
ENUM_TIMEFRAMES findLowerTimeframe(ENUM_TIMEFRAMES timePeriod)
  {
   int TFIndex=ArrayBsearch(DEFAULT_TIMEFRAMES,timePeriod);
   return(TFIndex>0 ? timeFrames[TFIndex - 1] : PERIOD_CURRENT);
  }
Leatherman answered 16/10, 2019 at 19:37 Comment(7)
Thanks. How can I use this to search for the largest number of times a candlestick pattern occurs from 2 hours to 15 minutes as I explained above?Lakeshialakey
I have no idea. show what pattern you tried to search, both in words and in textLeatherman
I am interested in searching for a bearish candle with the upper and lower wick similar/equal in length followed by a bullish pinbar. I want to search on this pattern on all times from 2 hours to 15 minutes and find where the pattern appears the largest number of times within the timeframes.Lakeshialakey
@DanielKniaz I would really appreciate some help with this #62528797Continent
@DanielKniaz I've created a bounty for the question with additional info. Please take a look #62528797Continent
@Continent If you could describe what is bullish engulfing pattern, from your point of view, that would make things easier.Leatherman
@DanielKniaz I have updated the question with the description of the bullish engulfing pattern.Continent

© 2022 - 2024 — McMap. All rights reserved.