• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 12:17am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 12:17am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Chart Slide Show Indicator - Auto Rotate Profiles 3 replies

How to copy profiles in MT4? How to use Excel with MT4? 7 replies

is it possible to rotate windows with an EA? 3 replies

How to create profiles in mt4 3 replies

PRICE ALERT in MT4 with different Profiles 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: How to rotate MT4 Profiles every X minutes?
Exit Attachments
Tags: How to rotate MT4 Profiles every X minutes?
Cancel

How to rotate MT4 Profiles every X minutes?

  • Post #1
  • Quote
  • First Post: Dec 13, 2018 8:35am Dec 13, 2018 8:35am
  •  gargindia
  • | Joined Mar 2017 | Status: Member | 86 Posts
Hello Friends,
Anyone know of a script that can rotate created Profiles every X minutes in MT4?
if so please post here or direct me to it.

Thanks
  • Post #2
  • Quote
  • Edited 3:57pm Dec 13, 2018 1:08pm | Edited 3:57pm
  •  Nicholishen
  • Joined Jul 2005 | Status: zzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzz | 1,289 Posts
Quoting gargindia
Disliked
Hello Friends, Anyone know of a script that can rotate created Profiles every X minutes in MT4? if so please post here or direct me to it. Thanks
Ignored
You'll need to run an external script since all MQL programs run on charts, and switching the profile will remove the program from the chart. Here is a python script which will cycle the profiles. You'll need python 3 installed on your computer and then you'd run this from the command line with with the number of seconds to cycle as an arg.

From command-line
Inserted Code
C:\Path\To\Script> python profilecycle.py 60
Attached Image (click to enlarge)
Click to Enlarge

Name: Annotation 2018-12-13 153404.jpg
Size: 24 KB

Script: Runs all terminal windows (MT4/5)
NOTE: This uses regex pattern matching to find terminal windows. This may have unintended consequences if by a stroke of luck another open window's name (non-terminal) matches the pattern as well.
Inserted Code
#profilecycle.py
import argparse
import re
import sys
import time
import win32gui
import pyautogui

class WindowsMgr:
    def __init__(self):
        self._handles = []
    def _window_enum_callback(self, hwnd, pattern):
        win_name = str(win32gui.GetWindowText(hwnd))
        if re.match(pattern, win_name) is not None:
            self._handles.append(hwnd)
    def find_windows_regex(self, pattern):
        self._handles.clear()
        win32gui.EnumWindows(self._window_enum_callback, pattern)
        return bool(self._handles)
    def do_action(self, fn):
        for handle in self._handles:
            win32gui.SetForegroundWindow(handle)
            fn()

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('cycle', help='Time in seconds to cycle the profiles')
    args = parser.parse_args()
    interval = int(args.cycle)
    print(f'Cycling MT profiles @ {interval} second intervals\n'
          f'Press Ctrl+C to exit this script.')
    w = WindowsMgr()
    while True:
        try:
            if w.find_windows_regex(r'\d+\s?[:-]\s.*?-.*'):
                w.do_action(lambda: pyautogui.hotkey('ctrl', 'f5'))
            time.sleep(interval)
        except KeyboardInterrupt:
            sys.exit('Exiting...')

if __name__ == '__main__':
    main()
 
3
  • Post #3
  • Quote
  • Dec 14, 2018 8:31am Dec 14, 2018 8:31am
  •  gargindia
  • | Joined Mar 2017 | Status: Member | 86 Posts
Quoting Nicholishen
Disliked
{quote} You'll need to run an external script since all MQL programs run on charts, and switching the profile will remove the program from the chart. Here is a python script which will cycle the profiles. You'll need python 3 installed on your computer and then you'd run this from the command line with with the number of seconds to cycle as an arg. From command-line C:\Path\To\Script> python profilecycle.py 60 {image} Script: Runs all terminal windows (MT4/5) NOTE: This uses regex pattern matching to find terminal windows. This may have unintended...
Ignored

Thanks Nicholishen.
i am not programming person...if you dont mind,can you please explain how to this step by step.
 
 
  • Post #4
  • Quote
  • Dec 14, 2018 1:22pm Dec 14, 2018 1:22pm
  •  Nicholishen
  • Joined Jul 2005 | Status: zzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzz | 1,289 Posts
Quoting gargindia
Disliked
{quote} Thanks Nicholishen. i am not programming person...if you dont mind,can you please explain how to this step by step.
Ignored

  1. install python https://www.python.org/downloads/
  2. create a text file and paste in the script above and save it as "profilecycle.py"
  3. launch a terminal from the location of the script
  4. run it - "python profilecycle.py 60" ...with "60" being the number of seconds you want to wait between cycles

    1. if you get errors then you need to install the dependencies

      1. from the command line type

        1. pip install pyautogui
        2. pip install pywin32

 
1
  • Post #5
  • Quote
  • Dec 15, 2018 1:11am Dec 15, 2018 1:11am
  •  gargindia
  • | Joined Mar 2017 | Status: Member | 86 Posts
Quoting Nicholishen
Disliked
{quote} install python https://www.python.org/downloads/ create a text file and paste in the script above and save it as "profilecycle.py" launch a terminal from the location of the script run it - "python profilecycle.py 60" ...with "60" being the number of seconds you want to wait between cycles if you get errors then you need to install the dependencies from the command line type pip install pyautogui pip install pywin32
Ignored

Nicholishen Thanks for your healp
 
 
  • Post #6
  • Quote
  • Last Post: Dec 15, 2018 1:31pm Dec 15, 2018 1:31pm
  •  Nicholishen
  • Joined Jul 2005 | Status: zzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzz | 1,289 Posts
Quoting gargindia
Disliked
{quote} Nicholishen Thanks for your healp
Ignored
You're wealcome
 
 
  • Platform Tech
  • /
  • How to rotate MT4 Profiles every X minutes?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023