HighLowExtractor
Download scriptThis script is designed to automatically capture and archive specific price movement data from your trading charts directly into a CSV file. It focuses on measuring the total "range" of price action for each completed candle.
How it Works
Every time the software runs, it looks back at the most recently completed bar on your chart. It performs three primary actions:
- Range Calculation: The script identifies the highest price point (High) and the lowest price point (Low) reached during that specific bar. It calculates the mathematical difference between these two points to determine the total volatility or "spread" of that period. This value is then adjusted to match the correct decimal precision of your specific currency pair or asset.
- Data Collection: Along with the calculated range, the script gathers several other key pieces of information from that same bar, including:
- The exact time the bar occurred.
- The opening price.
- The closing price.
- The high and low price points.
- Automated Logging: The script automatically creates (or updates) a dedicated spreadsheet file on your computer. The filename is intelligently named based on the asset you are trading and the timeframe you have selected (for example, it will distinguish between a 1-minute chart and a 1-hour chart).
Key Features for the User
- Automatic Updates: You do not need to manually record data; the script handles the extraction as new bars form.
- Easy Export: By saving this information into a CSV format, the data can be easily opened in programs like Microsoft Excel or Google Sheets for further analysis.
- Dynamic Formatting: The tool automatically adjusts its file naming and decimal calculations so that you don't have to manually configure it for different types of assets (like Forex, Gold, or Stocks).
//+------------------------------------------------------------------+
//| HighLowExtractor.mq4 |
//| ttitto |
//|Extracts the difference between high and low of a bar and
// writes it a file |
//+------------------------------------------------------------------+
#property copyright "ttitto"
#property link ""
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
datetime PreviousBarTime;
int HighLowDifference;
int handle;
HighLowDifference=(High[1]-Low[1])*MathPow(10,Digits);
PreviousBarTime=Time[1];
handle=FileOpen(Symbol()+"_HighLowExtractor_"+Period()+"M.csv", FILE_CSV|FILE_READ|FILE_WRITE, ';');
if(handle>0)
{
FileSeek(handle,0,SEEK_END);
FileWrite( handle,TimeToStr(PreviousBarTime), Close[1], Open[1], High[1], Low[1], HighLowDifference);
FileClose(handle);
}
return(0);
}
//+------------------------------------------------------------------+
Comments