Class4_EURCHF_buy
Download scriptSystem Overview
This script is designed to automate a comprehensive data-gathering process for currency pairs. Its primary objective is to systematically evaluate a wide variety of trading combinations and record specific results into an external log file for later analysis. Rather than making live trades, this tool functions as a "simulation engine" that calculates mathematical balances between different assets.
How the Logic Works
1. Data Preparation The script begins by preparing a dedicated workspace by creating (or clearing) a specific text file. This file serves as a permanent record where all generated data will be stored.
2. Multi-Dimensional Exploration The core of the script utilizes a "nested" search logic. It looks at five different currency pairs simultaneously:
- EURUSD
- EURCHF
- EURJPY
- GBPUSD
- AUDUSD
It treats these pairs as variables in a massive grid. By nesting several layers of loops, the script explores every possible combination of positions for these five assets across multiple states.
3. Scoring and Balancing As the script moves through these combinations, it assigns "Buy" points and "Sell" points based on the current state of the loop:
- It identifies specific conditions that trigger a Buy count.
- It identifies opposing conditions that trigger a Sell count.
The system constantly monitors the relationship between these two scores. It is specifically looking for "balanced" scenarios—situations where the number of Buy points and Sell points are equal, or differ by only a single digit (e.g., a 5 to 4 balance).
4. Filtering and Validation Not every combination generated is saved. The script applies three specific filters before recording any data:
- Balance Check: It only saves results where the Buy and Sell scores are nearly equal.
- Activity Check: It ensures that neither the Buy nor the Sell count is zero (it ignores empty scenarios).
- Pair Specificity: It specifically focuses on capturing the data when the second currency pair in its sequence meets a specific criteria.
5. Data Recording When a combination meets all the requirements above, the script formats a detailed string of information. This includes:
- The final calculated Buy and Sell scores.
- The unique "code" (the coordinate) of the combination found.
- A descriptive summary of which currency pairs were involved in that specific iteration.
Finally, the script opens the external file, appends this summarized data to the end of the document, and closes the file, repeating this process until every possible combination has been tested.
//+------------------------------------------------------------------+
//| 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_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(j==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