|
1 | 1 | //+------------------------------------------------------------------+
|
2 |
| -//| ForecastExpert.mq5 | |
| 2 | +//| _HPCS_RNNPredict_MT5_EA_V01_WE.mq5 | |
3 | 3 | //| HPCS |
|
4 | 4 | //| https://www.mql5.com |
|
5 | 5 | //+------------------------------------------------------------------+
|
@@ -149,35 +149,78 @@ int OnInit()
|
149 | 149 | //---
|
150 | 150 |
|
151 | 151 | previousPred = "";
|
| 152 | + if(train == true){ |
| 153 | + ObjectCreate(ChartID(),"Trainbutton",OBJ_BUTTON,0,0,0); |
| 154 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_XSIZE,140); |
| 155 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_YSIZE,30); |
| 156 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_XDISTANCE,40); |
| 157 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_YDISTANCE,10); |
| 158 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_COLOR,clrBlue); |
| 159 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_BGCOLOR,clrWhite); |
| 160 | + ObjectSetString(ChartID(),"Trainbutton",OBJPROP_TEXT,"TRAIN MODEL"); |
| 161 | + ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_STATE,false); |
152 | 162 |
|
153 |
| - ObjectCreate(ChartID(),"Trainbutton",OBJ_BUTTON,0,0,0); |
154 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_XSIZE,140); |
155 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_YSIZE,30); |
156 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_XDISTANCE,40); |
157 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_YDISTANCE,10); |
158 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_COLOR,clrBlue); |
159 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_BGCOLOR,clrWhite); |
160 |
| - ObjectSetString(ChartID(),"Trainbutton",OBJPROP_TEXT,"TRAIN MODEL"); |
161 |
| - ObjectSetInteger(ChartID(),"Trainbutton",OBJPROP_STATE,false); |
162 |
| - |
163 |
| - ObjectCreate(ChartID(),"Predbutton",OBJ_BUTTON,0,0,0); |
164 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_XSIZE,140); |
165 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_YSIZE,30); |
166 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_XDISTANCE,40); |
167 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_YDISTANCE,50); |
168 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_COLOR,clrBlue); |
169 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_BGCOLOR,clrWhite); |
170 |
| - ObjectSetString(ChartID(),"Predbutton",OBJPROP_TEXT,"PREDICT"); |
171 |
| - ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_STATE,false); |
172 |
| - |
173 |
| - if(!EventChartCustom(ChartID(),0,0,0,"Trainbutton")){ |
174 |
| - Print("Error : ",GetLastError()); |
175 |
| - } |
176 |
| - |
177 |
| - if(!EventChartCustom(ChartID(),0,0,0,"Predbutton")){ |
178 |
| - Print("Error : ",GetLastError()); |
| 163 | + ObjectCreate(ChartID(),"Predbutton",OBJ_BUTTON,0,0,0); |
| 164 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_XSIZE,140); |
| 165 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_YSIZE,30); |
| 166 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_XDISTANCE,40); |
| 167 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_YDISTANCE,50); |
| 168 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_COLOR,clrBlue); |
| 169 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_BGCOLOR,clrWhite); |
| 170 | + ObjectSetString(ChartID(),"Predbutton",OBJPROP_TEXT,"PREDICT"); |
| 171 | + ObjectSetInteger(ChartID(),"Predbutton",OBJPROP_STATE,false); |
| 172 | + |
| 173 | + if(!EventChartCustom(ChartID(),0,0,0,"Trainbutton")){ |
| 174 | + Print("Error : ",GetLastError()); |
| 175 | + } |
| 176 | + |
| 177 | + if(!EventChartCustom(ChartID(),0,0,0,"Predbutton")){ |
| 178 | + Print("Error : ",GetLastError()); |
| 179 | + } |
179 | 180 | }
|
| 181 | + else{ |
180 | 182 |
|
| 183 | + socket = SocketCreate(); |
| 184 | + if(socket!=INVALID_HANDLE) { |
| 185 | + if(SocketConnect(socket,"localhost",9090,1000)) { |
| 186 | + Print("Connected to "," localhost",":",9090); |
| 187 | + |
| 188 | + CJAVal json; |
| 189 | + json["FileName"] = fileName; |
| 190 | + json["Train"] = train; |
| 191 | + json["GPU"] = gpu; |
| 192 | + json["Bars"] = bars; |
| 193 | + |
| 194 | + string jsonString = json.Serialize(); |
| 195 | + |
| 196 | + bool send = socksend(socket, jsonString); |
| 197 | + if(send) |
| 198 | + Print("Data Sent Successfully For Prediction."); |
| 199 | + |
| 200 | + string strMessage; |
| 201 | + do{ |
| 202 | + strMessage = socketreceive(socket,10); |
| 203 | + if (strMessage != "") { |
| 204 | + previousPred = strMessage; |
| 205 | + Print(strMessage); |
| 206 | + drawpred(strMessage); |
| 207 | + SocketClose(socket); |
| 208 | + socket = -2; |
| 209 | + } |
| 210 | + }while(strMessage == ""); |
| 211 | + |
| 212 | + } |
| 213 | + else{ |
| 214 | + socket = -2; |
| 215 | + Print("Error in connecting to ","localhost",":",9090," Error : ",GetLastError()); |
| 216 | + } |
| 217 | + } |
| 218 | + else{ |
| 219 | + socket = -2; |
| 220 | + Print("Socket creation error ",GetLastError()); |
| 221 | + } |
| 222 | + |
| 223 | + } |
181 | 224 |
|
182 | 225 | //---
|
183 | 226 | return(INIT_SUCCEEDED);
|
@@ -224,6 +267,7 @@ void OnTick()
|
224 | 267 | }
|
225 | 268 |
|
226 | 269 | json["FileName"] = fileName;
|
| 270 | + json["Train"] = train; |
227 | 271 | json["GPU"] = gpu;
|
228 | 272 | json["Architecture"] = (int)architecture;
|
229 | 273 | json["Optimizer"] = (int)optimizer;
|
@@ -297,6 +341,7 @@ void OnChartEvent(const int id, const long &lparam, const double &dparam, const
|
297 | 341 | }
|
298 | 342 |
|
299 | 343 | json["FileName"] = fileName;
|
| 344 | + json["Train"] = train; |
300 | 345 | json["GPU"] = gpu;
|
301 | 346 | json["Architecture"] = (int)architecture;
|
302 | 347 | json["Optimizer"] = (int)optimizer;
|
|
0 commit comments