Skip to content

Commit

Permalink
Merge remote-tracking branch 'nseam/dev-indicator-refactor' into v3.0…
Browse files Browse the repository at this point in the history
…01-dev-new

* nseam/dev-indicator-refactor: (50 commits)
  • Loading branch information
kenorb committed Apr 19, 2024
2 parents 7b5996a + 74eb036 commit 83d5ee7
Show file tree
Hide file tree
Showing 118 changed files with 4,501 additions and 1,198 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/test-buffer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
name: Test Buffer

# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- 'Buffer/**'
- '.github/workflows/test-buffer.yml'
push:
paths:
- 'Buffer/**'
- '.github/workflows/test-buffer.yml'

jobs:

Compile:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Compile
uses: fx31337/mql-compile-action@master
with:
init-platform: true
path: 'Buffer/tests'
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell
- name: Upload artifacts (MQL4)
uses: actions/upload-artifact@v2
with:
name: files-ex4
path: '**/*.ex4'
- name: Upload artifacts (MQL5)
uses: actions/upload-artifact@v2
with:
name: files-ex5
path: '**/*.ex5'

Buffer-Tests-MQL4:
defaults:
run:
shell: bash
working-directory: Buffer/tests
needs: Compile
runs-on: ubuntu-latest
strategy:
matrix:
test:
- BufferCandle.test
- BufferTick.test
steps:
- uses: actions/download-artifact@v2
with:
name: files-ex4
- name: Run ${{ matrix.test }}
uses: fx31337/mql-tester-action@master
with:
Script: ${{ matrix.test }}
timeout-minutes: 10
67 changes: 67 additions & 0 deletions .github/workflows/test-indicator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: Test Indicator

# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- 'Indicator**'
- 'Indicator/**'
- '.github/workflows/test-indicator.yml'
push:
paths:
- 'Indicator**'
- 'Indicator/**'
- '.github/workflows/test-indicator.yml'

jobs:

Compile:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Compile
uses: fx31337/mql-compile-action@master
with:
init-platform: true
path: 'Indicator/tests'
verbose: true
- name: Print compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
shell: powershell
- name: Upload artifacts (MQL4)
uses: actions/upload-artifact@v2
with:
name: files-ex4
path: '**/*.ex4'
- name: Upload artifacts (MQL5)
uses: actions/upload-artifact@v2
with:
name: files-ex5
path: '**/*.ex5'

Indicator-Tests-MQL4:
defaults:
run:
shell: bash
working-directory: Indicator/tests
needs: Compile
runs-on: ubuntu-latest
strategy:
matrix:
test:
- IndicatorCandle.test
- IndicatorTf.test
- IndicatorTick.test
steps:
- uses: actions/download-artifact@v2
with:
name: files-ex4
- name: Run ${{ matrix.test }}
uses: fx31337/mql-tester-action@master
with:
BtDays: 4-8
BtMonths: 1
BtYears: 2020
TestExpert: ${{ matrix.test }}
timeout-minutes: 10
18 changes: 10 additions & 8 deletions Action.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,16 @@ class Action {
break;
#endif
#ifdef INDICATOR_MQH
case ACTION_TYPE_INDICATOR:
if (Object::IsValid(_entry.obj)) {
_result = ((IndicatorBase *)_entry.obj).ExecuteAction((ENUM_INDICATOR_ACTION)_entry.action_id);
} else {
_result = false;
_entry.AddFlags(ACTION_ENTRY_FLAG_IS_INVALID);
}
break;
/*
case ACTION_TYPE_INDICATOR:
if (Object::IsValid(_entry.obj)) {
_result = ((IndicatorBase *)_entry.obj).ExecuteAction((ENUM_INDICATOR_ACTION)_entry.action_id);
} else {
_result = false;
_entry.AddFlags(ACTION_ENTRY_FLAG_IS_INVALID);
}
break;
*/
#endif
#ifdef STRATEGY_MQH
case ACTION_TYPE_STRATEGY:
Expand Down
79 changes: 79 additions & 0 deletions Buffer/BufferCandle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//+------------------------------------------------------------------+
//| 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/>.
*
*/

// Prevents processing this includes file for the second time.
#ifndef BUFFER_CANDLE_H
#define BUFFER_CANDLE_H

// Includes.
#include "../BufferStruct.mqh"
#include "../Candle.struct.h"

/**
* Class to store struct data.
*/
template <typename TV>
class BufferCandle : public BufferStruct<CandleOCTOHLC<TV>> {
protected:
protected:
/* Protected methods */

/**
* Initialize class.
*
* Called on constructor.
*/
void Init() { SetOverflowListener(BufferCandleOverflowListener, 10); }

public:
/* Constructors */

/**
* Constructor.
*/
BufferCandle() { Init(); }
BufferCandle(BufferCandle& _right) {
THIS_REF = _right;
Init();
}

/* Callback methods */

/**
* Function should return true if resize can be made, or false to overwrite current slot.
*/
static bool BufferCandleOverflowListener(ENUM_DICT_OVERFLOW_REASON _reason, int _size, int _num_conflicts) {
static int cache_limit = 86400;
switch (_reason) {
case DICT_OVERFLOW_REASON_FULL:
// We allow resize if dictionary size is less than 86400 slots.
return _size < cache_limit;
case DICT_OVERFLOW_REASON_TOO_MANY_CONFLICTS:
default:
// When there is too many conflicts, we just reject doing resize, so first conflicting slot will be reused.
break;
}
return false;
}
};

#endif // BUFFER_CANDLE_H
Loading

0 comments on commit 83d5ee7

Please sign in to comment.