Author: Copyright � 2008, MetaQuotes Software Corp.
Class1

This script is designed to automatically generate a structured dataset of currency pairs and numeric identifiers by systematically exploring every possible combination of values. It functions as a data preparation tool that automates repetitive "brute-force" listing tasks.

Core Operational Logic

1. Systematic Combination Generation The heart of the script is a nested sequence of loops. Think of this as a multi-layered grid: the script starts with a base value (0) for several different categories and moves through every possible increment up to a pre-defined limit (in this case, 2). It explores every mathematical possibility across five distinct "levels" simultaneously.

2. Data Labeling and Mapping For every unique combination generated by these layers, the script constructs a specific text string. This string serves two purposes:

  • It records the numerical coordinates of the current iteration (e.g., "00000").
  • It maps those coordinates to specific currency pairs, including EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD.

3. Automated File Management The script handles all file operations automatically:

  • Initialization: Before creating new data, it clears out any existing file named "Class1" to ensure you are starting with a clean slate.
  • Logging: As the script runs through its combinations, it writes each unique line of data into a CSV (Comma Separated Values) file. This format is easily readable by spreadsheet software like Microsoft Excel.
  • Seamless Writing: The script manages opening the file, moving the "cursor" to the very end of the document to prevent overwriting previous entries, saving the data, and then closing the file properly.

Summary of Purpose

Instead of a human manually typing out hundreds of variations of currency pair combinations, this script automates the process. It creates an exhaustive inventory of data points, ensuring that every possible numeric combination for the selected currencies is captured and organized into a structured file for later use.

Miscellaneous
Uses files from the file systemIt writes information to file
12 Views
0 Downloads
0 Favorites
Class1
//+------------------------------------------------------------------+
//|                                                       Class1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   string fn1="Class1";
   string s1="";
   int max1=2;
   FileDelete(fn1);
   for(int i=0;i<max1;i++)
     for(int j=0;j<max1;j++)
       for(int k=0;k<max1;k++)
         for(int l=0;l<max1;l++)
           for(int m=0;m<max1;m++)
       {
         s1=""+i+""+j+""+k+""+l+""+m+"  "+i+"-EURUSD "+j+"-EURCHF "+k+"-EURJPY "+l+"-GBPUSD "+m+"-AUDUSD";
         Write2(fn1,s1);
         s1="";
       }  
   
         
       
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
int Write2(string filename,string str)
{
//Write log file
   
   int handle; 
   handle = FileOpen(filename,FILE_READ|FILE_WRITE|FILE_CSV,"/t");
   FileSeek(handle, 0, SEEK_END);      
   //FileWrite(handle,"" + TimeToStr(CurTime(),TIME_DATE|TIME_SECONDS) + ": " + str);
   FileWrite(handle,str);
   FileClose(handle);
	//Print(str);
}

Comments