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

To add comments, please log in or register
Jackery
88
Jackery  

I am trying to search figure out how to search for a pattern within a range of timeframes in MQL5. 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. 


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]);
}

I would really appreciate some help.

Vladimir Karputov
Moderator
160388
Vladimir Karputov  

I would suggest this option:

ENUM_TIMEFRAMES findLowerTimeframe(ENUM_TIMEFRAMES timePeriod)
  {
   int timeFrames[5];
   timeFrames[0]=PERIOD_M15;
   timeFrames[1]=PERIOD_M20;
   timeFrames[2]=PERIOD_M30;
   timeFrames[3]=PERIOD_H1;
   timeFrames[4]=PERIOD_H2;

   int TFIndex=ArrayBsearch(timeFrames,timePeriod);
//---
   return((ENUM_TIMEFRAMES)timeFrames[TFIndex - 1]);
  }
William Roeder
19972
William Roeder  
  1. On MT5 ENUM_TIMEFRAMES values are not the period in minutes.
    Use EnumToString(TF[i]) to see the string representation of the time frame.
    Use PeriodSeconds(TF[i]) to see the duration of the time frame.
              Why calculations of period()_value are different? (over 30 minutes) What's Burg? - Indices - Technical Indicators - MQL5 programming forum

  2. If this is supposed to be MT4, Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. What happens if you pass 15 into your function?
Jackery
88
Jackery  
Vladimir Karputov:

I would suggest this option:

Thank you. I appreciate the help. What about how I can use this method to search a some generic pattern on all timeframes in the range till I get the largest number of times it occurs as I explained above? That's the crux of my problem.

Jackery
88
Jackery  
William Roeder:
  1. On MT5 ENUM_TIMEFRAMES values are not the period in minutes.
    Use EnumToString(TF[i]) to see the string representation of the time frame.
    Use PeriodSeconds(TF[i]) to see the duration of the time frame.
              Why calculations of period()_value are different? (over 30 minutes) What's Burg? - Indices - Technical Indicators - MQL5 programming forum

  2. If this is supposed to be MT4, Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. What happens if you pass 15 into your function?

I thought posting it here would be the most appropriate place for my question. What about how I can use the method to search a some generic pattern on all timeframes in the range till I get the largest number of times it occurs as I explained above? That's the crux of my problem.

Jackery
88
Jackery  
I still haven't been able to figure this out. Could someone please help me.
Jackery
88
Jackery  
I haven't been able to fix this. Please help.
To add comments, please log in or register