Initial Commit ...
This commit is contained in:
@@ -0,0 +1,319 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XTM Indicator Helper for Signal Providers
|
||||
// --------------------------------------------------------------------------
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "..\Libraries\x-saherelm.log.lib.mq5"
|
||||
#include "..\Libraries\x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Enum Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// XTM Indicator States ...
|
||||
enum ENUM_X_XTM_STATES
|
||||
{
|
||||
X_XTM_BULLISH = 1,
|
||||
X_XTM_BEARISH = -1,
|
||||
X_XTM_NEUTURAL = 0,
|
||||
};
|
||||
|
||||
//
|
||||
// XTM Indicator Buffer Lines ...
|
||||
enum ENUM_X_XTM_BUFFER_LINES
|
||||
{
|
||||
X_XTM_MA_LINE = 0,
|
||||
X_XTM_MC_COLOR_LINE = 1,
|
||||
X_XTM_STATE_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// END Enum Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
input group "XTM Indicator";
|
||||
input int xTMMaPeriod = 14; // Period
|
||||
input int xTMMaShift = 0; // Shift
|
||||
input ENUM_MA_METHOD xTMMaMethod = MODE_EMA; // Method
|
||||
input ENUM_APPLIED_PRICE xTMMaAppliedTo = PRICE_WEIGHTED; // Applied To
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
int xTMHandler = INVALID_HANDLE;
|
||||
double xTMMaBuffer[];
|
||||
double xTMStateBuffer[];
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Handler Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Init Indicators ...
|
||||
bool XTMInitHandlers()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize Indicator/Oscillator Handlers ...
|
||||
ResetLastError();
|
||||
|
||||
//
|
||||
// XTM Handler ...
|
||||
ArraySetAsSeries(xTMMaBuffer, true);
|
||||
ArraySetAsSeries(xTMStateBuffer, true);
|
||||
xTMHandler = iCustom(
|
||||
_Symbol,
|
||||
_Period,
|
||||
"x-saherelm.xtm.indicator",
|
||||
//
|
||||
// Inputs ...
|
||||
xTMMaPeriod,
|
||||
xTMMaShift,
|
||||
xTMMaMethod,
|
||||
xTMMaAppliedTo);
|
||||
if (xTMHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
LogMessage("failed to Initialize XTM Indicator: " + (string)GetLastError());
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// xTMOHandler ...
|
||||
// ArraySetAsSeries(xTMOBuffer, true);
|
||||
// xTMOHandler = iCustom(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// "x-saherelm.xma.indicator",
|
||||
// //
|
||||
// // Inputs ...
|
||||
// xTMMaPeriod,
|
||||
// xTMMaShift,
|
||||
// MODE_SMA,
|
||||
// PRICE_OPEN);
|
||||
// if (xTMOHandler == INVALID_HANDLE)
|
||||
// {
|
||||
// //
|
||||
// LogMessage("failed to Initialize XMA Indicator: " + (string)GetLastError());
|
||||
// return result;
|
||||
// }
|
||||
|
||||
//
|
||||
result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Release Indicators ...
|
||||
void XTMReleaseHandlers()
|
||||
{
|
||||
IndicatorRelease(xTMHandler);
|
||||
// IndicatorRelease(xTMOHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Reading Buffers ...
|
||||
void XTMReadBuffers(
|
||||
int xTMItemsPerTick // Number Of Reading Buffer Items Per Tick
|
||||
)
|
||||
{
|
||||
//
|
||||
// Ma Buffer ...
|
||||
CopyBuffer(
|
||||
xTMHandler,
|
||||
X_XTM_MA_LINE,
|
||||
0,
|
||||
xTMItemsPerTick,
|
||||
xTMMaBuffer);
|
||||
|
||||
//
|
||||
// State Buffer ...
|
||||
CopyBuffer(
|
||||
xTMHandler,
|
||||
X_XTM_STATE_LINE,
|
||||
0,
|
||||
xTMItemsPerTick,
|
||||
xTMStateBuffer);
|
||||
|
||||
//
|
||||
// XTMO Buffer ...
|
||||
// CopyBuffer(
|
||||
// xTMOHandler,
|
||||
// 0,
|
||||
// 0,
|
||||
// xTMItemsPerTick,
|
||||
// xTMOBuffer);
|
||||
}
|
||||
|
||||
//
|
||||
// END Handler Funcions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Signal Related Conditions ...
|
||||
//
|
||||
|
||||
//
|
||||
// XTM Long Conditions ...
|
||||
bool XTMHasLongConditions(
|
||||
int xTMItemsPerTick // Number Of Reading Buffer Items Per Tick
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bool isVale = XTMIsVale();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
isVale
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XTM Short Conditions ...
|
||||
bool XTMHasShortConditions(
|
||||
int xTMItemsPerTick // Number Of Reading Buffer Items Per Tick
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bool isPeak = XTMIsPeak();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
isPeak
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Signal Related Conditions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START XTM Custom Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Find Peak based On this Indicator ...
|
||||
bool XTMIsPeak()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Must Decreasing ...
|
||||
bool isIncreasing = IsIncreasing(
|
||||
20,
|
||||
5,
|
||||
xTMMaBuffer);
|
||||
|
||||
//
|
||||
// Must Increasing ...
|
||||
bool isDecreasing = IsDecreasing(
|
||||
5,
|
||||
1,
|
||||
xTMMaBuffer);
|
||||
|
||||
//
|
||||
// Calculate Result ...
|
||||
result =
|
||||
//
|
||||
isIncreasing
|
||||
//
|
||||
&&
|
||||
//
|
||||
isDecreasing
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Vale based On this Indicator ...
|
||||
bool XTMIsVale()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Must Decreasing ...
|
||||
bool isIncreasing = IsIncreasing(
|
||||
5,
|
||||
1,
|
||||
xTMMaBuffer);
|
||||
|
||||
//
|
||||
// Must Increasing ...
|
||||
bool isDecreasing = IsDecreasing(
|
||||
20,
|
||||
5,
|
||||
xTMMaBuffer);
|
||||
|
||||
//
|
||||
// Calculate Result ...
|
||||
result =
|
||||
//
|
||||
isIncreasing
|
||||
//
|
||||
&&
|
||||
//
|
||||
isDecreasing
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END XTM Custom Functions ...
|
||||
//
|
||||
Reference in New Issue
Block a user