Generally I know how to search for a pattern in lower timeframes between two datetime values. I need to do something a bit different now. How can I search within for patterns on lower timeframes within one candle? For example, say, I have an H1 bullish candle and I want to search for a candle pattern on say, M20, M15 and M10 with that H1, how will this be done.
You need to work with the CopyRates function (apply the third form - request from time to time).
string symbol_name, // symbol name
ENUM_TIMEFRAMES timeframe, // period
datetime start_time, // start date and time
datetime stop_time, // end date and time
MqlRates rates_array // target array to copy
Use the opening time of candles on a higher timeframe as the start and end time.
Here it will be like this: 'timeframe' is the timeframe on which you will search for the pattern (for example, it will be PERIOD_M15). 'start_time' and 'stop_time' - opening time of candles from the PERIOD_H1 timeframe
iTime and iBarShift feel sufficient for what I want to achieve. Though I would definitely want to check how I could implement it with CopyRates in the near future.
Using the same timeframe for both start and end time causes an issues when trying to get the range of indexes for lower timeframes for my search with iBarShift.
After looking at the definition of CopyRates I think I understand why you recommend I use it. Though I'm still trying to fully understand how to apply it. I would really appreciate some more info on applying it directly to my problem.
I cannot tell you anything, since you did not indicate what you need. For example, I expect something like this: how can I find two candles that go in sequence (two bullish candles or two bearish ones) inside the 'H1' candle on the 'PERIOD_M15' timeframe)
Okay, let me be more specific. I am looking for a bearish candle on M20 which has a close the same as another bearish candle contained in an M30 candle and finally both contained within an H1 bullish candle with the same close as the two M20 and M30 candles.
So we have the close of candles on 3 timeframes coinciding with the H1 being a bullish candle and M30 and M20 being bearish.
In case this is a bit confusing, I’ve attached screenshots to an example with the three timeframes.
The original screenshots that I provided didn't have enough information explaining what I desire to achieve. I've updated the screenshots now.
On any timeframe, the current candle has the same 'Close' price. Therefore, your 'pattern' is not really any pattern.
But the current candle could be a bullish or a bearish candle too. Also please note that this is just one use case of certain types of patterns that I am researching on that have a high/low/open or close preserved over various lower timeframes within a given candle. I decided to start with this.
Being able to get this one would greatly serve as a foundation for me to work on other more complex patterns
Why did you choose this particular candlestick on the H1 timeframe:
This is not an answer. To refer to a candle you need: either its number or date. Without this data, the train will not run.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.