Class4_GBPUSD_sell
Download scriptThis script is designed to automate the systematic evaluation of different trading combinations across five specific currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD. Its primary goal is to identify specific numerical patterns that meet predefined mathematical criteria and record those results into an external log file for later review.
Core Operational Logic
1. Systematic Iteration (The Testing Grid) The script operates by running through a multi-layered "grid" of possibilities. It systematically cycles through every possible combination of values (from 0 to 2) across five different categories. Think of this as a massive nested checklist where the program tries every variation of "Buy" and "Sell" signals for each currency pair simultaneously.
2. Scoring Mechanism As the script moves through these combinations, it tracks two primary scores:
- Buy Count: The number of times a "Buy" condition is triggered.
- Sell Count: The number of times a "Sell" condition is triggered.
The logic assigns these points based on the specific position within the sequence. For instance, if a certain variable falls into a "Buy" category, it increments the Buy counter; if it falls into a "Sell" category, it increments the Sell counter.
3. Filtering and Validation Criteria Not every combination generated by the grid is saved. The script applies three specific "filters" to decide which data points are relevant enough to be recorded:
- Balance Check: The number of Buy signals must be almost equal to the number of Sell signals (specifically, they must be equal, or differ by only one). This ensures the script focuses on balanced scenarios.
- Activity Check: There must be at least one Buy signal and at least one Sell signal present in the combination.
- Specific Pair Filter: The logic specifically isolates results where the fourth currency pair (GBPUSD) meets a specific condition (a value of 1).
4. Data Logging Whenever a combination successfully passes all the filters mentioned above, the script generates a summary string. This string includes:
- The final Buy and Sell scores.
- The raw numerical codes used to create that combination.
- A human-readable map showing which specific currency pairs were associated with those numbers.
5. Output Generation
Finally, the script handles the physical creation of a report. It creates (or updates) a CSV file named Class4_GBPUSD_sell.txt. It takes the validated data strings and writes them line-by-line into this file. This allows the user to open a spreadsheet or text file to see all the "balanced" trading combinations that met the script's internal rules without having to run the calculations manually.
//+------------------------------------------------------------------+
//| 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_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(l==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