exoticwave_v1
Download scriptThis tool is designed to automatically extract and export historical market data from your MetaTrader platform into an external spreadsheet format (CSV file). It acts as a bridge between your live trading charts and your personal records, ensuring that data is captured systematically without manual entry.
Core Functionality
The primary purpose of this script is to scan your trading history for a specific number of price bars—which you can define in the settings—and save that information into a dedicated file on your computer. This is particularly useful for traders who need to perform offline analysis, backtesting, or record-keeping using external software like Microsoft Excel.
How it Works
The logic follows a structured sequence to ensure data integrity:
- Initialization and Delay: To prevent the system from overwhelming your computer's resources, the script includes a small "waiting period." It counts the first few price movements (ticks) before beginning its primary task. This ensures the platform is stable before the heavy lifting starts.
- File Management: The script automatically generates a unique filename based on the specific financial instrument (e.g., EURUSD) and the time frame you are currently viewing on your chart. If a file with that name already exists, it prepares to refresh or overwrite it to ensure you always have the most current data.
- Data Extraction: The script "walks" backward through the history of the chart starting from your chosen starting point. For every candle (bar) it encounters, it identifies:
- The precise date and time (Year, Month, Day, Hour, Minute, and Second).
- The key price points (Open, High, Low, and Close prices).
- The trading volume.
- Formatting: It standardizes the time format into a clean, readable string, ensuring that months, days, hours, and minutes are always presented with leading zeros (e.g., "05" instead of "5") for consistency in your final spreadsheet.
- Completion: Once the script has finished processing all the requested bars, it closes the file to protect the data and displays a confirmation message on your chart screen to let you know the export was successful.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Copyright © 2005, FX Waves :)
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Sprrite&Lemon"
#property link "wladimir447@yandex.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- input parameters
extern int Bar=1900;
extern int LastBar=0;
extern int cnttik = 3 ;
double ExtMapBuffer1[];
// ??????? ???? ? ?? ?????? N-? ??? ????????? ???? ?????????
int tick = 0 ;
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
string sName="",ss1=" ",ss2=" ";
int file=0, NumBar=0, shift=0;
int Ye=0,Mo=0,Da=0,Ho=0,Mi=0,Se=0,Ti=0;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if (counted_bars<0) return(-1);
// ??????? ???? ;
tick++;
if ( tick <= cnttik )
{
Print(" Tick = ", tick);
Comment( tick ,"/", cnttik ," | " , Bars);
// ????? ???? ! - ?????????
return(0) ;
}
else
{
tick = 0 ;
// ??????? ??????????? ????
//int rfile = FileOpen("sprrite.csv",FILE_CSV|FILE_WRITE,",");
//FileWrite(rfile,"yes");
//FileClose(rfile);
}
//int filesh = FileOpen("zag.csv",FILE_CSV|FILE_READ);
// string sh = FileReadString(filesh);
// FileClose( filesh );
//----
if ( 1 == 1)
{
// ???
sName=Symbol()+Period()+".csv";
// ??????? ??????????
FileDelete(sName);
file =FileOpen(sName,FILE_CSV|FILE_WRITE,",");
// FileWrite(file,sh);
shift=Bar+LastBar-1;
while(shift>=0)
{
Ti=Time[shift];
Ye=TimeYear(Ti);
Mo=TimeMonth(Ti);
Da=TimeDay(Ti);
Ho=TimeHour(Ti);
Mi=TimeMinute(Ti);
if ( Ho == 0 && Mi == 0 ) Mi = 1 ;
Se=TimeSeconds(Ti);
ss1=Ye;
if (Mo<10) ss1=ss1+"0"+Mo; else ss1=ss1+Mo;
if (Da<10) ss1=ss1+"0"+Da; else ss1=ss1+Da;
if (Ho<10) ss2="0"+Ho; else ss2=Ho;
if (Mi<10) ss2=ss2+"0"+Mi; else ss2=ss2+Mi;
FileWrite(file,ss1,ss2,Open[shift],High[shift],Low[shift],Close[shift],Volume[shift]);
shift--;
}
Comment( " Save of "+ss1+" "+ss2+" is ok" , " === " , Bars);
NumBar=counted_bars;
FileClose(file);
Print(" ???????? " , Bars);
}
//----
return(0);
}
Comments