//////////////////////////////////////////////////////////////////////////////// // Mechanical trade system for MetaTrader 5 // // Copyright (c) 2010 Interesting // //////////////////////////////////////////////////////////////////////////////// // User script "Synchronizing the timeframes of the charts" // // Unit: ChgTF-All // //////////////////////////////////////////////////////////////////////////////// // Version: 1.0 // // Version File: 1.0.0.0 // // File name: ChgTF-All.mq5 // //////////////////////////////////////////////////////////////////////////////// // Property // //////////////////////////////////////////////////////////////////////////////// #property description "User script - Synchronizing the timeframes of the charts" #property description "Version File: 1.0.0.0" #property copyright "Copyright 2010, Interesting" #property link "http://www.mql5.com" #property script_show_inputs //////////////////////////////////////////////////////////////////////////////// // The arrays for keeping main data // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Input parameters // //////////////////////////////////////////////////////////////////////////////// input ENUM_TIMEFRAMES WorkPeriod = PERIOD_M5; //Work period //////////////////////////////////////////////////////////////////////////////// // Global variables, used in working the script // //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Script program start function // //////////////////////////////////////////////////////////////////////////////// void OnStart() { //----------------------------------------------------------------------------// //Work variables ENUM_TIMEFRAMES TimeFrames; //TimeFrames string ChartSymbolName; //The symbol name for the specified chart long ChartFirstID; //The ID of the first chart of the client terminal long ChartNextID; //Identifier for of the new chart int Limit= CHARTS_MAX; int f; //----------------------------------------------------------------------------// //Checking parameters if(WorkPeriod == PERIOD_CURRENT) TimeFrames = _Period; else TimeFrames = WorkPeriod; //Synchronizing the timeframes of the charts ChartFirstID = ChartFirst(); //Processing of the main chart if(ChartPeriod(ChartFirstID)!= TimeFrames) { ChartSymbolName = ChartSymbol(ChartNextID); //Change the timeframe of the specified chart ChartSetSymbolPeriod(ChartFirstID,ChartSymbolName,TimeFrames); //Message for user PrintFormat("Change the timeframe of the chart %s. New period %s", ChartSymbolName,PeriodToStr(TimeFrames)); } //Processing of additional charts while(f