-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathGridEA.mq4
96 lines (88 loc) · 2.83 KB
/
GridEA.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
//+------------------------------------------------------------------+
//| GridEA.mq4 |
//| Copyright 2018, Valentinos Galanos <[email protected]> |
//+------------------------------------------------------------------+
#define ver "1.00"
#property copyright "Copyright 2018, Valentinos Galanos <[email protected]>"
#property version ver
#property strict
//--- input parameters
input int GridGap = 50; // Grid Gap (Pips)
input double LotSize = 0.01; // Trade Lot Volume
input int TotalGridLines = 7; // Total Grid Lines Each Side
//--- Includes
#include "Library\GridExpert.mqh"
//--- Expert
CGridExpert* GridEA;
//--- Memory
bool initialized=false;
bool timerCalled=false;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- create timer
EventSetMillisecondTimer(500);
if( initialized == false )
{
initialized = true;
GridEA = new CGridExpert;
return GridEA.OnInit();
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
switch(reason)
{
case REASON_CLOSE:
case REASON_INITFAILED:
case REASON_RECOMPILE:
case REASON_REMOVE:
case REASON_ACCOUNT:
case REASON_CHARTCLOSE:
case REASON_PROGRAM:
if( initialized && GridEA != NULL)
{
GridEA.OnDeinit(reason);
initialized = false;
delete GridEA;
}
break;
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
if( initialized && GridEA != NULL )
{
GridEA.OnTick();
}
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
if(timerCalled == false)
{
timerCalled = true;
//---
if( initialized && GridEA != NULL )
{
GridEA.OnTimer();
}
timerCalled = false;
}
}
//+------------------------------------------------------------------+