/
DayOpening.mqh
77 lines (72 loc) · 3.59 KB
/
DayOpening.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
//+--------------------------------------------------------------------+
//| Copyright: (C) 2016 Forex Software Ltd. |
//| Website: http://forexsb.com/ |
//| Support: http://forexsb.com/forum/ |
//| License: Proprietary under the following circumstances: |
//| |
//| This code is a part of Forex Strategy Builder. It is free for |
//| use as an integral part of Forex Strategy Builder. |
//| One can modify it in order to improve the code or to fit it for |
//| personal use. This code or any part of it cannot be used in |
//| other applications without a permission. |
//| The contact information cannot be changed. |
//| |
//| NO LIABILITY FOR CONSEQUENTIAL DAMAGES |
//| |
//| In no event shall the author be liable for any damages whatsoever |
//| (including, without limitation, incidental, direct, indirect and |
//| consequential damages, damages for loss of business profits, |
//| business interruption, loss of business information, or other |
//| pecuniary loss) arising out of the use or inability to use this |
//| product, even if advised of the possibility of such damages. |
//+--------------------------------------------------------------------+
#property copyright "Copyright (C) 2016 Forex Software Ltd."
#property link "http://forexsb.com"
#property version "2.00"
#property strict
#include <Forexsb.com/Indicator.mqh>
#include <Forexsb.com/Enumerations.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class DayOpening : public Indicator
{
public:
DayOpening(SlotTypes slotType);
virtual void Calculate(DataSet &dataSet);
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DayOpening::DayOpening(SlotTypes slotType)
{
SlotType = slotType;
IndicatorName = "Day Opening";
WarningMessage = "";
IsAllowLTF = true;
ExecTime = ExecutionTime_AtBarOpening;
IsSeparateChart = false;
IsDiscreteValues = false;
IsDefaultGroupAll = false;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void DayOpening::Calculate(DataSet &dataSet)
{
Data=GetPointer(dataSet);
double openPrice[]; ArrayResize(openPrice,Data.Bars); ArrayInitialize(openPrice,0);
for(int bar=1; bar<Data.Bars; bar++)
{
MqlDateTime time0; TimeToStruct(Data.Time[bar-0], time0);
MqlDateTime time1; TimeToStruct(Data.Time[bar-1], time1);
if(time0.day!=time1.day)
openPrice[bar]=Data.Open[bar];
}
Component[0].CompName = "Opening price of the day";
Component[0].DataType = IndComponentType_OpenPrice;
Component[0].FirstBar = 2;
ArrayResize(Component[0].Value,Data.Bars);
ArrayCopy(Component[0].Value,openPrice);
}
//+------------------------------------------------------------------+