Re: Something interesting please post here (Metatrader)

4336
So here is answer from AI, about that dynamic MTF.
In this code, the MTF (Multi-Timeframe) logic is centered on the following lines where the data from the higher timeframe is identified and synced:
Line 11: extern int TimeFrame = 60;
This defines the external input for the higher timeframe (e.g., 60 for H1).
Line 48: int j = iBarShift(NULL, TimeFrame, Time[pos]);
This is the core MTF line. It uses the time of the current chart bar (Time[pos]) to find the corresponding bar index (j) on the higher timeframe. This ensures the indicator looks at the correct historical point in time.
Lines 51 & 54: GetPrice(j, TimeFrame) and GetPrice(j + i, TimeFrame)
These calls trigger the helper function to fetch price data specifically from the TimeFrame defined in the inputs, rather than the chart's default period.
Lines 82–92: double GetPrice(int shift, int tf) { ... }
This custom function contains the iOpen, iHigh, iLow, and iClose calls. By passing tf (the higher timeframe) into these functions, the indicator pulls data from the "outside" timeframe.
In short: Line 48 handles the time synchronization, and the helper function starting at line 82 retrieves the actual price data from the higher timeframe.