How to create a loop for an MT4 indicator

JimmyJay

Trader
Jun 20, 2018
1
0
11
43
Hi guys,

I have an indicator that exports historical price data to csv files. I'm not much of a coder and am having trouble with this.

What I'd really, really appreciate it would be if someone would be able to help where and how to put a loop in the indicator, details are as follows:

1. The indicator runs (once I click on it)

2. It exports to csv (which it already does)

3. Waits 60 seconds and then runs through again exporting to a csv

So I guess something like this - [loop starts] [indicator runs] [waits 60 seconds] [loops back to the start and indicator runs again].

If anyone could help that would be great. Thanks a lot. James

The indicator is attached.
 

Attachments

  • out_hist.mq4
    8.3 KB · Views: 3

Enivid

Administrator
Staff member
Nov 30, 2008
18,503
1,351
144
Odesa
www.earnforex.com
Hi Jimmy! Actually, you do not need a loop because MT4 supports its own EventTimer. You can easily set up a timer, which will trigger your custom event every N seconds (or even milliseconds). You can start by reading the help files on EventSetTimer, EventKillTimer, and OnTimer. It is much easier than doing the loops (which is actually not possible in an indicator because of how MetaTrader treats indicator's runtime).

Please post here if you have further questions.