Class4_GBPUSD_not
Download scriptThis script is designed to perform a systematic data generation and logging process for currency pairs. It essentially acts as an automated "combinatorial explorer" that tests various configurations of buy and sell signals across five specific currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD.
Core Logic Overview
The script functions by running through a multi-layered nested loop. It evaluates every possible combination of three states (indexed as 0, 1, and 2) for each of the five currency pairs. By iterating through these levels, the tool calculates the cumulative number of "buy" and "sell" signals based on the specific indices selected in each iteration.
How it Processes Information
- Signal Counting: As the script cycles through the combinations, it identifies whether a position is designated as a buy or a sell. It keeps a running tally of these counts for every unique configuration it encounters.
- Filtering Criteria: Not every combination is saved to the final report. The script applies specific logical filters to ensure that only relevant data is recorded. Specifically, it looks for configurations where:
- The number of buy and sell signals are nearly equal (balanced).
- There is at least one buy signal and one sell signal present in the combination.
- A specific condition regarding the fourth currency pair (GBPUSD) is met.
- Data Recording: When a combination meets all the above criteria, the script generates a formatted string containing the total count of buys, the total count of sells, the unique identification code for that combination, and a detailed list of the currency pairs involved.
Output Generation
The final result of this logic is the creation of a dedicated text file (CSV format). The script automatically deletes any existing file with the name Class4_GBPUSD_not.txt before it starts, ensuring that you are always looking at fresh data. It then populates this file with the valid configurations discovered during its execution, providing a structured log of all combinations that satisfy your specific trading parameters.
//+------------------------------------------------------------------+
//| 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_GBPUSD_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(l==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