Skip to content

Commit

Permalink
Merge pull request #731 from nseam/v3.000-dev
Browse files Browse the repository at this point in the history
IndicatorLegacy.h for running MQL5 indicators in MQL4 and underscores in function parameter names to prevent conflicts.
  • Loading branch information
kenorb authored Nov 22, 2023
2 parents fdb3680 + 0ddfa58 commit 8f5733b
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 7 deletions.
1 change: 1 addition & 0 deletions Indicator.define.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

// Defines macros.
#define COMMA ,
#define SEMICOLON ;
#define DUMMY

#define ICUSTOM_DEF(SET_HANDLE, PARAMS) \
Expand Down
12 changes: 6 additions & 6 deletions IndicatorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,11 @@ class IndicatorBase : public Chart {
* Returns shift at which the last known valid entry exists for a given
* period (or from the start, when period is not specified).
*/
bool GetLastValidEntryShift(int& out_shift, int period = 0) {
bool GetLastValidEntryShift(int& out_shift, int _period = 0) {
out_shift = 0;

while (true) {
if ((period != 0 && out_shift >= period) || !HasValidEntry(out_shift + 1))
if ((_period != 0 && out_shift >= _period) || !HasValidEntry(out_shift + 1))
return out_shift > 0; // Current shift is always invalid.

++out_shift;
Expand All @@ -852,10 +852,10 @@ class IndicatorBase : public Chart {
* Returns shift at which the oldest known valid entry exists for a given
* period (or from the start, when period is not specified).
*/
bool GetOldestValidEntryShift(int& out_shift, int& out_num_valid, int shift = 0, int period = 0) {
bool GetOldestValidEntryShift(int& out_shift, int& out_num_valid, int shift = 0, int _period = 0) {
bool found = false;
// Counting from previous up to previous - period.
for (out_shift = shift + 1; out_shift < shift + period + 1; ++out_shift) {
for (out_shift = shift + 1; out_shift < shift + _period + 1; ++out_shift) {
if (!HasValidEntry(out_shift)) {
--out_shift;
out_num_valid = out_shift - shift;
Expand All @@ -873,8 +873,8 @@ class IndicatorBase : public Chart {
* Checks whether indicator has valid at least given number of last entries
* (counting from given shift or 0).
*/
bool HasAtLeastValidLastEntries(int period, int shift = 0) {
for (int i = 0; i < period; ++i)
bool HasAtLeastValidLastEntries(int _period, int shift = 0) {
for (int i = 0; i < _period; ++i)
if (!HasValidEntry(shift + i)) return false;

return true;
Expand Down
Loading

0 comments on commit 8f5733b

Please sign in to comment.