The XMA_Divergence indicator with the possibility to change the indicator timeframe from input parameters:
input ENUM_TIMEFRAMES TimeFrame=PERIOD_H4; // Indicator chart period (timeframe)
The indicator requires the XMA_Divergence.mq5 indicator file for operation. Add it to <terminal_data_folder>\MQL5\Indicators.

Fig.1. The XMA_Divergence_HTF indicator.