Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb authored Aug 27, 2023
0 parents commit ebd626a
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 120
26 changes: 26 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# git normalization file
# @see http://www.kernel.org/pub/software/scm/git/docs/gitattributes.html

# Shorthand for text files.
# - Treat them as text.
# - Ensure no CRLF line-endings, neither on checkout nor on checkin.
# - Detect whitespace errors.
# - Exposed by default in `git diff --color` on the CLI.
# - Validate with `git diff --check`.
# - Deny applying with `git apply --whitespace=error-all`.
# - Fix automatically with `git apply --whitespace=fix`.
[attr]utf8 text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2
[attr]utf16 encoding=UTF-16LE-BOM working-tree-encoding=UTF-16LE-BOM diff merge eol=CRLF

# Shorthand for binary files.
# - Do not treat them as text.
# - Include binary diff in patches instead of "binary files differ."
[attr]binary -text diff

# Define text file attributes.
*.ex? binary
*.h utf8 diff=c
*.json utf8 diff=c
*.mq? utf8 diff=c
*.mqproj utf16 diff=c
*.txt utf8 diff=c
83 changes: 83 additions & 0 deletions .github/workflows/backtest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: Backtest

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

jobs:
Compile:
defaults:
run:
shell: powershell
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
path: Include/EA31337-classes
ref: v2.013
repository: EA31337/EA31337-classes
- name: Compile for MQL4
uses: fx31337/mql-compile-action@master
with:
include: .
init-platform: true
mt-version: 5.0.0.2361
path: Stg_Demo.mq4
verbose: true
- name: Compile for MQL5
uses: fx31337/mql-compile-action@master
with:
include: .
mt-version: 5.0.0.2515
path: Stg_Demo.mq5
verbose: true
- name: List compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
- run: Get-Location
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: EA
path: '*.ex?'
Test:
needs: Compile
runs-on: ubuntu-latest
strategy:
matrix:
month: [1]
year: [2019, 2020]
steps:
- uses: actions/download-artifact@v2
with:
name: EA
- name: Run strategy
uses: ea31337/mql-tester-action@dev
with:
BtDeposit: 100000
BtDest: ${{ github.workspace }}/_results
BtMonths: ${{ matrix.month }}
BtYears: ${{ matrix.year }}
OptFormatBrief: true
OptFormatJson: true
OptVerbose: true
TestExpert: "Stg_Demo"
TestPeriod: M1
TestReportName: Report-${{ matrix.year }}-${{ matrix.month }}
- name: Upload results
uses: actions/upload-artifact@v2
with:
name: results
path: ${{ github.workspace }}/_results/*.*
21 changes: 21 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Check

# yamllint disable-line rule:truthy
on:
pull_request:
push:

jobs:
Pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/setup-python@v2
with:
python-version: 3.9
- uses: pre-commit/[email protected]
56 changes: 56 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: Compile

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

jobs:
Compile:
defaults:
run:
shell: powershell
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
path: Include/EA31337-classes
ref: v2.013
repository: EA31337/EA31337-classes
- name: Compile for MQL4
uses: fx31337/mql-compile-action@master
with:
include: .
init-platform: true
mt-version: 5.0.0.2361
path: Stg_Demo.mq4
verbose: true
- name: Compile for MQL5
uses: fx31337/mql-compile-action@master
with:
include: .
mt-version: 5.0.0.2515
path: Stg_Demo.mq5
verbose: true
- name: List compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
- run: Get-Location
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: EA
path: '*.ex?'
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignores compiled binary files.
*.ex?

# Ignores temporary files.
*.swp
*~

# Ignores Finder metadata files on Mac
.DS_Store

# Ignores Python cache files.
*.pyc
__pycache__
40 changes: 40 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
repos:

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.31.0
hooks:
- id: yamllint

- repo: https://github.com/igorshubovych/markdownlint-cli.git
rev: v0.27.1
hooks:
- id: markdownlint

- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.5
hooks:
- id: forbid-binary
exclude: (\.ico|\.mqproj)$
- id: git-check # Configure in .gitattributes
# - id: markdownlint # Configure in .mdlrc.style.rb
- id: require-ascii

- repo: https://github.com/thibaudcolas/curlylint
rev: v0.13.1
hooks:
- id: curlylint

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
exclude: \.txt$
- id: trailing-whitespace
exclude: \.txt$
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Strategy Demo

[![Status][gha-image-check-master]][gha-link-check-master]
[![Status][gha-image-compile-master]][gha-link-compile-master]
[![Channel][tg-channel-image]][tg-channel-link]
[![Discuss][gh-discuss-badge]][gh-discuss-link]
[![License][license-image]][license-link]
[![Edit][gh-edit-badge]][gh-edit-link]

Strategy based on the Demo indicator.

This is example demo strategy for the demonstration purposes.

## Dependencies

| Tag | Framework |
|:--------:|:---------:|
| v1.000 | v2.000 |
| v1.001 | v2.001 |
| ... | ... |
| v1.010 | v2.010 |
| v1.011 | v2.011.1 |
| v1.012 | v2.012.1 |
| v1.013 | v2.013 |

<!-- Named links -->

[gh-discuss-badge]: https://img.shields.io/badge/Discussions-Q&A-blue.svg?logo=github
[gh-discuss-link]: https://github.com/EA31337/EA31337-Strategies/discussions

[gh-edit-badge]: https://img.shields.io/badge/GitHub-edit-purple.svg?logo=github
[gh-edit-link]: https://github.dev/EA31337/Strategy-Demo

[gha-link-check-master]: https://github.com/EA31337/Strategy-Demo/actions?query=workflow:Check+branch%3Amaster
[gha-image-check-master]: https://github.com/EA31337/Strategy-Demo/workflows/Check/badge.svg?branch=master
[gha-link-compile-master]: https://github.com/EA31337/Strategy-Demo/actions?query=workflow:Compile+branch%3Amaster
[gha-image-compile-master]: https://github.com/EA31337/Strategy-Demo/workflows/Compile/badge.svg?branch=master

[tg-channel-image]: https://img.shields.io/badge/Telegram-join-0088CC.svg?logo=telegram
[tg-channel-link]: https://t.me/EA31337

[license-image]: https://img.shields.io/github/license/EA31337/EA31337-Strategies.svg
[license-link]: https://tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3)
13 changes: 13 additions & 0 deletions Stg_Demo.mq4
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//+------------------------------------------------------------------+
//| EA31337 - multi-strategy advanced trading robot |
//| Copyright 2016-2023, EA31337 Ltd |
//| https://github.com/EA31337 |
//+------------------------------------------------------------------+

/**
* @file
* Implements Demo strategy.
*/

// Includes the main code.
#include "Stg_Demo.mq5"
74 changes: 74 additions & 0 deletions Stg_Demo.mq5
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* @file
* Implements Demo strategy.
*/

// Includes conditional compilation directives.
#include "config/define.h"

// Includes EA31337 framework.
#include <EA31337-classes/EA.mqh>
#include <EA31337-classes/Indicators/Indi_Demo.mqh>
#include <EA31337-classes/Strategy.mqh>

// Inputs.
input int Active_Tfs = M15B + M30B + H1B + H2B + H3B + H4B + H6B +
H8B; // Timeframes (M1=1,M2=2,M5=16,M15=256,M30=1024,H1=2048,H2=4096,H3,H4,H6,H8)
input ENUM_LOG_LEVEL Log_Level = V_INFO; // Log level.
input bool Info_On_Chart = true; // Display info on chart.

// Includes strategy.
#include "Stg_Demo.mqh"

// Defines.
#define ea_name "Strategy Demo"
#define ea_version "1.013"
#define ea_desc "Strategy based on EA31337 framework."
#define ea_link "https://github.com/EA31337/Strategy-Demo"
#define ea_author "EA31337 Ltd"

// Properties.
#property version ea_version
#ifdef __MQL4__
#property description ea_name
#property description ea_desc
#endif
#property link ea_link
#property copyright "Copyright 2016-2023, EA31337 Ltd"

// Class variables.
EA *ea;

/* EA event handler functions */

/**
* Implements "Init" event handler function.
*
* Invoked once on EA startup.
*/
int OnInit() {
bool _result = true;
EAParams ea_params(__FILE__, Log_Level);
ea = new EA(ea_params);
_result &= ea.StrategyAdd<Stg_Demo>(Active_Tfs);
return (_result ? INIT_SUCCEEDED : INIT_FAILED);
}

/**
* Implements "Tick" event handler function (EA only).
*
* Invoked when a new tick for a symbol is received, to the chart of which the Expert Advisor is attached.
*/
void OnTick() {
ea.ProcessTick();
if (!ea.GetTerminal().IsOptimization()) {
ea.UpdateInfoOnChart();
}
}

/**
* Implements "Deinit" event handler function.
*
* Invoked once on EA exit.
*/
void OnDeinit(const int reason) { Object::Delete(ea); }
Loading

0 comments on commit ebd626a

Please sign in to comment.