Small description of expert:
The user can set extern variable SpreadToCheck. If current spread will be wider than SpreadToCheck, then expert will record current time and current spread in *.csv file.
For example: The EURUSD default spread at your broker is 3 pips, but sometimes it becomes wider. If you want to find out how often. You can attach Spread check.mq4 expert to EURUSD chart and find out.
If you will attach expert to EURUSD chart then expert will log results in EURUSD.csv file. It will create it under \experts\files directory.
Here will be the expert code or you can download it from our Forex web site. Click Lejupielādēt.
//+------------------------------------------------------------------+
//| Spread check.mq4 |
//| coded by Rolands Auza |
//| www.rm-forex.lv |
//+------------------------------------------------------------------+
#property copyright "coded by Rolands Auza"
#property link " www.rm-forex.lv "
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
extern int SpreadToCheck=0;
int prevBars,out;
double standSpreads;
string Currency,file;
int init()
{
int handle;
int size;
//----
prevBars=Bars;
Currency=Symbol();
file=Currency+".csv";
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
handle=FileOpen(file, FILE_BIN|FILE_READ);
if(handle>0)
{
size=FileSize(handle);
FileClose(handle);
}
if(size<3)
{
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
if(out<1)
{
Print("File not found, the last error is ", GetLastError());
return(0);
}
if(FileSeek(out,0,SEEK_END)) FileWrite(out,"Day","Month","Hour","Minute","Secon ds","Current Spread");
FileClose(out);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double CurrentSpread=MarketInfo(Currency, MODE_SPREAD);
if(CurrentSpread>SpreadToCheck)
{
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
if(out<1)
{
Print("File not found, the last error is ", GetLastError());
return(0);
}
if(FileSeek(out,0,SEEK_END)) FileWrite(out,Day(),Month(),Hour(),Minute(),Second s(),CurrentSpread);
FileClose(out);
}
return(0);
}
//+------------------------------------------------------------------+
The user can set extern variable SpreadToCheck. If current spread will be wider than SpreadToCheck, then expert will record current time and current spread in *.csv file.
For example: The EURUSD default spread at your broker is 3 pips, but sometimes it becomes wider. If you want to find out how often. You can attach Spread check.mq4 expert to EURUSD chart and find out.
If you will attach expert to EURUSD chart then expert will log results in EURUSD.csv file. It will create it under \experts\files directory.
Here will be the expert code or you can download it from our Forex web site. Click Lejupielādēt.
//+------------------------------------------------------------------+
//| Spread check.mq4 |
//| coded by Rolands Auza |
//| www.rm-forex.lv |
//+------------------------------------------------------------------+
#property copyright "coded by Rolands Auza"
#property link " www.rm-forex.lv "
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
extern int SpreadToCheck=0;
int prevBars,out;
double standSpreads;
string Currency,file;
int init()
{
int handle;
int size;
//----
prevBars=Bars;
Currency=Symbol();
file=Currency+".csv";
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
handle=FileOpen(file, FILE_BIN|FILE_READ);
if(handle>0)
{
size=FileSize(handle);
FileClose(handle);
}
if(size<3)
{
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
if(out<1)
{
Print("File not found, the last error is ", GetLastError());
return(0);
}
if(FileSeek(out,0,SEEK_END)) FileWrite(out,"Day","Month","Hour","Minute","Secon ds","Current Spread");
FileClose(out);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
double CurrentSpread=MarketInfo(Currency, MODE_SPREAD);
if(CurrentSpread>SpreadToCheck)
{
out=FileOpen(file,FILE_CSV|FILE_READ|FILE_WRITE,'; ');
if(out<1)
{
Print("File not found, the last error is ", GetLastError());
return(0);
}
if(FileSeek(out,0,SEEK_END)) FileWrite(out,Day(),Month(),Hour(),Minute(),Second s(),CurrentSpread);
FileClose(out);
}
return(0);
}
//+------------------------------------------------------------------+
Forex and currency trading rullz!