Author: Copyright � 2008, MetaQuotes Software Corp.
Class4

This script functions as an automated data generation tool designed to systematically explore and log various combinations of trading signals across multiple currency pairs. It operates by running through a multi-layered brute-force simulation to identify specific patterns of "Buy" and "Sell" actions.

Core Logic Overview

The primary objective of this script is to cycle through every possible numerical combination for five different currency pairs (EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD). It treats each currency pair as a variable that can be assigned to either a "Buy" state or a "Sell" state.

How the Process Works

  • Exhaustive Iteration: The script uses five nested loops to test every mathematical possibility for the five currencies listed. By cycling through these variables, it creates a comprehensive map of how different trade positions interact with one another.
  • Signal Counting: As the script moves through these combinations, it keeps a running tally of how many "Buy" signals and "Sell" signals are active at any given moment.
  • Validation Criteria: The logic specifically looks for balanced scenarios. It identifies and flags combinations where the number of Buy signals is nearly equal to the number of Sell signals (specifically, when they are equal, or differ by only one).
  • Filtering: To ensure the data is meaningful, the script ignores any combinations that result in zero actions; it only focuses on active trading scenarios.

Data Output

Once a combination meets the criteria—meaning there is an active trade occurring and the balance between Buy and Sell signals is relatively even—the script captures that specific configuration. It then saves this information into an external file.

The recorded data includes:

  1. The total count of Buy and Sell signals for that specific configuration.
  2. The numerical coordinates of the combination.
  3. A clear mapping of which specific currency pair was assigned to which action (Buy or Sell).

In essence, this tool acts as a "permutation generator," producing a detailed log of balanced trading setups across multiple markets simultaneously.

Miscellaneous
Uses files from the file systemIt writes information to file
15 Views
0 Downloads
0 Favorites
Class4
//+------------------------------------------------------------------+
//|                                                       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="Class4";
   string s1="";
   int max1=3;
   int nrbuy=0;
   int nrsell=0;
   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++)
           {
             if(i==0) nrbuy++;
             if(i==1) nrsell++;           
             if(j==0) nrbuy++;
             if(j==1) nrsell++;             
             if(k==0) nrbuy++;
             if(k==1) nrsell++;             
             if(l==0) nrbuy++;
             if(l==1) nrsell++;             
             if(m==0) nrbuy++;
             if(m==1) nrsell++;           
             s1=""+nrbuy+" "+nrsell+" "+i+""+j+""+k+""+l+""+m+"  "+i+"-EURUSD "+j+"-EURCHF "+k+"-EURJPY "+l+"-GBPUSD "+m+"-AUDUSD";
             if((nrbuy==nrsell) || (nrbuy-1==nrsell) || (nrbuy==nrsell-1))
             if((nrbuy!=0))
             if((nrsell!=0))
               Write2(fn1,s1);
               
             s1="";
             nrbuy=0;
             nrsell=0;             
           }  
         }  
       }  
     }  
   }
         
       
   
//----
   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