Skip to content

Commit

Permalink
Renames Demo to Arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed Aug 18, 2023
1 parent 29e206e commit e947668
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 195 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/backtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ jobs:
include: .
init-platform: true
mt-version: 5.0.0.2361
path: Stg_Demo.mq4
path: Stg_Arrows.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
path: Stg_Arrows.mq5
verbose: true
- name: List compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
OptFormatBrief: true
OptFormatJson: true
OptVerbose: true
TestExpert: "Stg_Demo"
TestExpert: "Stg_Arrows"
TestPeriod: M1
TestReportName: Report-${{ matrix.year }}-${{ matrix.month }}
- name: Upload results
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ jobs:
include: .
init-platform: true
mt-version: 5.0.0.2361
path: Stg_Demo.mq4
path: Stg_Arrows.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
path: Stg_Arrows.mq5
verbose: true
- name: List compiled files
run: '(Get-ChildItem -Recurse -Path . -Include *.ex[45]).fullname'
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Strategy Demo
# Strategy Arrows

[![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]

Strategy based on the Demo indicator.
Strategy based on the Arrows indicator.

This is example demo strategy for the demonstration purposes.
This is example arrows strategy for the arrowsnstration purposes.

## Dependencies

Expand All @@ -25,10 +25,10 @@ This is example demo strategy for the demonstration purposes.
[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

[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
[gha-link-check-master]: https://github.com/EA31337/Strategy-Arrows/actions?query=workflow:Check+branch%3Amaster
[gha-image-check-master]: https://github.com/EA31337/Strategy-Arrows/workflows/Check/badge.svg?branch=master
[gha-link-compile-master]: https://github.com/EA31337/Strategy-Arrows/actions?query=workflow:Compile+branch%3Amaster
[gha-image-compile-master]: https://github.com/EA31337/Strategy-Arrows/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
Expand Down
4 changes: 2 additions & 2 deletions Stg_Demo.mq4 → Stg_Arrows.mq4
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

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

// Includes the main code.
#include "Stg_Demo.mq5"
#include "Stg_Arrows.mq5"
12 changes: 6 additions & 6 deletions Stg_Demo.mq5 → Stg_Arrows.mq5
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* @file
* Implements Demo strategy.
* Implements Arrows 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/Indicators/Indi_Arrows.mqh>
#include <EA31337-classes/Strategy.mqh>

// Inputs.
Expand All @@ -18,13 +18,13 @@ 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"
#include "Stg_Arrows.mqh"

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

// Properties.
Expand All @@ -50,7 +50,7 @@ int OnInit() {
bool _result = true;
EAParams ea_params(__FILE__, Log_Level);
ea = new EA(ea_params);
_result &= ea.StrategyAdd<Stg_Demo>(Active_Tfs);
_result &= ea.StrategyAdd<Stg_Arrows>(Active_Tfs);
return (_result ? INIT_SUCCEEDED : INIT_FAILED);
}

Expand Down
115 changes: 115 additions & 0 deletions Stg_Arrows.mqh
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* @file
* Implements Arrows strategy based on the Arrows indicator.
*/

// User input params.
INPUT_GROUP("Arrows strategy: strategy params");
INPUT float Arrows_LotSize = 0; // Lot size
INPUT int Arrows_SignalOpenMethod = 0; // Signal open method
INPUT float Arrows_SignalOpenLevel = 0; // Signal open level
INPUT int Arrows_SignalOpenFilterMethod = 32; // Signal open filter method
INPUT int Arrows_SignalOpenFilterTime = 3; // Signal open filter time (0-31)
INPUT int Arrows_SignalOpenBoostMethod = 0; // Signal open boost method
INPUT int Arrows_SignalCloseMethod = 0; // Signal close method
INPUT int Arrows_SignalCloseFilter = 32; // Signal close filter (-127-127)
INPUT float Arrows_SignalCloseLevel = 0; // Signal close level
INPUT int Arrows_PriceStopMethod = 0; // Price limit method
INPUT float Arrows_PriceStopLevel = 2; // Price limit level
INPUT int Arrows_TickFilterMethod = 32; // Tick filter method (0-255)
INPUT float Arrows_MaxSpread = 4.0; // Max spread to trade (in pips)
INPUT short Arrows_Shift = 0; // Shift
INPUT float Arrows_OrderCloseLoss = 80; // Order close loss
INPUT float Arrows_OrderCloseProfit = 80; // Order close profit
INPUT int Arrows_OrderCloseTime = -30; // Order close time in mins (>0) or bars (<0)
INPUT_GROUP("Arrows strategy: Arrows indicator params");
INPUT int Arrows_Indi_Arrows_Shift = 0; // Shift
INPUT ENUM_IDATA_SOURCE_TYPE Arrows_Indi_Arrows_SourceType = IDATA_INDICATOR; // Source type

// Structs.

// Defines struct with default user strategy values.
struct Stg_Arrows_Params_Defaults : StgParams {
Stg_Arrows_Params_Defaults()
: StgParams(::Arrows_SignalOpenMethod, ::Arrows_SignalOpenFilterMethod, ::Arrows_SignalOpenLevel,
::Arrows_SignalOpenBoostMethod, ::Arrows_SignalCloseMethod, ::Arrows_SignalCloseFilter,
::Arrows_SignalCloseLevel, ::Arrows_PriceStopMethod, ::Arrows_PriceStopLevel,
::Arrows_TickFilterMethod, ::Arrows_MaxSpread, ::Arrows_Shift) {
Set(STRAT_PARAM_LS, Arrows_LotSize);
Set(STRAT_PARAM_OCL, Arrows_OrderCloseLoss);
Set(STRAT_PARAM_OCP, Arrows_OrderCloseProfit);
Set(STRAT_PARAM_OCT, Arrows_OrderCloseTime);
Set(STRAT_PARAM_SOFT, Arrows_SignalOpenFilterTime);
}
};

#ifdef __config__
// Loads pair specific param values.
#include "config/H1.h"
#include "config/H4.h"
#include "config/H8.h"
#include "config/M1.h"
#include "config/M15.h"
#include "config/M30.h"
#include "config/M5.h"
#endif

class Stg_Arrows : public Strategy {
public:
Stg_Arrows(StgParams &_sparams, TradeParams &_tparams, ChartParams &_cparams, string _name = "")
: Strategy(_sparams, _tparams, _cparams, _name) {}

static Stg_Arrows *Init(ENUM_TIMEFRAMES _tf = NULL, EA *_ea = NULL) {
// Initialize strategy initial values.
Stg_Arrows_Params_Defaults stg_arrows_defaults;
StgParams _stg_params(stg_arrows_defaults);
#ifdef __config__
SetParamsByTf<StgParams>(_stg_params, _tf, stg_arrows_m1, stg_arrows_m5, stg_arrows_m15, stg_arrows_m30,
stg_arrows_h1, stg_arrows_h4, stg_arrows_h8);
#endif
// Initialize indicator.
// Initialize Strategy instance.
ChartParams _cparams(_tf, _Symbol);
TradeParams _tparams;
Strategy *_strat = new Stg_Arrows(_stg_params, _tparams, _cparams, "Arrows");
return _strat;
}

/**
* Event on strategy's init.
*/
void OnInit() {
IndiArrowsParams _indi_params(::Arrows_Indi_Arrows_Shift);
_indi_params.SetTf(Get<ENUM_TIMEFRAMES>(STRAT_PARAM_TF));
SetIndicator(new Indi_Arrows(_indi_params));
}

/**
* Check strategy's opening signal.
*/
bool SignalOpen(ENUM_ORDER_TYPE _cmd, int _method, float _level = 0.0f, int _shift = 0) {
Indi_Arrows *_indi = GetIndicator();
bool _result =
_indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift) && _indi.GetFlag(INDI_ENTRY_FLAG_IS_VALID, _shift + 1);
if (!_result) {
// Returns false when indicator data is not valid.
return false;
}
IndicatorSignal _signals = _indi.GetSignals(4, _shift);
switch (_cmd) {
case ORDER_TYPE_BUY:
// Buy signal.
_result &= _indi.IsIncreasing(1, 0, _shift);
_result &= _indi.IsIncByPct(_level / 10, 0, _shift, 2);
_result &= _method > 0 ? _signals.CheckSignals(_method) : _signals.CheckSignalsAll(-_method);
break;
case ORDER_TYPE_SELL:
// Sell signal.
_result &= _indi.IsDecreasing(1, 0, _shift);
_result &= _indi.IsDecByPct(_level / 10, 0, _shift, 2);
_result &= _method > 0 ? _signals.CheckSignals(_method) : _signals.CheckSignalsAll(-_method);
break;
}
return _result;
}
};
115 changes: 0 additions & 115 deletions Stg_Demo.mqh

This file was deleted.

12 changes: 6 additions & 6 deletions config/H1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

// Defines indicator's parameter values for the given pair symbol and timeframe.
struct Indi_Demo_Params_H1 : IndiDemoParams {
Indi_Demo_Params_H1() : IndiDemoParams(indi_demo_defaults, PERIOD_H1) { shift = 0; }
} indi_demo_h1;
struct Indi_Arrows_Params_H1 : IndiArrowsParams {
Indi_Arrows_Params_H1() : IndiArrowsParams(indi_arrows_defaults, PERIOD_H1) { shift = 0; }
} indi_arrows_h1;

// Defines strategy's parameter values for the given pair symbol and timeframe.
struct Stg_Demo_Params_H1 : StgParams {
struct Stg_Arrows_Params_H1 : StgParams {
// Struct constructor.
Stg_Demo_Params_H1() : StgParams(stg_demo_defaults) {}
} stg_demo_h1;
Stg_Arrows_Params_H1() : StgParams(stg_arrows_defaults) {}
} stg_arrows_h1;
12 changes: 6 additions & 6 deletions config/H4.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

// Defines indicator's parameter values for the given pair symbol and timeframe.
struct Indi_Demo_Params_H4 : IndiDemoParams {
Indi_Demo_Params_H4() : IndiDemoParams(indi_demo_defaults, PERIOD_H4) { shift = 0; }
} indi_demo_h4;
struct Indi_Arrows_Params_H4 : IndiArrowsParams {
Indi_Arrows_Params_H4() : IndiArrowsParams(indi_arrows_defaults, PERIOD_H4) { shift = 0; }
} indi_arrows_h4;

// Defines strategy's parameter values for the given pair symbol and timeframe.
struct Stg_Demo_Params_H4 : StgParams {
struct Stg_Arrows_Params_H4 : StgParams {
// Struct constructor.
Stg_Demo_Params_H4() : StgParams(stg_demo_defaults) {}
} stg_demo_h4;
Stg_Arrows_Params_H4() : StgParams(stg_arrows_defaults) {}
} stg_arrows_h4;
Loading

0 comments on commit e947668

Please sign in to comment.