Class4_EURCHF_sell
Download scriptThis script functions as an automated data generator designed to systematically explore and record various combinations of trading scenarios across five different currency pairs. Rather than executing live trades, the logic serves as a computational "brute-force" tool that maps out specific mathematical relationships between buying and selling actions.
Core Operational Logic
1. Systematic Iteration The script uses a multi-layered nested loop structure to cycle through every possible numerical combination for five distinct variables. Each variable corresponds to a specific currency pair:
- EURUSD
- EURCHF
- EURJPY
- GBPUSD
- AUDUSD
2. Buy/Sell Accumulation As the script cycles through these combinations, it tracks and counts how many "Buy" actions versus "Sell" actions are triggered based on the numerical value assigned to each currency pair. For instance, if a variable is set to 0, it increments a "Buy" counter; if it is set to 1, it increments a "Sell" counter.
3. Filtering and Validation Criteria The script does not record every possible combination it generates. Instead, it applies a specific set of filters to determine which results are worth saving. A combination is only recorded in the final output if it meets all of the following conditions:
- Balanced Weighting: The total number of Buy actions and Sell actions must be nearly equal (specifically, they must be equal, or differ by only one).
- Activity Requirement: There must be at least one Buy action and at least one Sell action present in the combination.
- Specific Pair Constraint: The logic specifically filters for instances where the second currency pair (EURCHF) is set to a "Sell" state.
4. Data Logging and Export Whenever a combination meets all the criteria mentioned above, the script formats the data into a readable string. This string includes:
- The total count of Buy vs. Sell actions.
- The specific numerical codes for each of the five currency pairs.
- A clear text label identifying which currency pair corresponds to which code.
All valid results are then automatically saved to an external CSV file. This allows the user to review a structured list of all mathematically "balanced" trade configurations that meet the predefined requirements, which can then be used for further analysis or strategy development.
//+------------------------------------------------------------------+
//| 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_sell.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==1)
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