Class4_EURUSD_sell

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

This script is designed to systematically generate a data log by testing various combinations of trading actions across five specific currency pairs. It functions as a mathematical "brute-force" scanner that identifies specific patterns of buying and selling behaviors to record in an external file.

Core Logic Overview

The script operates by cycling through every possible combination of two primary actions (buying or selling) for five different currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD. It treats these combinations as a multi-dimensional grid, systematically moving through every iteration to see how the "balance" of buy vs. sell orders changes.

How the Process Works

  • The Grid System: The script uses five nested loops, each representing one of the currency pairs. For each pair, it evaluates two states (coded as a 0 or 1). One state represents a "Buy" action and the other represents a "Sell" action.
  • Accumulation & Counting: As the script moves through these combinations, it keeps a running tally of how many "Buy" actions versus "Sell" actions have been triggered across all five pairs simultaneously.
  • Filtering Criteria: Not every combination is saved. The script specifically looks for "balanced" scenarios. It only records a result if:
    1. The number of Buy actions is equal to the number of Sell actions, OR
    2. There is a difference of exactly one between the two (e.g., 3 buys and 4 sells).
    3. It ensures that at least one action of each type has occurred.
  • Recording Results: When a combination meets these specific balance criteria, the script captures the exact sequence of actions (the "code") and the corresponding count of buys and sells. It then writes this information into a text file named Class4_EURUSD_sell.txt.

Final Output

The end result is a structured CSV-style log file. This file acts as a registry of all valid combinations where the trading actions across the five currencies remain relatively balanced. This type of logic is typically used for identifying equilibrium points or systematic distributions in multi-currency environments.

Miscellaneous
Uses files from the file systemIt writes information to file
7 Views
0 Downloads
0 Favorites
Class4_EURUSD_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_EURUSD_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(i==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