-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
263 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* This file is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
// Ignore processing of this file if already included. | ||
#ifndef INDICATOR_TICK_MQH | ||
#define INDICATOR_TICK_MQH | ||
|
||
// Includes. | ||
#include "../IndicatorBase.h" | ||
//#include "Array.mqh" | ||
//#include "BufferStruct.mqh" | ||
//#include "Chart.mqh" | ||
//#include "DateTime.mqh" | ||
//#include "DrawIndicator.mqh" | ||
//#include "Indicator.define.h" | ||
//#include "Indicator.enum.h" | ||
//#include "Indicator.struct.cache.h" | ||
//#include "Indicator.struct.h" | ||
//#include "Indicator.struct.serialize.h" | ||
//#include "Indicator.struct.signal.h" | ||
//#include "IndicatorBase.h" | ||
//#include "Math.h" | ||
//#include "Object.mqh" | ||
//#include "Refs.mqh" | ||
//#include "Serializer.mqh" | ||
//#include "SerializerCsv.mqh" | ||
//#include "SerializerJson.mqh" | ||
//#include "Storage/ValueStorage.h" | ||
//#include "Storage/ValueStorage.indicator.h" | ||
//#include "Storage/ValueStorage.native.h" | ||
|
||
/** | ||
* Class to deal with tick indicators. | ||
*/ | ||
// template <typename TS> | ||
class IndicatorTick : public IndicatorBase { | ||
protected: | ||
BufferStruct<IndicatorDataEntry> tickdata; | ||
|
||
public: | ||
/* Special methods */ | ||
|
||
/** | ||
* Class constructor. | ||
*/ | ||
IndicatorTick() {} | ||
|
||
/* Virtual method implementations */ | ||
|
||
/** | ||
* Returns the indicator's data entry. | ||
* | ||
* @see: IndicatorDataEntry. | ||
* | ||
* @return | ||
* Returns IndicatorDataEntry struct filled with indicator values. | ||
*/ | ||
IndicatorDataEntry GetEntry(int _timestamp = 0) { | ||
IndicatorDataEntry _entry = tickdata.GetByKey(_timestamp); | ||
if (!_entry.IsValid() && !_entry.CheckFlag(INDI_ENTRY_FLAG_INSUFFICIENT_DATA)) { | ||
_entry.timestamp = _timestamp; | ||
_entry.Resize(4); | ||
_entry.SetFlag(INDI_ENTRY_FLAG_IS_VALID, IsValidEntry(_entry)); | ||
for (int _mode = 0; _mode < (int)iparams.GetMaxModes(); _mode++) { | ||
//_entry.values[_mode] = GetValue(_mode, _shift); / @todo | ||
} | ||
if (_entry.IsValid()) { | ||
idata.Add(_entry, _bar_time); | ||
} else { | ||
_entry.AddFlags(INDI_ENTRY_FLAG_INSUFFICIENT_DATA); | ||
} | ||
} | ||
return _entry; | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* This file is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* Test functionality of IndicatorTick class. | ||
*/ | ||
|
||
// Includes. | ||
#include "IndicatorTick.test.mq5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//+------------------------------------------------------------------+ | ||
//| EA31337 framework | | ||
//| Copyright 2016-2021, EA31337 Ltd | | ||
//| https://github.com/EA31337 | | ||
//+------------------------------------------------------------------+ | ||
|
||
/* | ||
* This file is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* Test functionality of IndicatorTick class. | ||
*/ | ||
|
||
// Includes. | ||
#include "../../Test.mqh" | ||
#include "../IndicatorTick.h" | ||
|
||
/** | ||
* Implements OnInit(). | ||
*/ | ||
int OnInit() { | ||
/* @fixme | ||
// Initialize. | ||
IndicatorParams iparams(INDI_NONE, TYPE_INT, 10); | ||
Indicator *in = new Indicator(iparams, NULL); | ||
// Check empty values. | ||
assertTrueOrFail(in.GetBufferSize() == 10, "Wrong buffer size!"); | ||
assertTrueOrFail(in.GetEmpty().double_value == 0.0, "Wrong empty double value!"); | ||
assertTrueOrFail(in.GetEmpty().integer_value == 0, "Wrong empty integer value!"); | ||
// Check dynamic allocation. | ||
MqlParam entry; | ||
entry.integer_value = 1; | ||
for (uint i = 0; i < in.GetBufferSize() * 2; i++) { | ||
in.AddValue(entry); | ||
Print("Index ", i, ": Curr: ", in.GetValue(0).integer_value, "; Prev: ", in.GetValue(1).integer_value); | ||
assertTrueOrFail(in.GetValue(0).integer_value == entry.integer_value, | ||
StringFormat("Wrong latest value (%d <> %d)!", | ||
in.GetValue(0).integer_value, | ||
entry.integer_value)); | ||
assertTrueOrFail(in.GetValue(1).integer_value == entry.integer_value - 1, | ||
StringFormat("Wrong previous value (%d <> %d)!", | ||
in.GetValue(1).integer_value, | ||
entry.integer_value - 1)); | ||
entry.integer_value++; | ||
} | ||
Print(in.ToString()); | ||
// Clean up. | ||
delete in; | ||
*/ | ||
return (INIT_SUCCEEDED); | ||
} |
Oops, something went wrong.