Class4_EURJPY_buy
Download scriptThis script functions as a data generation tool designed to systematically map out potential combinations of trading actions across five specific currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD. Instead of executing live trades, the script acts as an automated "combinatorics engine" that identifies and logs specific patterns into a text file for later review.
Core Logic Overview
The script operates by systematically cycling through every possible permutation of two binary states (Buy or Sell) for each of the five currency pairs mentioned. It treats these pairs as individual variables in a multi-dimensional grid.
How it Processes Data:
- Systematic Iteration: The program uses a series of nested loops to move through every possible combination of actions. For every currency pair, it calculates what happens if it is either in a "Buy" state (represented by the first numerical value) or a "Sell" state (represented by the second).
- Balance Tracking: As the script cycles through these combinations, it maintains a running count of total "Buys" versus total "Sells." It identifies specific scenarios where the number of Buy actions and Sell actions are balanced—or nearly balanced (differing by only one).
- Filtering Criteria: The script does not log every possible combination. It applies three specific filters before saving any data:
- The count of Buys must be nearly equal to the count of Sells.
- There must be at least one action performed (it ignores completely empty states).
- It specifically isolates results where the third currency pair (EURJPY) is in its primary "Buy" state.
- Data Logging: Every time a combination meets all the above criteria, the script captures the specific numerical code of that combination, the final count of Buys and Sells, and a text description of which currency pairs are being acted upon.
Output
The final result is a structured CSV (comma-separated values) file named Class4_EURJPY_buy.txt. This file serves as a comprehensive directory of "balanced" trading configurations. For a user, this script essentially creates a roadmap of mathematical possibilities, allowing you to see which combinations of trades across five different markets result in an equilibrium between buying and selling pressure.
//+------------------------------------------------------------------+
//| 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_buy.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==0)
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