I have this code:
It is supposed to save the data of the mentioned indicators aside from the standard open, high, low, close data. However I applied it to a chart but it did not work. Could anyone let me know what is wrong with it?
All I am trying to do is export the output from the CCFp indicator from this thread -> http://articles.mql4.com/422
Thank you!
QuoteDisliked/*----------------------------------------------------------------|
// Indicator Export Expert v1, by juanchoc & neo |
//----------------------------------------------------------------|
// |
// |
// This EA was made to easily export indicators results |
// to CSV files for further manipulation and/or analisis |
// of them. |
// |
// Instructions: |
// Modify the InitializeHeaderFile() function so that it |
// displays the CSV column headers in the same order |
// you set the indicators. |
// Modify the WriteHistoryData() function so that it |
// displays the indicators you want to export (remember |
// to place them on the same order you used on the |
// InitializeHeaderFile()). |
// Compile the expert. |
// Run the expert on the desired time range using the |
// Strategy Tester. |
// Results are saved at your MetaTrader/tester/files/ |
// folder. |
// |
// |
// ***PLEASE DONT MODIFY OR DELETE THIS HEADER** |
// Copyright 2006, by juanchoc & neo. |
// [email protected] |
//---------------------------------------------------------------*/
#property copyright "#copyright#"
#property link "#link#"
#include <WinUser32.mqh>
int CSVHandle = -1;
int OpenHistoryFile()
{
string name;
name = Symbol() + "_DATA";
CSVHandle = FileOpen(name + ".csv", FILE_CSV|FILE_WRITE, ',');
if (CSVHandle < 0) return(-1);
return (0);
}
int InitializeHeaderFile()
{
FileWrite(CSVHandle,
"DATE",
"TIME",
"OPEN",
"HIGH",
"LOW",
"CLOSE",
"VOLUME",
"SMA_CLOSE_20",
"EMA_CLOSE_20",
"SMMA_CLOSE_20",
"LWMA_CLOSE_20",
"ATR",
"CCFp"
);
}
static double d_open, d_low, d_high, d_close, d_volume;
static int i_time;
void WriteHistoryData()
{
if (CSVHandle >= 0) {
int i_digits = Digits;
FileWrite(CSVHandle,
TimeToStr(Time[0], TIME_DATE),
TimeToStr(Time[0], TIME_MINUTES),
DoubleToStr(Open[0], i_digits),
DoubleToStr(High[0], i_digits),
DoubleToStr(Low[0], i_digits),
DoubleToStr(Close[0], i_digits),
Volume[0],
iMA(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,0),
iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,0),
iMA(NULL,0,20,0,MODE_SMMA,PRICE_CLOSE,0),
iMA(NULL,0,20,0,MODE_LWMA,PRICE_CLOSE,0),
iATR(NULL,0,20,0),
iCCI(NULL,0,20,PRICE_CLOSE,0)
);
}
}
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
OpenHistoryFile();
InitializeHeaderFile();
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if (CSVHandle >= 0) {
FileClose(CSVHandle);
CSVHandle = -1;
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
WriteHistoryData();
//----
return(0);
}
//+------------------------------------------------------------------+
It is supposed to save the data of the mentioned indicators aside from the standard open, high, low, close data. However I applied it to a chart but it did not work. Could anyone let me know what is wrong with it?
All I am trying to do is export the output from the CCFp indicator from this thread -> http://articles.mql4.com/422
Thank you!