generated from EA31337/Strategy-MA_Cross_Pivot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Stg_MA_Cross_Sup_Res.mq5
83 lines (72 loc) · 2.42 KB
/
Stg_MA_Cross_Sup_Res.mq5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* @file
* Implements MA Cross Sup/Res strategy.
*/
// Includes conditional compilation directives.
#include "config/define.h"
// Includes EA31337 framework.
#include <EA31337-classes/EA.mqh>
#include <EA31337-classes/Indicators/Indi_AMA.mqh>
#include <EA31337-classes/Indicators/Indi_DEMA.mqh>
#include <EA31337-classes/Indicators/Indi_FractalAdaptiveMA.mqh>
#include <EA31337-classes/Indicators/Indi_Ichimoku.mqh>
#include <EA31337-classes/Indicators/Indi_MA.mqh>
#include <EA31337-classes/Indicators/Indi_PriceChannel.mqh>
#include <EA31337-classes/Indicators/Indi_SAR.mqh>
#include <EA31337-classes/Indicators/Indi_TEMA.mqh>
#include <EA31337-classes/Indicators/Indi_VIDYA.mqh>
#include <EA31337-classes/Strategy.mqh>
// Inputs.
INPUT_GROUP("MA Cross Sup/Res strategy: main");
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_MA_Cross_Sup_Res.mqh"
// Defines.
#define ea_name "Strategy MA Cross Sup/Res"
#define ea_version "2.000"
#define ea_desc "Strategy based on the moving average price indicators implementing support/resistance cross signal."
#define ea_link "https://github.com/EA31337/Strategy-MA_Cross_Sup_Res"
#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_MA_Cross_Sup_Res>(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); }