Class4_EURJPY_not
Download scriptThis script is designed to perform an automated exhaustive search of trading combinations across five different currency pairs. Its primary purpose is to identify specific mathematical balances between "Buy" and "Sell" positions within a structured grid of possibilities.
How the Logic Works
1. The Grid System The script evaluates five specific currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD. For each of these pairs, it explores three distinct states (represented by numerical markers). These states act as variables that determine whether a "Buy" or a "Sell" signal is being triggered for that specific pair in a given combination.
2. Iterative Combination Testing The program uses a nested looping structure to systematically cycle through every possible permutation of these five pairs and their three states. It essentially creates a massive matrix of every possible scenario, checking each one individually to see how the "Buy" and "Sell" counts accumulate.
3. Filtering and Criteria As the script moves through these combinations, it tracks the total number of Buy signals versus Sell signals:
- Balance Check: It looks for scenarios where the number of Buys and Sells are equal, or differ by only one (e.g., a 5/4 split).
- Activity Check: It ensures that the combination actually contains at least one Buy and one Sell signal to avoid recording empty data.
- Specific Pair Filtering: There is a specific condition that limits the results to combinations involving the "EURJPY" pair (the third position in the sequence).
4. Data Logging When a combination meets all the above criteria, the script records the result into an external text file. Each entry in this file includes:
- The total count of Buy signals.
- The total count of Sell signals.
- A unique code identifying that specific combination.
- A descriptive string mapping those codes back to the actual currency pairs.
Summary for the User
Essentially, this script acts as a combination generator. Instead of trading live, it "pre-calculates" and exports a list of all mathematically balanced trade configurations across your chosen currency pairs. You can use the resulting text file to see which combinations of Buy and Sell positions maintain a neutral balance while involving specific currency requirements.
//+------------------------------------------------------------------+
//| 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_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(k==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