exoticwavein

Download script
Author: Copyright � 2005, Sprrite&Lemon
exoticwavein

This script is designed as a data management tool for MetaTrader users who need to export historical market information into an external format. Rather than acting as a visual trading indicator that shows signals on your screen, its primary function is to systematically organize and save price history into CSV files on your computer.

Core Functionality

The logic follows a structured process to convert live chart data into organized spreadsheet-ready files:

1. Intelligent Delay System To prevent the software from overwhelming your computer's resources, the script includes a "waiting" mechanism. It counts incoming price updates (ticks) and remains idle until a specific threshold is reached. This ensures the export process happens smoothly without interfering with your active trading platform.

2. Dynamic File Identification The script automatically detects which timeframe you are currently viewing (e.g., 1 minute, 1 hour, Daily, Weekly, or Monthly). It then generates a unique, organized file name based on that specific time period and the currency symbol you are trading. For example, if you are looking at a Daily chart for EURUSD, it identifies the correct folder path and naming convention automatically.

3. Comprehensive Data Extraction The tool scans through the available history of the current chart. For every single candle (bar) in the history, it extracts seven key pieces of information:

  • Time Stamps: It breaks down the date and time into Year, Month, Day, Hour, and Minute.
  • Price Action: It captures the Open, High, Low, and Close prices.
  • Trading Volume: It records the volume associated with each period.

4. Automated Data Export Once the data is gathered, the script performs the following:

  • It creates a new CSV file (a standard format readable by Excel or Google Sheets).
  • It writes every piece of extracted information into a clean, comma-separated row.
  • It provides a status update on your chart screen to confirm exactly which date and time range has been successfully saved.

Summary for the User

Think of this script as an automated "Data Archiver." Instead of you having to manually copy and paste price data into a spreadsheet, this tool does the heavy lifting by scanning your chart history and building a perfectly formatted file that is ready for external analysis or record-keeping.

Miscellaneous
Implements a curve of type %1Uses files from the file systemIt writes information to file
11 Views
0 Downloads
0 Favorites
exoticwavein
//+------------------------------------------------------------------+
//|                  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
int              Bar;
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)  
	{
     //  ???
     if (Period()==10080) sName="monthly"+"\\"+Symbol()+Period()+".csv";
     if (Period()==43200) sName="weekly"+"\\"+Symbol()+Period()+".csv";
     if (Period()==1440) sName="daily"+"\\"+Symbol()+Period()+".csv";
     if (Period()==240) sName="4_hour"+"\\"+Symbol()+Period()+".csv";
     if (Period()==60) sName="1_hour"+"\\"+Symbol()+Period()+".csv";
     if (Period()==30) sName="half_hour"+"\\"+Symbol()+Period()+".csv";
     if (Period()==15) sName="quarter_hour"+"\\"+Symbol()+Period()+".csv";
     if (Period()==5) sName="5_min"+"\\"+Symbol()+Period()+".csv";
     if (Period()==1) sName="1_min"+"\\"+Symbol()+Period()+".csv";

     // ??????? ?????????? 
     FileDelete(sName);
     file =FileOpen(sName,FILE_CSV|FILE_WRITE,",");


    // FileWrite(file,sh);
 
    shift=Bars+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