Skip to content

Commit

Permalink
Merge pull request #642 from EA31337/dev-v2011
Browse files Browse the repository at this point in the history
Indicator logic refactor
  • Loading branch information
kenorb committed Jul 3, 2022
2 parents b550609 + b26dfa5 commit 78a0fbd
Show file tree
Hide file tree
Showing 210 changed files with 8,687 additions and 4,055 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/compile-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Compile C++

# yamllint disable-line rule:truthy
on:
pull_request:
paths-ignore:
- '**.md'
push:
paths-ignore:
- '**.md'

jobs:

FileList:
outputs:
filelist: ${{ steps.get-files.outputs.filelist }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set output with list of files
id: get-files
run: |
import glob, json, os
files = glob.glob("**/tests/*.cpp")
print("::set-output name=filelist::{}".format(json.dumps(files)))
shell: python
- name: Display output
run: echo ${{ steps.get-files.outputs.filelist }}

Compile:
runs-on: ubuntu-latest
needs: [FileList]
strategy:
matrix:
file: ${{ fromJson(needs.FileList.outputs.filelist) }}
steps:
- uses: actions/checkout@v2
- name: Install compiler
uses: rlalik/[email protected]
with:
compiler: gcc-latest
- name: Compile ${{ matrix.file }}
run: g++ "${{ matrix.file }}"
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
62 changes: 62 additions & 0 deletions .github/workflows/test-exchange.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Test Exchange

# yamllint disable-line rule:truthy
on:
pull_request:
paths:
- 'Exchange/**.h'
- 'Exchange/**.mq?'
- '.github/workflows/test-exchange.yml'
push:
paths:
- 'Exchange/**.h'
- 'Exchange/**.mq?'
- '.github/workflows/test-exchange.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: 'Exchange/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'

Exchange-Tests-MQL4:
defaults:
run:
shell: bash
working-directory: Exchange/tests
needs: Compile
runs-on: ubuntu-latest
strategy:
matrix:
test:
- Exchange.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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- CompileIndicatorsTest
- ConditionTest
- DatabaseTest
- DrawIndicatorTest
# - DrawIndicatorTest
- EATest
- IndicatorDataTest
- IndicatorTest
Expand Down
6 changes: 6 additions & 0 deletions Account.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Account;
// Includes.
#include "Account/Account.define.h"
#include "Account/Account.enum.h"
#include "Account/Account.extern.h"
#include "Account/Account.struct.h"
#include "Array.mqh"
#include "BufferStruct.mqh"
Expand Down Expand Up @@ -63,6 +64,11 @@ class Account {
*/
Account() : init_balance(CalcInitDeposit()), start_balance(GetBalance()), start_credit(GetCredit()) {}

/**
* Class copy constructor.
*/
Account(const Account &_account) {}

/**
* Class deconstructor.
*/
Expand Down
29 changes: 29 additions & 0 deletions Account/Account.extern.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//+------------------------------------------------------------------+
//| EA31337 framework |
//| Copyright 2016-2022, 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/>.
*
*/

// Includes.
#include "Account.enum.h"

// Define external global functions.
#ifndef __MQL__
extern string AccountInfoString(ENUM_ACCOUNT_INFO_STRING property_id);
#endif
1 change: 1 addition & 0 deletions Account/Account.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Serializer;

// Includes.
#include "../Serializer.mqh"
#include "../Terminal.define.h"

// Struct for account entries.
struct AccountEntry {
Expand Down
1 change: 1 addition & 0 deletions Account/AccountBase.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Serializer;

// Includes.
#include "../Serializer.mqh"
#include "../Terminal.define.h"

// Struct for account entries.
struct AccountBaseEntry {
Expand Down
1 change: 1 addition & 0 deletions Account/AccountForex.struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Serializer;

// Includes.
#include "../Serializer.mqh"
#include "../Terminal.define.h"

// Struct for account entries.
struct AccountForexEntry : public AccountBaseEntry {
Expand Down
2 changes: 1 addition & 1 deletion Account/tests/Account.test.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int OnInit() {
bool _result = true;
Account<AccountBaseState, AccountBaseEntry> acc1;
// ...
return _result && GetLastError() == ERR_NO_ERROR ? INIT_SUCCEEDED : INIT_FAILED;
return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Account/tests/AccountForex.test.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int OnInit() {
bool _result = true;
Account<AccountForexState, AccountForexEntry> acc1;
// ...
return _result && GetLastError() == ERR_NO_ERROR ? INIT_SUCCEEDED : INIT_FAILED;
return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED;
}

/**
Expand Down
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
Loading

0 comments on commit 78a0fbd

Please sign in to comment.