Initial commit

This commit is contained in:
Nkondog Anselme
2021-11-14 05:36:01 +01:00
commit 407a205132
69 changed files with 5946 additions and 0 deletions
@@ -0,0 +1,155 @@
//+------------------------------------------------------------------+
//| EA_Template_1.0.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
#include <Expert\ExpertBase.mqh>
//Input section
//Some standard inputs
input double inpVolume = 0.01; //Default order size
input string inpComment = __FILE__; //Default trade comment
input int inpMagicNumber = 12345; //Magic number
//Declare the Expert
#define CExpert CExpertBase
CExpert *Expert;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//Assign the default values to the expert
Expert = new CExpert();
Expert.SetVolume(inpVolume);
Expert.SetTradeComment(__FILE__);
Expert.SetMagic(inpMagicNumber);
//--- create timer
EventSetTimer(60);
int result = Expert.OnInit();
//---
return(result);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
delete Expert;
return;
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
Expert.OnTick();
return;
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer()
{
//---
Expert.OnTimer();
return;
}
//+------------------------------------------------------------------+
//| Trade function |
//+------------------------------------------------------------------+
void OnTrade()
{
//---
Expert.OnTrade();
return;
}
//+------------------------------------------------------------------+
//| TradeTransaction function |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result)
{
//---
Expert.OnTradeTransaction(trans, request, result);
return;
}
//+------------------------------------------------------------------+
//| Tester function |
//+------------------------------------------------------------------+
double OnTester()
{
//---
//double ret=0.0;
//---
//---
//return(ret);
return(Expert.OnTester());
}
//+------------------------------------------------------------------+
//| TesterInit function |
//+------------------------------------------------------------------+
void OnTesterInit()
{
//---
Expert.OnTesterInit();
return;
}
//+------------------------------------------------------------------+
//| TesterPass function |
//+------------------------------------------------------------------+
void OnTesterPass()
{
//---
Expert.OnTesterPass();
return;
}
//+------------------------------------------------------------------+
//| TesterDeinit function |
//+------------------------------------------------------------------+
void OnTesterDeinit()
{
//---
Expert.OnTesterDeinit();
return;
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
//+------------------------------------------------------------------+
//| BookEvent function |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
//---
Expert.OnBookEvent();
return;
}
//+------------------------------------------------------------------+
@@ -0,0 +1,21 @@
/*
EA_Template.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Basic template for framework based MQ4 expert
Uses: framework_2.02 minimum
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// Load the common code
//
#include "EA_Template.mqh" // Remember to change this
@@ -0,0 +1,64 @@
/*
EA_Template.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Basic template for framework based MQ4 expert
Uses: framework_2.02 minimum
*/
#property copyright "Copyright 2012-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// Load the common code
//
#include "EA_Template.mqh" // Remember to change this
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
int OnTesterInit() {
return(Expert.OnTesterInit());
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
@@ -0,0 +1,182 @@
/*
EA_Template.mqh
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description: Holds common template code between MQ4 and MQ5
Uses: framework_2.02 minimum
*/
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20202020; // Magic Number
//
// Declare the expert, use the child class name
// If the base class does everything needed then it's OK to
// just use CExpertBase
// Declare the name CExpert as the actual class name.
// This allows other files to just refer to CExpert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators - use the child class name instead of CIndicatorBase
// Remove if not needed
//
CIndicatorBase *Indicator1;
//
// Signals - use the child class name instead of CSignalBase
// Remove if not needed
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
// Remove if not needed
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
// Remove if not needed
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert
// Uses the declared class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators - using your child class name
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals - using your child class names
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0); // Add as many indicators as you need
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0); // Add as many indicators as you need
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal); // repeat for more signals
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
// Delete all objects created
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
Binary file not shown.
@@ -0,0 +1,181 @@
/*
EA_Template.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
// Use the following line for the current framework
#include <Orchard/Frameworks/Framework.mqh>
// Use the following line for a specific framework (replace x.x)
//#include <Orchard/Frameworks/Framework_x.x/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators
//
CIndicatorBase *Indicator1;
//
// Signals
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Set up the indicators
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -0,0 +1,224 @@
/*
EA_Template.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2012-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
// Use the following line for the current framework
#include <Nkanven/Frameworks/Framework.mqh>
// Use the following line for a specific framework (replace x.x)
//#include <Orchard/Frameworks/Framework_x.x/Framework.mqh>
//
// Input Section
//
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Indicators
//
CIndicatorBase *Indicator1;
//
// Signals
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
CTPSLBase *TPObject;
CTPSLBase *SLObject;
//
// Indicators for TPSL - use child class names instead of CIndicatorBase
//
CIndicatorBase *IndicatorTPSL1;
CIndicatorBase *IndicatorTPSL2;
int OnInit() {
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Set up the indicators
//
Indicator1 = new CIndicatorBase();
//
// Set up the signals
//
EntrySignal = new CSignalBase();
EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalBase();
ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new CTPSLBase(); // Create the object
IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new CTPSLBase();
IndicatorTPSL2 = new CIndicatorBase();
SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete Indicator1;
delete TPObject;
delete SLObject;
delete IndicatorTPSL1;
delete IndicatorTPSL2;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
Binary file not shown.
@@ -0,0 +1,281 @@
//+------------------------------------------------------------------+
//| GridEA.mq5 |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
#property version "1.00"
#include <Nkanven/Frameworks/GridFramework.mqh>
//
// Input Section
//
//This is where you should include the input parameters for your entry and exit signals
input string Comment_strategy="=========="; //Entry And Exit Settings
//Add in this section the parameters for the indicators used in your entry and exit
//General input parameters
input string Comment_0="=========="; //Risk Management Settings
input ENUM_RISK_DEFAULT_SIZE InpRiskDefaultSize=RISK_DEFAULT_AUTO; //Position Size Mode
input double InpDefaultLotSize=1; //Position Size (if fixed or if no stop loss defined)
input ENUM_RISK_BASE InpRiskBase=RISK_BASE_BALANCE; //Risk Base
input double InpMaxRiskPerTrade=0.5; //Percentage To Risk Each Trade
input double InpMinLotSize=0.01; //Min Lot Size
input double InpMaxLotSize=100; //Max Lot Size
input string Comment_1="=========="; //Trading Hours Settings
input bool InpUseTradingHours=false; //Activate Trading Hours
input string InpTradingHourStart="01"; //Trading Start Hour (Broker Server Hour)
input string InpTradingStartMin="30"; //Trading Start minute
input string InpTradingHourEnd="23"; //Trading End Hour (Broker Server Hour)
input string InpTradingEndMin="00"; //Trading End minute
input bool InpUseTradingSession=true;
input ENUM_TRADING_SESSION InpTradingSession = LONDON_SESSION; //Trading session
input string Comment_2="=========="; //Trading Hours Settings
input int InpGridGap = 1000;
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
input int InpBrokerTimeZoneGMT = 2; //Broker timezone from GMT
input int InpSlippage = 2;
int londonSession[] = {7, 17};
int newyorkSession[] = {13, 23};
int tokyoSession[] = {0, 6};
//
// Declare the expert
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals
//
CSignalGrid *EntrySignal;
CSignalGrid *ExitSignal;
//
// TPSL - use child class names instead of CTPSLBase
//
GridTPSL *TPObject;
GridTPSL *SLObject;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//
// Instantiate the expert, use the child class name
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
Expert.SetDefaultLotSize(InpDefaultLotSize);
Expert.SetGridGap(InpGridGap);
Expert.SetGridNumber(10);
Expert.SetMaxLotSize(InpMaxLotSize);
Expert.SetMaxRiskPerTrade(InpMaxRiskPerTrade);
Expert.SetMinLotSize(InpMinLotSize);
Expert.SetRiskBase(InpRiskBase);
Expert.SetRiskDefaultSize(InpRiskDefaultSize);
Expert.SetUseTradingSession(InpTradingSession);
Expert.SetSlippage(InpSlippage);
//
// Set up the signals
//
EntrySignal = new CSignalGrid();
//EntrySignal.AddIndicator(Indicator1, 0);
ExitSignal = new CSignalGrid();
ExitSignal.SetMaxRiskPerTrade(InpMaxRiskPerTrade);
ExitSignal.setMmagic(InpMagicNumber);
//ExitSignal.AddIndicator(Indicator1, 0);
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(ExitSignal);
//
// If using fixed tp and sl set them here in points
//
Expert.SetTakeProfitValue(0);
Expert.SetStopLossValue(0);
//
// Set up the Take Profit and Stop Loss objects
// Remember to create child class names, not base
//
TPObject = new GridTPSL(); // Create the object
//IndicatorTPSL1 = new CIndicatorBase(); // Create an indicator for the tp object
//TPObject.AddIndicator(IndicatorTPSL1, 0); // Add the indicator to tp
// Set any other properties needed
// And for the SL object
SLObject = new GridTPSL();
//IndicatorTPSL2 = new CIndicatorBase();
//SLObject.AddIndicator(IndicatorTPSL2, 0);
Expert.SetTakeProfitObj(TPObject);
Expert.SetStopLossObj(SLObject);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
EventKillTimer();
delete Expert;
delete ExitSignal;
delete EntrySignal;
delete TPObject;
delete SLObject;
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
Expert.OnTick();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTimer()
{
Expert.OnTimer();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTrade()
{
Expert.OnTrade();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result)
{
Expert.OnTradeTransaction(trans, request, result);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
double OnTester()
{
return(Expert.OnTester());
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterInit()
{
Expert.OnTesterInit();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterPass()
{
Expert.OnTesterPass();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTesterDeinit()
{
Expert.OnTesterDeinit();
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
Expert.OnBookEvent();
return;
}
//+------------------------------------------------------------------+
@@ -0,0 +1,176 @@
/*
MA Crossover ATR TPSL.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
//
// For ATR based TPSL
//
input int InpATRPeriods = 14; // ATR Periods
input double InpATRMultiplier = 3.0; // ATR Multiplier
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200000; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
//
// TPSL - use child class name
//
CTPSLSimple *TPSL;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
// And for the TPSL
CIndicatorATR *IndicatorATR;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Set up the ATR TPSL
//
TPSL = new CTPSLSimple();
IndicatorATR = new CIndicatorATR(InpATRPeriods);
TPSL.AddIndicator(IndicatorATR, 0);
TPSL.SetIndex(1);
TPSL.SetMultiplier(InpATRMultiplier);
Expert.SetTakeProfitObj(TPSL);
Expert.SetStopLossObj(TPSL);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete EntrySignal;
delete TPSL;
delete FastIndicator;
delete SlowIndicator;
delete IndicatorATR;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -0,0 +1,221 @@
/*
MA Crossover ATR TPSL.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
//
// For ATR based TPSL
//
input int InpATRPeriods = 14; // ATR Periods
input double InpATRMultiplier = 3.0; // ATR Multiplier
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200000; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// TPSL
//
CTPSLSimple *TPSL;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
// And for the TPSL
CIndicatorATR *IndicatorATR;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Set up the ATR TPSL
//
TPSL = new CTPSLSimple();
IndicatorATR = new CIndicatorATR(InpATRPeriods);
TPSL.AddIndicator(IndicatorATR, 0);
TPSL.SetIndex(1);
TPSL.SetMultiplier(InpATRMultiplier);
Expert.SetTakeProfitObj(TPSL);
Expert.SetStopLossObj(TPSL);
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
delete EntrySignal;
delete TPSL;
delete FastIndicator;
delete SlowIndicator;
delete IndicatorATR;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
@@ -0,0 +1,153 @@
/*
MA Crossover.mq4
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Orchard/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
@@ -0,0 +1,197 @@
/*
MA Crossover.mq5
Copyright 2013-2020, Orchard Forex
https://www.orchardforex.com
Description:
*/
#property copyright "Copyright 2013-2020, Orchard Forex"
#property link "https://www.orchardforex.com"
#property version "1.00"
#property strict
//
// This is where we pull in the framework
//
#include <Nkanven/Frameworks/Framework.mqh>
//
// Input Section
//
// Fast moving average
input int InpFastPeriods = 10; // Fast periods
input ENUM_MA_METHOD InpFastMethod = MODE_SMA; // Fast method
input ENUM_APPLIED_PRICE InpFastAppliedPrice = PRICE_CLOSE; // Fast price
// Slow moving average
input int InpSlowPeriods = 20; // Slow periods
input ENUM_MA_METHOD InpSlowMethod = MODE_SMA; // Slow method
input ENUM_APPLIED_PRICE InpSlowAppliedPrice = PRICE_CLOSE; // Slow price
// Bar numbers for comparison
//input int InpBar2 = 2; // Base bar number
//input int InpBar1 = 1; // Crossover bar number
//
// Some standard inputs,
// remember to change the default magic for each EA
//
input double InpVolume = 0.01; // Default order size
input string InpComment = __FILE__; // Default trade comment
input int InpMagicNumber = 20200701; // Magic Number
//
// Declare the expert, use the child class name
//
#define CExpert CExpertBase
CExpert *Expert;
//
// Signals, use the child class names if applicable
//
CSignalBase *EntrySignal;
CSignalBase *ExitSignal;
//
// Indicators - use the child class name here
//
CIndicatorMA *FastIndicator;
CIndicatorMA *SlowIndicator;
int OnInit() {
//
// Instantiate the expert
//
Expert = new CExpert();
//
// Assign the default values to the expert
//
Expert.SetVolume(InpVolume);
Expert.SetTradeComment(InpComment);
Expert.SetMagic(InpMagicNumber);
//
// Create the indicators
//
FastIndicator = new CIndicatorMA(InpFastPeriods, 0, InpFastMethod, InpFastAppliedPrice);
SlowIndicator = new CIndicatorMA(InpSlowPeriods, 0, InpSlowMethod, InpSlowAppliedPrice);
//
// Set up the signals
//
EntrySignal = new CSignalCrossover();
EntrySignal.AddIndicator(FastIndicator, 0);
EntrySignal.AddIndicator(SlowIndicator, 0);
//ExitSignal = Not needed, using the same signal as entry
//
// Add the signals to the expert
//
Expert.AddEntrySignal(EntrySignal);
Expert.AddExitSignal(EntrySignal); // Same signal
//
// Finish expert initialisation and check result
//
int result = Expert.OnInit();
return(result);
}
void OnDeinit(const int reason) {
EventKillTimer();
delete Expert;
//delete ExitSignal;
delete EntrySignal;
delete FastIndicator;
delete SlowIndicator;
return;
}
void OnTick() {
Expert.OnTick();
return;
}
void OnTimer() {
Expert.OnTimer();
return;
}
void OnTrade() {
Expert.OnTrade();
return;
}
void OnTradeTransaction(const MqlTradeTransaction& trans,
const MqlTradeRequest& request,
const MqlTradeResult& result) {
Expert.OnTradeTransaction(trans, request, result);
return;
}
double OnTester() {
return(Expert.OnTester());
}
void OnTesterInit() {
Expert.OnTesterInit();
return;
}
void OnTesterPass() {
Expert.OnTesterPass();
return;
}
void OnTesterDeinit() {
Expert.OnTesterDeinit();
return;
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
Expert.OnChartEvent(id, lparam, dparam, sparam);
return;
}
void OnBookEvent(const string &symbol) {
Expert.OnBookEvent();
return;
}
Binary file not shown.