mirror of
https://github.com/rithsila/MT5-EA-Sniper-Strategy.git
synced 2026-08-19 05:38:15 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
SignalCombination.mqh
|
||||
For framework version 1.0
|
||||
|
||||
Copyright 2013-2020, Orchard Forex
|
||||
https://www.orchardforex.com
|
||||
|
||||
*/
|
||||
|
||||
#include "../../Framework.mqh"
|
||||
|
||||
class CSignalCombination : public CSignalBase {
|
||||
|
||||
private:
|
||||
|
||||
protected: // member variables
|
||||
|
||||
CSignalBase *mSignals[];
|
||||
|
||||
public: // constructors
|
||||
|
||||
CSignalCombination(string symbol, ENUM_TIMEFRAMES timeframe)
|
||||
: CSignalBase(symbol, timeframe)
|
||||
{ Init(); }
|
||||
CSignalCombination()
|
||||
: CSignalBase()
|
||||
{ Init(); }
|
||||
~CSignalCombination() { }
|
||||
|
||||
int Init();
|
||||
|
||||
public:
|
||||
|
||||
virtual void AddSignal(CSignalBase *signal);
|
||||
virtual void UpdateSignal();
|
||||
|
||||
};
|
||||
|
||||
int CSignalCombination::Init() {
|
||||
|
||||
if (InitResult()!=INIT_SUCCEEDED) return(InitResult());
|
||||
|
||||
ArrayResize(mSignals, 0);
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
|
||||
}
|
||||
|
||||
void CSignalCombination::UpdateSignal() {
|
||||
|
||||
int index = ArraySize(mSignals);
|
||||
|
||||
if (index<=0) {
|
||||
|
||||
mEntrySignal = OFX_SIGNAL_NONE;
|
||||
mExitSignal = OFX_SIGNAL_NONE;
|
||||
|
||||
} else {
|
||||
|
||||
mSignals[0].UpdateSignal();
|
||||
mEntrySignal = mSignals[0].EntrySignal();
|
||||
mExitSignal = mSignals[0].ExitSignal();
|
||||
|
||||
for (int i = 1; i<index; i++) {
|
||||
|
||||
mSignals[i].UpdateSignal();
|
||||
if (mSignals[i].EntrySignal()!=mEntrySignal) mEntrySignal = OFX_SIGNAL_NONE;
|
||||
if (mSignals[i].ExitSignal()!=mExitSignal) mExitSignal = OFX_SIGNAL_NONE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void CSignalCombination::AddSignal(CSignalBase *signal) {
|
||||
|
||||
int index = ArraySize(mSignals);
|
||||
ArrayResize(mSignals, index+1);
|
||||
mSignals[index] = signal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
SignalCrossover.mqh
|
||||
For framework version 1.0
|
||||
|
||||
Copyright 2013-2020, Orchard Forex
|
||||
https://www.orchardforex.com
|
||||
|
||||
*/
|
||||
|
||||
#include "../../Framework.mqh"
|
||||
|
||||
class CSignalCrossover : public CSignalBase {
|
||||
|
||||
private:
|
||||
|
||||
protected: // member variables
|
||||
|
||||
int mIndex1;
|
||||
int mIndex2;
|
||||
|
||||
public: // constructors
|
||||
|
||||
CSignalCrossover(string symbol, ENUM_TIMEFRAMES timeframe,
|
||||
int index1=1, int index2=2)
|
||||
: CSignalBase(symbol, timeframe)
|
||||
{ Init(index1, index2); }
|
||||
CSignalCrossover(int index1=1, int index2=2)
|
||||
: CSignalBase()
|
||||
{ Init(index1, index2); }
|
||||
~CSignalCrossover() { }
|
||||
|
||||
int Init(int index1, int index2);
|
||||
|
||||
public:
|
||||
|
||||
virtual void UpdateSignal();
|
||||
|
||||
};
|
||||
|
||||
int CSignalCrossover::Init(int index1, int index2) {
|
||||
|
||||
if (InitResult()!=INIT_SUCCEEDED) return(InitResult());
|
||||
|
||||
mIndex1 = index1;
|
||||
mIndex2 = index2;
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
|
||||
}
|
||||
|
||||
void CSignalCrossover::UpdateSignal() {
|
||||
|
||||
double fast1 = GetIndicatorData(0, mIndex1);
|
||||
double fast2 = GetIndicatorData(0, mIndex2);
|
||||
double slow1 = GetIndicatorData(1, mIndex1);
|
||||
double slow2 = GetIndicatorData(1, mIndex2);
|
||||
|
||||
// There is a less common condition where the fast
|
||||
// indicator touches the slow indicator and then
|
||||
// reverses. With the conditions below this would
|
||||
// appear like a cross.
|
||||
if ( (fast1>slow1) && !(fast2>slow2) ) { // Crossed up
|
||||
mEntrySignal = OFX_SIGNAL_BUY;
|
||||
mExitSignal = OFX_SIGNAL_SELL;
|
||||
} else
|
||||
if ( (fast1<slow1) && !(fast2<slow2) ) { // Crossed down
|
||||
mEntrySignal = OFX_SIGNAL_SELL;
|
||||
mExitSignal = OFX_SIGNAL_BUY;
|
||||
} else {
|
||||
mEntrySignal = OFX_SIGNAL_NONE;
|
||||
mExitSignal = OFX_SIGNAL_NONE;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
//+------------------------------------------------------------------+
|
||||
//| SignalGrid.mqh |
|
||||
//| Copyright 2021, Nkondog Anselme Venceslas |
|
||||
//| https://www.mql5.com |
|
||||
//+------------------------------------------------------------------+
|
||||
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
|
||||
#property link "https://www.mql5.com"
|
||||
// Next line assumes this file is located in .../Frameworks/Extensions/someFolder
|
||||
#include "../../GridFramework.mqh"
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
class CSignalGrid : public CSignalBase
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
protected: // member variables
|
||||
|
||||
// Place any required member variables here
|
||||
int m_magic;
|
||||
|
||||
public: // constructors
|
||||
|
||||
// Add any required constructor arguments
|
||||
// e.g. CSignalXYZ(int periods, double multiplier)
|
||||
CSignalGrid()
|
||||
: CSignalBase()
|
||||
{ Init(); }
|
||||
// Same constructor with symbol and timeframe added
|
||||
CSignalGrid(string symbol, ENUM_TIMEFRAMES timeframe)
|
||||
: CSignalBase(symbol, timeframe)
|
||||
{ Init(); }
|
||||
~CSignalGrid() { }
|
||||
|
||||
// Include all arguments to match the constructor
|
||||
int Init();
|
||||
|
||||
public:
|
||||
|
||||
// Add this line to override the same function from the parent class
|
||||
virtual void UpdateSignal();
|
||||
|
||||
virtual void setMmagic(int magic) {m_magic = magic;}
|
||||
|
||||
};
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
int CSignalGrid::Init()
|
||||
{
|
||||
|
||||
// Checks if init has been set to fail by any parent class already
|
||||
if(InitResult()!=INIT_SUCCEEDED)
|
||||
return(InitResult());
|
||||
|
||||
// Assign variables and do any other initialisation here
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
|
||||
}
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| |
|
||||
//+------------------------------------------------------------------+
|
||||
void CSignalGrid::UpdateSignal()
|
||||
{
|
||||
|
||||
// Just gather data from the indicators and
|
||||
// decide on a trade direction
|
||||
// This is the trade decision logic
|
||||
//CSignalBase signal = new CSignalBase();
|
||||
|
||||
|
||||
|
||||
}
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
SignalTemplate.mqh
|
||||
Updated as of framework version 2.02
|
||||
|
||||
Copyright 2013-2020, Orchard Forex
|
||||
https://www.orchardforex.com
|
||||
|
||||
*/
|
||||
|
||||
// Next line assumes this file is located in .../Frameworks/Extensions/someFolder
|
||||
#include "../../Framework.mqh"
|
||||
|
||||
class CSignalTemplate : public CSignalBase {
|
||||
|
||||
private:
|
||||
|
||||
protected: // member variables
|
||||
|
||||
// Place any required member variables here
|
||||
|
||||
public: // constructors
|
||||
|
||||
// Add any required constructor arguments
|
||||
// e.g. CSignalXYZ(int periods, double multiplier)
|
||||
CSignalTemplate()
|
||||
: CSignalBase()
|
||||
{ Init(); }
|
||||
// Same constructor with symbol and timeframe added
|
||||
CSignalTemplate(string symbol, ENUM_TIMEFRAMES timeframe)
|
||||
: CSignalBase(symbol, timeframe)
|
||||
{ Init(); }
|
||||
~CSignalTemplate() { }
|
||||
|
||||
// Include all arguments to match the constructor
|
||||
int Init();
|
||||
|
||||
public:
|
||||
|
||||
// Add this line to override the same function from the parent class
|
||||
virtual void UpdateSignal();
|
||||
|
||||
};
|
||||
|
||||
int CSignalTemplate::Init() {
|
||||
|
||||
// Checks if init has been set to fail by any parent class already
|
||||
if (InitResult()!=INIT_SUCCEEDED) return(InitResult());
|
||||
|
||||
// Assign variables and do any other initialisation here
|
||||
|
||||
return(INIT_SUCCEEDED);
|
||||
|
||||
}
|
||||
|
||||
void CSignalTemplate::UpdateSignal() {
|
||||
|
||||
// Just gather data from the indicators and
|
||||
// decide on a trade direction
|
||||
// This is the trade decision logic
|
||||
|
||||
mExitSignal = OFX_SIGNAL_NONE; // This strategy has no exit signal
|
||||
// Just set the buy or sell signals now
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user