//+------------------------------------------------------------------+ //| TimeSwitcher| //| Copyright 2024, YourCompany| //| https://www.yourcompany.com| //+------------------------------------------------------------------+ #property strict input ENUM_TIMEFRAMES TimeFrames[] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_H1}; // Define the time frames to switch between //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { EventSetTimer(1); // Start the timer return INIT_SUCCEEDED; } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { EventKillTimer(); // Stop the timer } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTimer() { static int currentTF = 0; if(currentTF >= ArraySize(TimeFrames)) currentTF = 0; ChartSetInteger(0, CHART_FOREGROUND,true); // Ensure the chart is in foreground PeriodSet(TimeFrames[currentTF]); // Switch to the next time frame currentTF++; // Move to the next time frame for the next switch } //+------------------------------------------------------------------+
Benjaminmark #: Thank you, my friend, for helping me, but I have encountered some errors. Can you fix them for me, as I cannot program?
Files:
1712754950020.jpg
3663 kb
1712754950004.jpg
3500 kb
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Code for switching between continuous time frames (indicator or script) Code to switch from the M1 time frame to the M5 time frame and then back to the M1 time frame again, and so on constantly. Meaning Every minute, the indicator or script switches the chart from the M1 time frame to the M5 time frame and then back to the M1 time frame.
With every minute, the indicator or script switches the chart from the M1 time frame to the M5 time frame and then back to the M1 time frame.