Class4_GBPUSD_buy
Download scriptThis script is designed as a data generation tool that systematically calculates and logs specific combinations of trading scenarios into a structured text file. Instead of executing live trades or analyzing real-time market charts, the logic functions as a mathematical "brute-force" simulator to identify balanced configurations between various currency pairs.
Core Logic Overview
The program operates by cycling through every possible combination of five different variables. Each variable represents a specific state across five different currency pairs: EURUSD, EURCHF, EURJPY, GBPUSD, and AUDUSD. By nesting these variables within multiple loops, the script creates a comprehensive map of every potential mathematical outcome for these pairs.
How the Processing Works
- Scenario Counting: As the script cycles through the combinations, it keeps a running tally of "Buy" signals versus "Sell" signals. It assigns specific numerical values to different positions; for example, one position might trigger a "Buy" count while another triggers a "Sell" count.
- Balance Filtering: The script evaluates every combination to see if the resulting balance between Buys and Sells is relatively equal. Specifically, it looks for scenarios where the number of buys and sells are either identical or differ by only one.
- Data Validation: To ensure the output is meaningful, the script ignores any combinations that result in zero active signals, ensuring that only "active" trading scenarios are captured.
- Specific Target Filtering: There is a specific priority given to the GBPUSD currency pair. The logic ensures that only configurations involving this specific pair are recorded in the final output.
Output and Recording
Once a combination meets all the requirements—being balanced, having active signals, and involving the target currency—the script compiles this data into a standardized string. This string includes:
- The total count of Buy signals.
- The total count of Sell signals.
- The unique numerical code for that specific combination.
- A descriptive label identifying the status of each of the five currency pairs.
Finally, the script automatically saves these successful combinations into a CSV-formatted text file. This allows a user to review a complete list of "balanced" trading configurations offline without having to manually calculate the thousands of possibilities.
//+------------------------------------------------------------------+
//| 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_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(l==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