forked from vzhomeexperiments/Include
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14_ReadPriceChangePredictionFromAI.mqh
More file actions
52 lines (45 loc) · 2.17 KB
/
Copy path14_ReadPriceChangePredictionFromAI.mqh
File metadata and controls
52 lines (45 loc) · 2.17 KB
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
//+-------------------------------------------------------------------+
//| 14_ReadPriceChangePredictionFromAI.mqh |
//| Copyright 2018, Vladimir Zhbanko |
//+-------------------------------------------------------------------+
#property copyright "Copyright 2018, Vladimir Zhbanko"
#property link "https://vladdsm.github.io/myblog_attempt/"
#property version "1.001"
#property strict
// function to recieve direction from csv file
// version 1.001 date 10.05.2018
//+-------------------------------------------------------------+//
//Function requires input of the symbol
//+-------------------------------------------------------------+//
/*
User guide:
1. Add global bool variable to EA: e.g.: double AIPriceChangePredictionH1;
2. Add function call inside start function to EA: e.g.: AIPriceChangePredictionH1 = ReadPredictionFromAI(Symbol(),predictor_periodH1);
3. Adapt Trading Robot conditions to change trading strategy parameters eg.: see Falcon_C
4. Add include call to this file to EAe.g.: #include <14_ReadPriceChangePredictionFromAI.mqh>
*/
double ReadPriceChangePredictionFromAI(string symbol, int chart_period)
{
/*
- Function reads the file eg: AI_M15_ChangeAUDCAD.csv
- It will output predicted value of asset change
*/
//define internal variables needed
double change = 0; //Variable to store and return predicted price change written in the file
string res = "0"; //Variable to return result of the function
int handle;
string str;
handle=FileOpen("AI_M"+IntegerToString(chart_period)+"_Change"+symbol+".csv",FILE_READ);
if(handle==-1){Comment("Error - file does not exist"); str = "-1"; }
if(FileSize(handle)==0){FileClose(handle); Comment("Error - File is empty"); }
//this will bring the last element
while(!FileIsEnding(handle)) { str=FileReadString(handle); }
FileClose(handle);
//Interpret the file
if(str == "-1"){change = StringToDouble(str); return(change); } //in anomalous case function will return error '-1'
else
{
change = StringToDouble(str);
}
return(change);
}