English

## Quantitative research in MT4

Back to topics list To post a new topic, please log in or register
 15 rori4 2014.03.10 18:16   Hello guys, I was wondering if there is a way to get data with an indicator or an EA that will count how many bars on average was the price not touching the Moving average. I tried searching the forum and other sources but I don't know what exactly should I search for. Thanks in advanse
 1815 SDC 2014.03.10 19:28 #   If you have coding experience you could write a script to check each Bar against a moving average and count each one that doesnt touch. Look up iMA() and Bars. In the documentation.
 15 rori4 2014.03.10 20:04 #   yes I know the function iMA() and Bars and I have some exp in coding. But the question is how to count and save the data. For example It should count the bars that were above or below (not touching the MA) a certain period and save that info somewhere and after that sum those numbers up and divide it to the number of crosses that the price made. I am just not sure if that is possible to do in MT4.
 Moderator3516 GumRai 2014.03.10 22:58 #   Count the bars that have their low above the MA and those that have their high below the MA otherwise, they must have straddled the MA
 1815 SDC 2014.03.11 01:01 #   rori4: yes I know the function iMA() and Bars and I have some exp in coding. But the question is how to count and save the data. For example It should count the bars that were above or below (not touching the MA) a certain period and save that info somewhere and after that sum those numbers up and divide it to the number of crosses that the price made. I am just not sure if that is possible to do in MT4. Counting and holding values for calculations is beginner level coding. You probably need to read the MQL4 Book and Reference. You can use For loops for counting and cycling through the Bars and variables for holding the values you want to perform calculations on.

To add comments, please log in or register