Class4_EURJPY_sell

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

This script is designed to systematically generate and record a variety of specific currency pair combinations into a structured text file. Instead of making real-time trades or performing complex market analysis, the logic functions as an automated data generator that creates a systematic log of possible configurations for five specific currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD.

How the Logic Works

1. Systematic Exploration The script uses a "nested" looping structure, which means it looks at every possible mathematical combination across five different variables. Each variable represents one of the currency pairs mentioned above. Because each variable can have two distinct states (represented as 0 or 1), the script exhaustively checks all 32 possible combinations (2 to the power of 5).

2. Balancing "Buy" and "Sell" Indicators As the script cycles through these combinations, it assigns a "buy" point if a variable is set to 0 and a "sell" point if it is set to 1. For every combination it evaluates, it keeps a running tally of how many buys versus how many sells are present in that specific mix.

3. Filtering Criteria The script does not save every single combination it finds. It applies three specific rules before deciding to record a result:

  • Balance Rule: It only saves combinations where the number of "buys" and "sells" are nearly equal (either exactly the same, or differing by only one).
  • Activity Rule: It ensures that there is at least one "buy" and one "sell" present in the mix; it ignores sets that are entirely one-sided.
  • Specific Pair Target: It specifically looks for combinations where the third currency pair (EURJPY) is set to its secondary state.

4. Data Logging Whenever a combination meets all the criteria above, the script formats a line of text. This line includes the total count of buys and sells, the specific numerical code of the combination, and a text label identifying which currency pairs are being represented. This information is then appended to a file named Class4_EURJPY_sell.txt.

Summary for the User

Think of this script as an automated "combinatorics" tool. It scans through hundreds of ways to group these five currencies together, calculates the balance of those groups, and writes down only the balanced configurations into a permanent log file for later review.

6 Views
0 Downloads
0 Favorites
Class4_EURJPY_sell
//+------------------------------------------------------------------+
//|                                                       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_EURJPY_sell.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(k==1)
               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