1 مرفق
اخذ القيمة الموجودة في مؤشر واستخدامها لرسم خط افقي (الكود شبه مكتمل)
السلام عليكم ورحمة الله
لدي مؤشر ...يقوم بقراءة ملف اكسل ويظهر النتيجة او الرقم الموجود في ملف الاكسل على شاشة الميتاتريدر
ثم اضفت كود ليقوم المؤشر برسم خط افقي OBJ_HLINE قيمته هي السعر المستورد من ملف الاكسل
وبما اني لازلت مبتدئ فلم استطع كتابة كود للربط بين الحصول على القيمة الموجودة على الشاشة واستخدامها لرسم الخط الافقي ... الصورة تشرح والكود مرفق
ملاحظة : وضعت بدل القيمة المطلوبة في الكود رمز @@ ليسهل الوصول لها
الملف المرفق 497042
كود PHP:
/
//+------------------------------------------------------------------+
//| importing from excel2.mq4 |
//| Copyright 2018, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
class CCsvDisplay {
public:
//Constructor, pass the filename here
CCsvDisplay(string strFilename) {
m_strFilename = strFilename;
}
~CCsvDisplay(){/*Destructor*/};
//Read the csv file
void ReadDisplayFile() {
if (FileIsExist(m_strFilename) == true) {
int iFile = FileOpen(m_strFilename, FILE_TXT | FILE_READ | FILE_SHARE_READ | FILE_ANSI);
//Is file open succeed?
if (iFile != -1) {
//Succeed
Print("Open file ", m_strFilename);
string strFormatDisplayString;
//Parse and display file content until file reach the end
while (FileIsEnding(iFile) == false) {
//Read file line per line
string strContentLine = FileReadString(iFile);
string strParsedColumn[];
//Parse string column by column (based on separator)
int iContentCount = StringSplit(strContentLine, StringGetCharacter(",",0), strParsedColumn);
if (iContentCount > 0) {
for (int i = 0; i < iContentCount; i++) {
strFormatDisplayString += strParsedColumn[i];
if (i != (iContentCount - 1)) strFormatDisplayString += " -> ";
ObjectDelete("VERTECALLINE");
ObjectCreate( "VERTECALLINE","VERTECALLINE", OBJ_HLINE,0,D'2018.06.29 20:00',@@);
ObjectSet( "VERTECALLINE", OBJPROP_STYLE, STYLE_SOLID);
ObjectSet( "VERTECALLINE", OBJPROP_COLOR, Red);
ObjectSet("VERTECALLINE", OBJPROP_BACK, false);
ObjectSet("VERTECALLINE", OBJPROP_WIDTH,1);
}
//Add return and new line for display
strFormatDisplayString += "\n";
}
}
//Close file after read
FileClose(iFile);
//Plot string as comment on chart
Comment(strFormatDisplayString);
}
else {
//Failed
Comment("Cannot open ", m_strFilename, " !");
}
}
else {
//File doesn't exist?
Comment("File ", m_strFilename, " doesn't exist!");
}
}
private:
string m_strFilename;
};
//============
CCsvDisplay *m_pcCsvDisp;
int OnInit()
{
m_pcCsvDisp = new CCsvDisplay("myFile.csv");
m_pcCsvDisp.ReadDisplayFile();
Print("Load Csv display");
return(0);
}
void OnDeinit(const int r)
{
if (m_pcCsvDisp != NULL) delete m_pcCsvDisp;
}