forked from trderx/EA_MindStorms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MACH2_MindStorms.mq4
218 lines (181 loc) · 6.74 KB
/
MACH2_MindStorms.mq4
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// P L E A S E - D O N O T D E L E T E A N Y T H I N G ! ! !
// -------------------------------------------------------------------------------------------------
// MACH2_MindStorms v1.01
//
// by Rodolfo
//
//--------------------------------------------------------------------------------------------------
// THIS EA IS 100 % FREE OPENSOURCE, WHICH MEANS THAT IT'S NOT A COMMERCIAL PRODUCT
// -------------------------------------------------------------------------------------------------
#property copyright " MACH2_MindStorms_v1.01"
#property link "[email protected]"
#property version "1.01"
#property description "MACH2_MindStorms_v1"
#property description "Strategy: When the signal is buy motor 1 MACHx starts, when the signal is sold the motor 2 MACHx starts"
#property description "This EA is 100% FREE OpenSource"
#property description "Coder: [email protected] "
#property strict
extern string Version__ = "-----------------------------------------------------------------";
extern string vg_versao = " MACH2_MindStorms_v1 2018-03-12 DEVELOPER EDITION ";
extern string Version____ = "-----------------------------------------------------------------";
extern string __chartTemplate = " ------- Chart template ------------";
extern string InpChartTemplate = "EA_MindStorm.tpl";
#include "SDK/EAframework.mqh"
#include "SDK/TrailingStop.mqh"
#include "Engines/macx.mqh"
#include "Engines/macx2.mqh"
#include "Sinal/SinalMA.mqh"
#include "Sinal/SinalHILO.mqh"
//#include "Sinal/SinalBB.mqh"
//#include "Sinal/SinalRSI.mqh"
#include "Filter/FFCallNews.mqh"
#include "Filter/FilterTime.mqh"
#include "Filter/FilterVolatility.mqh"
#include "Filter/FilterMarginLevel.mqh"
#include "Filter/FilterStopOut.mqh"
double vg_Spread = 0;
string vg_filters_on = "";
string vg_initpainel = false;
//+------------------------------------------------------------------+
//| input parameters |
//+------------------------------------------------------------------+
extern string Filter_Spread__ = "----------------------------Filter Max Spread----------------";
input int InpMaxvg_Spread = 24; // Max Spread
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- example of applying template, located in \MQL4\Files
if (FileIsExist(InpChartTemplate))
{
Print("The file " + InpChartTemplate + " found in \\Files'");
//--- apply template
if (ChartApplyTemplate(0, "\\Files\\" + InpChartTemplate))
{
Print("The template '" + InpChartTemplate + "' applied successfully");
}
else
Print("Failed to apply '" + InpChartTemplate + "', error code ", GetLastError());
}
else
{
Print("File '" + InpChartTemplate + "' not found in " + TerminalInfoString(TERMINAL_PATH) + "\\MQL4\\Files");
}
vg_Spread = MarketInfo(Symbol(), MODE_SPREAD) * Point;
vg_filters_on = "";
vg_initpainel = true;
printf(vg_versao + " - INIT");
return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
Comment(vg_filters_on);
vg_filters_on = "";
PainelUPER(vg_versao);
RefreshRates();
//FILTER SPREAD
if (vg_Spread > InpMaxvg_Spread)
{
vg_filters_on += "Filter InpMaxvg_Spread ON \n";
return;
}
//FILTER NEWS
if (InpUseFFCall)
{
NewsHandling();
if (vg_news_time)
{
vg_filters_on += "Filter News ON \n";
return;
}
}
//FILTER DATETIME
if (TimeFilter())
{
vg_filters_on += "Filter TimeFilter ON \n";
return;
}
//FILTER Volatility
if (FilterVolatility())
{
vg_filters_on += "Filter Volatility ON \n";
return;
}
//FILTER MarginLevel
if (FilterMargiLevel())
{
vg_filters_on += "Filter MarginLevel ON \n";
return;
}
if (FilterStopOut(MACH_CurrentPairProfit, MACH_MagicNumber) || FilterStopOut(MACH2_CurrentPairProfit, MACH2_MagicNumber))
return;
int Sinal = (GetSinalMA() + GetSinalHILO()) / (DivSinalMA() + DivSinalHILO());
double lotsinitMACH2 = 0.01;
double lotsinitMACH1 = 0.01;
if (Sinal == -1)
{
// CloseThisSymbolAll(MACH2_MagicNumber,0);
if (MACH2_equityrisk)
MACHx(-1, true, MACH2_l_lastlot * 0.2);
else
MACHx(-1, false, lotsinitMACH1);
}
if (Sinal == 1)
{
//CloseThisSymbolAll(MACH_MagicNumber,0);
if (MACH_equityrisk)
MACH2x(1, true, MACH_l_lastlot * 0.2);
else
MACH2x(1, false, lotsinitMACH2);
}
// SE TrailingStop ENABLE
if (InpUseTrailingStop)
TrailingAlls(InpTrailStart, InpTrailStep, MACH_AveragePrice, MACH_MagicNumber);
if (InpUseTrailingStop)
TrailingAlls(InpTrailStart, InpTrailStep, MACH2_AveragePrice, MACH2_MagicNumber);
}
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
//sparam: Name of the graphical object, on which the event occurred
// did user click on the chart ?
if (id == CHARTEVENT_OBJECT_CLICK)
{
// and did he click on on of our objects
if (StringSubstr(sparam, 0, 2) == "_l")
{
// did user click on the name of a pair ?
int len = StringLen(sparam);
// Alert(sparam);
//
if (StringSubstr(sparam, len - 3, 3) == "BUY" || StringSubstr(sparam, len - 3, 3) == "ELL")
{
// if (InpManualInitGrid && CountTrades() == 0)
if (true)
{
//Aciona 1ª Ordem do Grid
if (StringSubstr(sparam, len - 3, 3) == "BUY")
{
//BUY
// Alert("BUY");
}
if (StringSubstr(sparam, len - 3, 3) == "ELL")
{
//SELL
// Alert("SELL");
}
}
}
}
}
}