forked from vzhomeexperiments/Include
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03b_ReadCommandFromCSV_MacroEconomicEvent.mqh
79 lines (68 loc) · 3.12 KB
/
03b_ReadCommandFromCSV_MacroEconomicEvent.mqh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//+------------------------------------------------------------------+
//| 03b_ReadCommandFromCSV_MacroEconomicEvent.mqh |
//| Miguel Ferraz |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Miguel Ferraz"
#property link "https://www.mql5.com"
#property strict
//+------------------------------------------------------------------+
//| defines |
//+------------------------------------------------------------------+
// #define MacrosHello "Hello, world!"
// #define MacrosYear 2010
//+------------------------------------------------------------------+
//| DLL imports |
//+------------------------------------------------------------------+
// #import "user32.dll"
// int SendMessageA(int hWnd,int Msg,int wParam,int lParam);
// #import "my_expert.dll"
// int ExpertRecalculate(int wParam,int lParam);
// #import
//+------------------------------------------------------------------+
//| EX5 imports |
//+------------------------------------------------------------------+
// #import "stdlib.ex5"
// string ErrorDescription(int error_code);
// #import
//+------------------------------------------------------------------+
bool ReadCommandFromCSVMacroEconomicEvent(string symboll)
{
//- Function reads the file SystemControlMagicNumber.csv
//- It is searching the code 1 and return trade as enabled
string symboll1 = StringSubstr(symboll,0,3);
string symboll2 = StringSubstr(symboll,3,3);
//int el1, el2, handle, comma,i,pos[]; bool TradePossible = False;
int handle, comma,i,pos[]; bool TradePossible = False;
static int el1 = 0; // added ver.02
static int el2 = 0; // added ver.02
string str, word, trigger;
/*
handle=FileOpen("01_MacroeconomicEvent.csv",FILE_READ|FILE_SHARE_READ);
if(handle==-1){Alert("Error - file does not exist"); TradePossible = TRUE; }
if(FileSize(handle)==0){FileClose(handle); Comment("Error - File is empty"); }*/
handle=0;
while( handle==0 || handle==-1 ){handle = FileOpen("01_MacroeconomicEvent.csv",FILE_CSV|FILE_READ|FILE_SHARE_READ|FILE_WRITE|FILE_SHARE_WRITE);}
while(!FileIsEnding(handle) && TradePossible == FALSE)
{
str=FileReadString(handle);
if(str!="")
{
word=StringSubstr(str,1,3);
//Alert(word);
trigger = StringSubstr(str,6,1);
//Alert(trigger);
if(word == symboll1 || word == symboll2 )
{if(trigger == "1")
{//Alert("The system is enabled!!!");
TradePossible = TRUE;
return TradePossible;
}
if(trigger == "0")
{//Alert("The system is disabled!!!");
TradePossible = FALSE;} }
}
}
FileClose(handle);
return(TradePossible);
}