Class4_EURCHF_not
Download scriptThis script is designed as a systematic data generator that automates the process of testing and documenting various combinations of trading signals across five different currency pairs. Instead of manually calculating every possible scenario, the script uses a nested multi-layered approach to explore every mathematical possibility within a defined set of parameters.
Core Logic Overview
The script functions by creating a "brute force" matrix of scenarios. It iterates through five different dimensions (each representing a specific currency pair: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD). For each dimension, it evaluates three distinct states. By nesting these loops, the script generates thousands of unique combinations to see how different signals interact with one another.
How the Evaluation Works
For every combination generated, the script performs the following steps:
- Signal Counting: It tracks how many "Buy" signals versus "Sell" signals are active across all five currency pairs simultaneously.
- Balance Filtering: The script specifically looks for "balanced" states. It identifies scenarios where the number of Buy and Sell signals are either equal or differ by only one. This ensures that it ignores extreme lopsided data and focuses on balanced market conditions.
- Activity Verification: It filters out any results where there are zero actions, ensuring that only active trading configurations are recorded.
- Specific Parameter Filtering: It applies a final filter to capture specific data points (specifically targeting the third state of the second currency pair) to narrow down the results to the exact requirements needed for analysis.
Data Output
Once a combination meets all the criteria—balanced signals, active participation, and the correct parameter state—the script automatically compiles this information into a structured format. This includes:
- The total count of Buy and Sell signals.
- The specific numerical code representing the state of each currency pair.
- A human-readable string identifying which currencies are being acted upon.
The final result is saved into an external text file (Class4_EURCHF_not.txt). This allows a user to review a comprehensive list of all valid market configurations without having to manually run calculations or monitor the markets in real-time. It essentially acts as a "pre-calculation" engine for complex trading strategies involving multiple currencies.
//+------------------------------------------------------------------+
//| 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_EURCHF_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(j==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