How can I start ENUM_TIMEFRAMES variables from a shift of specified minutes from their regular starting times?
I am looking for a pattern match every few minutes. Let's say 3 minutes. I have a specified start time and I want to end at the last closed candle for each timeframe (candle index 1 for every timeframe). How can I handle the various M1 candle residues when they are not enough to form a complete candle for one of the timeframes in the array?
I am trying to figure out how to shift the starting times for the above ENUM_TIMEFRAMES elements so that with a shift of -1 minute
An example which may help - adjust as needed
//+------------------------------------------------------------------+ //| 429580-TimeFrameShifter.mq5 | //| Copyright 2022, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnStart() { ENUM_TIMEFRAMES thisTF = PERIOD_M30; datetime openTime = iTime(_Symbol, thisTF, 0 ); datetime closeTime = openTime + PeriodSeconds(thisTF); for(int min = 0; min <= 5; min++) //Minute shifter { PrintFormat( "min=%i - %s OpenTime = %s Close Time = %s", min, EnumToString(thisTF), TimeToString(openTime), TimeToString(closeTime) ); openTime -= 60; closeTime -= 60; } } //+------------------------------------------------------------------+
I am working with the following array of ENUM_TIMEFRAMES elements:
Normally, PERIOD_M2 starts at 00:00 and continues to 00:02, 00:04 and so on. Also PERIOD_M3 starts at 00:00 and continues to 00:03, 00:06 and so on. The other timeframes follow in a similar manner.
I am trying to figure out how to shift the starting times for the above ENUM_TIMEFRAMES elements so that with a shift of -1 minute
PERIOD_M2 starts at 23:59 and continues to 00:01, 00:0 and so on. Also PERIOD_M3 starts at 23:59 and continues to 00:02, 00:05 and so on.
also for a shift of 1 minute
PERIOD_M2 starts at 00:01 and continues to 00:03, 00:03 and so on. Also PERIOD_M3 starts at 00:01 and continues to 00:04, 00:07 and so on.
and other timeframes follow suit.
I am using this array to compare Open, High, Low and Close of various candlesticks. Below is an example of how I am using the array to compare highs of two candles from two timeframes: