Class4_EURUSD_not

Download script
Author: Copyright � 2008, MetaQuotes Software Corp.
Class4_EURUSD_not

This script is designed to automate the generation of a structured data report based on specific combinations of currency pairs and their associated actions. It essentially acts as a "brute-force" generator that systematically calculates and logs various scenarios into an external text file.

Core Functionality

The script evaluates every possible combination across five different currency pairs (EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD). For each pair, it considers two potential states: a "Buy" action or a "Sell" action.

By nesting these possibilities, the tool explores a vast grid of outcomes to identify specific patterns where the number of Buy signals and Sell signals are nearly equal.

How the Logic Works

The logic follows a systematic step-by-step process:

  1. Initialization: The script starts by creating (or clearing) a dedicated log file named Class4_EURUSD_not.txt. This is where all the results will be saved for later review.
  2. Combination Mapping: It runs through five layers of loops, with each layer representing one of the currency pairs mentioned above.
  3. Tallying Actions: As it moves through these combinations, it keeps a running count of "Buy" actions versus "Sell" actions. If a specific position in the sequence is designated as a Buy, it adds to the Buy tally; if it is a Sell, it adds to the Sell tally.
  4. Filtering Criteria: The script does not save every single combination. It applies three specific filters before deciding to write data to your file:
    • Balance: The number of Buys and Sells must be equal, or differ by only one (e.g., a 3:3 split, a 4:3 split, or a 3:4 split).
    • Activity: There must be at least one Buy and one Sell present in the combination.
    • Specific Indexing: It specifically targets a unique scenario where the first currency pair in the sequence reaches a specific threshold (represented by the index "2").
  5. Data Export: When a combination meets all the criteria above, the script compiles a string of information including the total count of Buys/Sells, the raw numerical code of the combination, and a human-readable description of the pairs involved. It then appends this information into the text file.

Final Output

The end result of this script is a structured CSV-style text file. This file serves as a comprehensive list of all mathematically valid "balanced" combinations across your chosen currency pairs, allowing you to see which specific configurations meet your predefined trading logic requirements.

Miscellaneous
Uses files from the file systemIt writes information to file
5 Views
0 Downloads
0 Favorites
Class4_EURUSD_not
//+------------------------------------------------------------------+
//|                                                       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_EURUSD_not.txt";
   string s1="";
   string cod1="";
   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++;           
             cod1=""+i+""+j+""+k+""+l+""+m;
             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))
             if(i==2)
               Write2(fn1,s1);
               
             s1="";
             cod1="";
             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