add MQL5Test Workspace Content as BKP Solution ...

This commit is contained in:
2024-04-22 07:42:50 +03:30
parent ec0a03203e
commit f7fd579a9d
197 changed files with 80113 additions and 0 deletions
@@ -0,0 +1,438 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXAMAHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XAMAInputs
{
//
// Makret ...
int length; // Length
int fastEMA; // Fast EMA Length
int slowEMA; // Slow EMA Length
int maShift; // Shift
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Presentation ...
bool showLine; // Show Line
};
//
// Index of Lines ...
enum ENUM_XAMA_BUFFERS
{
//
// Main Requirements ...
XAMA_LINE = 0,
XAMA_STATE_LINE = 1,
};
//
// XAMA Indicator States ...
enum ENUM_XAMA_STATES
{
X_XAMA_BULLISH = 0,
X_XAMA_BEARISH = 2,
X_XAMA_NEUTURAL = 1,
};
//
// Retrieve Info Model ...
struct XAMAInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double value;
//
// State ...
ENUM_XAMA_STATES state;
//
// Conditions ...
//
// Detect Trend is Bullish or not ...
bool isBullish;
//
// Detect Trend is Switched to Bullish Or not ...
bool isSwitchedBullish;
//
// Detect Trend is Bearish or not ...
bool isBearish;
//
// Detect Trend is Switched to Bearish Or not ...
bool isSwitchedBearish;
//
// Detect Trend is Neutural or not ...
bool isNeutural;
//
// Detect Trend is Switched to Neutural Or not ...
bool isSwitchedNeutural;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXAMAHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double valueBuffer[];
double stateBuffer[];
//
// Constructor ...
void XSCXAMAHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXAMAHelper()
{
}
//
// START Properties ...
//
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XAMA" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = mLength;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Args ...
result =
//
(mLength >= 2)
//
;
if (!result)
{
return false;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xama",
//
// Inputs ...
//
// Makret ...
"",
//
// Length ...
mLength,
//
// Fast EMA Length ...
mFastEMA,
//
// Slow EMA Length ...
mSlowEMA,
//
// Shift ...
mMaShift,
//
// Applied To ...
mAppliedTo,
//
// Presentation ...
"",
//
// Show Line ...
mShowLine
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XAMAInputs GetConfig()
{
//
XAMAInputs result;
//
result.length = mLength;
result.fastEMA = mFastEMA;
result.slowEMA = mSlowEMA;
result.maShift = mMaShift;
result.appliedTo = mAppliedTo;
result.showLine = mShowLine;
//
return result;
}
//
// Set Config ...
bool SetConfig(XAMAInputs &config)
{
//
bool result = false;
//
mLength = config.length;
mFastEMA = config.fastEMA;
mSlowEMA = config.slowEMA;
mMaShift = config.maShift;
mAppliedTo = config.appliedTo;
mShowLine = config.showLine;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// VALUE ...
ArraySetAsSeries(valueBuffer, true);
CopyBuffer(
mHandler,
XAMA_LINE,
barIndex,
mLoopbackBars,
valueBuffer);
//
// STATE ...
ArraySetAsSeries(stateBuffer, true);
CopyBuffer(
mHandler,
XAMA_STATE_LINE,
barIndex,
mLoopbackBars,
stateBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XAMAInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XAMAInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
result.value = valueBuffer[barIndex];
//
ENUM_XAMA_STATES state = (ENUM_XAMA_STATES)stateBuffer[barIndex];
ENUM_XAMA_STATES prevState = (ENUM_XAMA_STATES)stateBuffer[barIndex + 1];
result.state = state;
//
result.isBullish = state == X_XAMA_BULLISH;
result.isBearish = state == X_XAMA_BEARISH;
result.isNeutural = state == X_XAMA_NEUTURAL;
//
result.isSwitchedBullish =
state == X_XAMA_BULLISH && prevState != X_XAMA_BULLISH;
result.isSwitchedBearish =
state == X_XAMA_BEARISH && prevState != X_XAMA_BEARISH;
result.isSwitchedNeutural =
state == X_XAMA_NEUTURAL && prevState != X_XAMA_NEUTURAL;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Length ...
int mLength;
//
// Fast EMA Length ...
int mFastEMA;
//
// Slow EMA Length ...
int mSlowEMA;
//
// Shift ...
int mMaShift;
//
// Applied To ...
ENUM_APPLIED_PRICE mAppliedTo;
//
// Presentation ...
//
// Show Line ...
bool mShowLine;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,293 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCCHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
struct XCCInputs
{
//
// Chart Style ...
color upColor; // Up Color
color downColor; // Down Color
color lineColor; // Line mode and Doji candlestick Color
color bearishColor; // Bullish Color
color bullishColor; // Bearish Color
color volumesColor; // Volumes Color
//
// Presentation ...
bool showCandles; // Show Candles
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXCCHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Constructor ...
void XSCXCCHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXCCHelper()
{
}
//
// START Properties ...
//
//
// Show Candles ...
bool ShowCandles(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowCandles == show)
{
return true;
}
//
mShowCandles = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XCC" + GetTagPrefix();
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
) {}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = 2;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xcc",
//
// Inputs ...
//
// Chart Style ...
"",
//
// Up Color ...
mUpColor,
//
// Down Color ...
mDownColor,
//
// Line mode and Doji candlestick Color ...
mLineColor,
//
// Bullish Color ...
mBearishColor,
//
// Bearish Color ...
mBullishColor,
//
// Volumes Color ...
mVolumesColor,
//
// Presentation ...
"",
//
// Show Candles ...
mShowCandles
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XCCInputs GetConfig()
{
//
XCCInputs result;
//
result.upColor = mUpColor;
result.downColor = mDownColor;
result.lineColor = mLineColor;
result.bearishColor = mBearishColor;
result.bullishColor = mBullishColor;
result.volumesColor = mVolumesColor;
result.showCandles = mShowCandles;
//
return result;
}
//
// Set Config ...
bool SetConfig(XCCInputs &config)
{
//
bool result = false;
//
mUpColor = config.upColor;
mDownColor = config.downColor;
mLineColor = config.lineColor;
mBearishColor = config.bearishColor;
mBullishColor = config.bullishColor;
mVolumesColor = config.volumesColor;
mShowCandles = config.showCandles;
//
result = Init();
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Chart Style ...
//
// Up Color ...
color mUpColor;
//
// Down Color ...
color mDownColor;
//
// Line mode and Doji candlestick Color ...
color mLineColor;
//
// Bullish Color ...
color mBearishColor;
//
// Bearish Color ...
color mBullishColor;
//
// Volumes Color ...
color mVolumesColor;
//
// Presentation ...
//
// Show Candles ...
bool mShowCandles;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,594 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCHEHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XCHEInputs
{
//
// Market ...
int length; // Length
int loopback; // Loopback
double multiplier1; // 1st Multiplier
double multiplier2; // 2nd Multiplier
//
// Calculation ...
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied to
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied to
//
// Presentation ...
bool showLongExit1Line; // Show 1st Long Exit
bool showShortExit1Line; // Show 1st Short Exit
bool showLongExit2Line; // Show 2st Long Exit
bool showShortExit2Line; // Show 2st Short Exit
};
//
// Index of Lines ...
enum ENUM_XCHE_BUFFERS
{
//
// Main Requirements ...
XCHE_1ST_LONG_EXIT_LINE = 0,
XCHE_1ST_SHORT_EXIT_LINE = 1,
XCHE_2ND_LONG_EXIT_LINE = 2,
XCHE_2ND_SHORT_EXIT_LINE = 3,
};
//
// Retrieve Info Model ...
struct XCHEInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double longExit1;
double longExit2;
double shortExit1;
double shortExit2;
//
// Conditions ...
//
bool isLongExit1Start;
bool isShortExit1Start;
//
bool isLongExit2Start;
bool isShortExit2Start;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXCHEHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double longExit1Buffer[];
double shortExit1Buffer[];
double longExit2Buffer[];
double shortExit2Buffer[];
//
// Constructor ...
void XSCXCHEHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXCHEHelper()
{
}
//
// START Properties ...
//
//
// Show 1st Long Exit ...
bool ShowLongExit1Line(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowLongExit1Line == show)
{
return true;
}
//
mShowLongExit1Line = show;
result = Init();
//
return result;
}
//
// Show 1st Short Exit ...
bool ShowShortExit1Line(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowShortExit1Line == show)
{
return true;
}
//
mShowShortExit1Line = show;
result = Init();
//
return result;
}
//
// Show 2st Long Exit ...
bool ShowLongExit2Line(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowLongExit2Line == show)
{
return true;
}
//
mShowLongExit2Line = show;
result = Init();
//
return result;
}
//
// Show 2st Short Exit ...
bool ShowShortExit2Line(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowShortExit1Line == show)
{
return true;
}
//
mShowShortExit1Line = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XCHE" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = MathMax(mLength, mLoopback);
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Inputs ...
//
//
result =
mLength >= 9 &&
mLoopback >= 0;
if (!result)
{
return result;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xche",
//
// Inputs ...
//
// Market ...
"",
//
// Length ...
mLength,
//
// Loopback ...
mLoopback,
//
// 1st Multiplier ...
mMultiplier1,
//
// 2nd Multiplier ...
mMultiplier2,
//
// Calculation ...
"",
//
// Up Zone Applied to ...
mUpAppliedTo,
//
// Down Zone Applied to ...
mDownAppliedTo,
//
// Presentation ...
"",
//
// Show 1st Long Exit ...
mShowLongExit1Line,
//
// Show 1st Short Exit ...
mShowShortExit1Line,
//
// Show 2st Long Exit ...
mShowLongExit2Line,
//
// Show 2st Short Exit ...
mShowShortExit2Line
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XCHEInputs GetConfig()
{
//
XCHEInputs result;
//
result.length = mLength;
result.loopback = mLoopback;
result.multiplier1 = mMultiplier1;
result.multiplier2 = mMultiplier2;
result.upAppliedTo = mUpAppliedTo;
result.downAppliedTo = mDownAppliedTo;
result.showLongExit1Line = mShowLongExit1Line;
result.showShortExit1Line = mShowShortExit1Line;
result.showLongExit2Line = mShowLongExit2Line;
result.showShortExit2Line = mShowShortExit2Line;
//
return result;
}
//
// Set Config ...
bool SetConfig(XCHEInputs &config)
{
//
bool result = false;
//
mLength = config.length;
mLoopback = config.loopback;
mMultiplier1 = config.multiplier1;
mMultiplier2 = config.multiplier2;
mUpAppliedTo = config.upAppliedTo;
mDownAppliedTo = config.downAppliedTo;
mShowLongExit1Line = config.showLongExit1Line;
mShowShortExit1Line = config.showShortExit1Line;
mShowLongExit2Line = config.showLongExit2Line;
mShowShortExit2Line = config.showShortExit2Line;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// LEVEL 1 ..
//
// LONG Exit ...
ArraySetAsSeries(longExit1Buffer, true);
CopyBuffer(
mHandler,
XCHE_1ST_LONG_EXIT_LINE,
barIndex,
mLoopbackBars,
longExit1Buffer);
//
// SHORT Exit ...
ArraySetAsSeries(shortExit1Buffer, true);
CopyBuffer(
mHandler,
XCHE_1ST_SHORT_EXIT_LINE,
barIndex,
mLoopbackBars,
shortExit1Buffer);
//
// LEVEL 2 ..
//
// LONG Exit ...
ArraySetAsSeries(longExit2Buffer, true);
CopyBuffer(
mHandler,
XCHE_2ND_LONG_EXIT_LINE,
barIndex,
mLoopbackBars,
longExit2Buffer);
//
// SHORT Exit ...
ArraySetAsSeries(shortExit2Buffer, true);
CopyBuffer(
mHandler,
XCHE_2ND_SHORT_EXIT_LINE,
barIndex,
mLoopbackBars,
shortExit2Buffer);
}
//
// Retrieve Info at Specific Bar Index ...
XCHEInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XCHEInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double longExit1 = longExit1Buffer[barIndex];
double longExit1Prev = longExit1Buffer[barIndex + 1];
double shortExit1 = shortExit1Buffer[barIndex];
double shortExit1Prev = shortExit1Buffer[barIndex + 1];
//
double longExit2 = longExit2Buffer[barIndex];
double longExit2Prev = longExit2Buffer[barIndex + 1];
double shortExit2 = shortExit2Buffer[barIndex];
double shortExit2Prev = shortExit2Buffer[barIndex + 1];
//
result.longExit1 = longExit1;
result.shortExit1 = shortExit1;
result.longExit2 = longExit2;
result.shortExit2 = shortExit2;
//
result.isLongExit1Start =
longExit1 != EMPTY_VALUE &&
longExit1Prev == EMPTY_VALUE;
//
result.isShortExit1Start =
shortExit1 != EMPTY_VALUE &&
shortExit1Prev == EMPTY_VALUE;
//
result.isLongExit2Start =
longExit2 != EMPTY_VALUE &&
longExit2Prev == EMPTY_VALUE;
//
result.isShortExit2Start =
shortExit2 != EMPTY_VALUE &&
shortExit2Prev == EMPTY_VALUE;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Length ...
int mLength;
//
// Loopback ...
int mLoopback;
//
// 1st Multiplier ...
double mMultiplier1;
//
// 2nd Multiplier ...
double mMultiplier2;
//
// Calculation ...
//
// Up Zone Applied to ...
ENUM_APPLIED_PRICE mUpAppliedTo;
//
// Down Zone Applied to ...
ENUM_APPLIED_PRICE mDownAppliedTo;
//
// Presentation ...
//
// Show 1st Long Exit ...
bool mShowLongExit1Line;
//
// Show 1st Short Exit ...
bool mShowShortExit1Line;
//
// Show 2st Long Exit ...
bool mShowLongExit2Line;
//
// Show 2st Short Exit ...
bool mShowShortExit2Line;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,248 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXCTHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
struct XCTInputs
{
//
color clr;
ENUM_BASE_CORNER corner;
//
// Presentation ...
bool showCandleTime; // Show Candle Time
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXCTHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Constructor ...
void XSCXCTHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXCTHelper()
{
}
//
// START Properties ...
//
//
// Show Candles ...
bool ShowCandleTime(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowCandleTime == show)
{
return true;
}
//
mShowCandleTime = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XCT" + GetTagPrefix();
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = 1;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xct",
//
// Inputs ...
mClr,
mCorner,
//
// Presentation ...
"",
mShowCandleTime
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XCTInputs GetConfig()
{
//
XCTInputs result;
//
result.clr = mClr;
result.corner = mCorner;
result.showCandleTime = mShowCandleTime;
//
return result;
}
//
// Set Config ...
bool SetConfig(XCTInputs &config)
{
//
bool result = false;
//
mClr = config.clr;
mCorner = config.corner;
mShowCandleTime = config.showCandleTime;
//
result = Init();
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Text Color ...
color mClr;
//
// Text Position ...
ENUM_BASE_CORNER mCorner;
//
// Presentation ...
//
// Show Candles ...
bool mShowCandleTime;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,427 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXHKHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XHKInputs
{
//
// Presentation ...
bool drawCandles; // Draw Hiken Ashi Candle
bool drawCandleLines; // Show HikenAshi Lines
};
//
// Index of Lines ...
enum ENUM_XHK_BUFFERS
{
//
// Main Requirements ...
XHK_OPEN_LINE = 0,
XHK_HIGH_LINE = 1,
XHK_LOW_LINE = 2,
XHK_CLOSE_LINE = 3,
};
//
// Retrieve Info Model ...
struct XHKInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double open;
double high;
double low;
double close;
//
// Conditions ...
//
// Detect Candle is Bullish or not ...
bool isBullish;
//
// Detect Candle is Bearish or not ...
bool isBearish;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXHKHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double openBuffer[];
double highBuffer[];
double lowBuffer[];
double closeBuffer[];
//
// Constructor ...
void XSCXHKHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
//
// Indicator Properties ...
//
// Presentation ...
//
// Draw Hiken Ashi Candle ...
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXHKHelper()
{
}
//
// START Properties ...
//
//
// Draw Candles ...
bool DrawCandles(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mDrawCandles == show)
{
return true;
}
//
mDrawCandles = show;
result = Init();
//
return result;
}
//
// Show HikenAshi Lines ...
bool DrawCandleLines(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mDrawCandleLines == show)
{
return true;
}
//
mDrawCandleLines = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XHK" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = 2;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xhk",
//
// Inputs ...
//
// Presentation ...
"",
//
// Draw Hiken Ashi Candle ...
mDrawCandles,
//
// Show HikenAshi Lines ...
mDrawCandleLines
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XHKInputs GetConfig()
{
//
XHKInputs result;
//
result.drawCandles = mDrawCandles;
result.drawCandleLines = mDrawCandleLines;
//
return result;
}
//
// Set Config ...
bool SetConfig(XHKInputs &config)
{
//
bool result = false;
//
mDrawCandles = config.drawCandles;
mDrawCandleLines = config.drawCandleLines;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// OPEN ...
ArraySetAsSeries(openBuffer, true);
CopyBuffer(
mHandler,
XHK_OPEN_LINE,
barIndex,
mLoopbackBars,
openBuffer);
//
// HIGH ...
ArraySetAsSeries(highBuffer, true);
CopyBuffer(
mHandler,
XHK_HIGH_LINE,
barIndex,
mLoopbackBars,
highBuffer);
//
// LOW ...
ArraySetAsSeries(lowBuffer, true);
CopyBuffer(
mHandler,
XHK_LOW_LINE,
barIndex,
mLoopbackBars,
lowBuffer);
//
// CLOSE ...
ArraySetAsSeries(closeBuffer, true);
CopyBuffer(
mHandler,
XHK_CLOSE_LINE,
barIndex,
mLoopbackBars,
closeBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XHKInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XHKInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double open = openBuffer[barIndex];
double high = highBuffer[barIndex];
double low = lowBuffer[barIndex];
double close = closeBuffer[barIndex];
//
result.open = open;
result.high = high;
result.low = low;
result.close = close;
//
result.isBullish = open < close;
result.isBearish = open >= close;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Presentation ...
//
// Draw Hiken Ashi Candle ...
bool mDrawCandles;
//
// Show HikenAshi Lines ...
bool mDrawCandleLines;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,530 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXHULLHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XHULLInputs
{
//
// Market ...
int length; // Length
double divisor; // Divisor (Speed)
//
// Calculation ...
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied to
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied to
//
// Presentation ...
bool showUpZone; // Show Up Zone
bool showDownZone; // Show Down Zone
};
//
// Index of Lines ...
enum ENUM_XHULL_BUFFERS
{
//
// Main Requirements ...
XHULL_UP_ZONE_LINE = 0,
XHULL_UP_ZONE_STATE_LINE = 1,
XHULL_DOWN_ZONE_LINE = 2,
XHULL_DOWN_ZONE_STATE_LINE = 3,
};
//
// Hull States ...
enum XHULL_ZONE_STATES
{
XHULL_STATE_NEUTURAL = 0,
XHULL_STATE_BULLISH = 1,
XHULL_STATE_BEARISH = 2
};
//
// Retrieve Info Model ...
struct XHULLInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double up;
XHULL_ZONE_STATES upState;
double down;
XHULL_ZONE_STATES downState;
//
// Conditions ...
//
bool isUpBullish;
bool isUpNeutural;
bool isUpBearish;
//
bool isUpSwitchedToBullish;
bool isUpSwitchedToBearish;
bool isUpSwitchedToNeutural;
//
bool isDownBullish;
bool isDownBearish;
bool isDownNeutural;
//
bool isDownSwitchedToBullish;
bool isDownSwitchedToBearish;
bool isDownSwitchedToNeutural;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXHULLHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double upBuffer[];
double upStateBuffer[];
double downBuffer[];
double downStateBuffer[];
//
// Constructor ...
void XSCXHULLHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXHULLHelper()
{
}
//
// START Properties ...
//
//
// Show Up Zone ...
bool ShowUpZone(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowUpZone == show)
{
return true;
}
//
mShowUpZone = show;
result = Init();
//
return result;
}
//
// Show Down Zone ...
bool ShowDownZone(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowDownZone == show)
{
return true;
}
//
mShowDownZone = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XHULL" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = mLength;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Inputs ...
//
result =
mLength >= 9 &&
mDivisor >= 0.5;
if (!result)
{
return result;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xhull",
//
// Inputs ...
//
// Market ...
"",
//
// Length ...
mLength,
//
// Divisor (Speed) ...
mDivisor,
//
// Calculation ...
"",
//
// Up Zone Applied to ...
mUpAppliedTo,
//
// Down Zone Applied to ...
mDownAppliedTo,
//
// Presentation ...
"",
//
// Show Up Zone ...
mShowUpZone,
//
// Show Down Zone ...
mShowDownZone
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XHULLInputs GetConfig()
{
//
XHULLInputs result;
//
result.length = mLength;
result.divisor = mDivisor;
result.upAppliedTo = mUpAppliedTo;
result.downAppliedTo = mDownAppliedTo;
result.showUpZone = mShowUpZone;
result.showDownZone = mShowDownZone;
//
return result;
}
//
// Set Config ...
bool SetConfig(XHULLInputs &config)
{
//
bool result = false;
//
mLength = config.length;
mDivisor = config.divisor;
mUpAppliedTo = config.upAppliedTo;
mDownAppliedTo = config.downAppliedTo;
mShowUpZone = config.showUpZone;
mShowDownZone = config.showDownZone;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// UP ...
ArraySetAsSeries(upBuffer, true);
CopyBuffer(
mHandler,
XHULL_UP_ZONE_LINE,
barIndex,
mLoopbackBars,
upBuffer);
//
// UP State ...
ArraySetAsSeries(upStateBuffer, true);
CopyBuffer(
mHandler,
XHULL_UP_ZONE_STATE_LINE,
barIndex,
mLoopbackBars,
upStateBuffer);
//
// DOWN ...
ArraySetAsSeries(downBuffer, true);
CopyBuffer(
mHandler,
XHULL_DOWN_ZONE_LINE,
barIndex,
mLoopbackBars,
downBuffer);
//
// DOWN State ...
ArraySetAsSeries(downStateBuffer, true);
CopyBuffer(
mHandler,
XHULL_DOWN_ZONE_STATE_LINE,
barIndex,
mLoopbackBars,
downStateBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XHULLInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XHULLInfo result;
//
if (barIndex < 0)
{
return result;
}
//
// Do Calculations ...
Calculate(barIndex);
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double up = upBuffer[barIndex];
XHULL_ZONE_STATES upState = (XHULL_ZONE_STATES)upStateBuffer[barIndex];
XHULL_ZONE_STATES upStatePrev = (XHULL_ZONE_STATES)upStateBuffer[barIndex + 1];
//
double down = downBuffer[barIndex];
XHULL_ZONE_STATES downState = (XHULL_ZONE_STATES)downStateBuffer[barIndex];
XHULL_ZONE_STATES downStatePrev = (XHULL_ZONE_STATES)downStateBuffer[barIndex + 1];
//
result.up = up;
result.upState = upState;
result.down = down;
result.downState = downState;
//
result.isUpBullish = upState = XHULL_STATE_BULLISH;
result.isUpBearish = upState = XHULL_STATE_BEARISH;
result.isUpNeutural = upState = XHULL_STATE_NEUTURAL;
//
result.isUpSwitchedToBullish = upState == XHULL_STATE_BULLISH &&
upStatePrev != XHULL_STATE_BULLISH;
result.isUpSwitchedToBearish = upState == XHULL_STATE_BEARISH &&
upStatePrev != XHULL_STATE_BEARISH;
result.isUpSwitchedToNeutural = upState == XHULL_STATE_NEUTURAL &&
upStatePrev != XHULL_STATE_NEUTURAL;
//
result.isDownBullish = downState = XHULL_STATE_BULLISH;
result.isDownBearish = downState = XHULL_STATE_BEARISH;
result.isDownNeutural = downState = XHULL_STATE_NEUTURAL;
//
result.isDownSwitchedToBullish = downState == XHULL_STATE_BULLISH &&
downStatePrev != XHULL_STATE_BULLISH;
result.isDownSwitchedToBearish = downState == XHULL_STATE_BEARISH &&
downStatePrev != XHULL_STATE_BEARISH;
result.isDownSwitchedToNeutural = downState == XHULL_STATE_NEUTURAL &&
downStatePrev != XHULL_STATE_NEUTURAL;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Length ...
int mLength;
//
// Divisor (Speed) ...
double mDivisor;
//
// Calculation ...
//
// Up Zone Applied to ...
ENUM_APPLIED_PRICE mUpAppliedTo;
//
// Down Zone Applied to ...
ENUM_APPLIED_PRICE mDownAppliedTo;
//
// Presentation ...
//
// Show Up Zone ...
bool mShowUpZone;
//
// Show Down Zone ...
bool mShowDownZone;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,965 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXICHHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
//
// Global Properties ...
#property library
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
#property strict
//
// START Definitions ...
//
//
// Ichimoku Lines Calculator Mode ...
enum ENUM_X_ICHIMOKU_CALCULATION_MODE
{
//
X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low
X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close
};
//
// Inputs ...
struct XICHInputs
{
//
// TENKANSEN ...
// Tenkan Sen ...
int tenkanSenLength; // Length
ENUM_X_ICHIMOKU_CALCULATION_MODE tenkanSenMode; // Calculation Mode
//
// KIJUNSEN ...
// Kijun Sen ...
int kijunSenLength; // Length
ENUM_X_ICHIMOKU_CALCULATION_MODE kijunSenMode; // Calculation Mode
//
// SENKOUSPANB ...
// Senkou Span B ...
int senkouSpanBLength; // Length
ENUM_X_ICHIMOKU_CALCULATION_MODE senkouSpanBMode; // Calculation Mode
//
// CHIKOUSPAN ...
// Chikou Span ...
ENUM_APPLIED_PRICE chikuoSpanAppliedTo; // Price Type
//
// Presentation ...
bool showTenkanSen; // Show Tenkan Sen
bool showKijunSen; // Show Kijun Sen
bool showKijunSenPlus; // Show Kijun Sen +
bool showKijunSenNegative; // Show Kijun Sen -
bool showChikouSpan; // Show Chikou Span
bool showSenkouSpanA; // Show Senkou Span A
bool showSenkouSpanB; // Show Senkou Span B
bool showKumo; // Show Kumo
bool shiftKumo; // Shift Kumo to Future
};
//
// Index of Lines ...
enum ENUM_XICH_BUFFERS
{
//
// Main Requirements ...
XICH_TEANKANSEN_LINE = 0,
XICH_KIJUNSEN_LINE = 1,
XICH_CHIKOUSPAN_LINE = 4,
XICH_SENKOUSPANA_LINE = 5,
XICH_SENKOUSPANB_LINE = 6,
};
//
// Retrieve Info Model ...
struct XICHInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double tenkanSen;
double kijunSen;
double chikouSpan;
double senkouSpanA;
double senkouSpanB;
double senkouSpanAFuture;
double senkouSpanBFuture;
//
// Conditions ...
//
bool isTenkanSenOverKijunSen;
bool isTenkanSenUnderKijunSen;
bool isTenkanSenCrossedOverKijunSen;
bool isTenkanSenCrossedUnderKijunSen;
//
bool isKumoBullish;
bool isKumoBearish;
bool isFutureKumoBullish;
bool isFutureKumoBearish;
bool isKumoSwitchedToBullish;
bool isKumoSwitchedToBearish;
bool isFutureKumoSwitchedToBullish;
bool isFutureKumoSwitchedToBearish;
//
bool isTenkanSenOverSenkouSpanA;
bool isTenkanSenUnderSenkouSpanA;
bool isTenkanSenOverFutureSenkouSpanA;
bool isTenkanSenUnderFutureSenkouSpanA;
bool isTenkanSenCrossedOverSenkouSpanA;
bool isTenkanSenCrossedUnderSenkouSpanA;
bool isTenkanSenCrossedOverFutureSenkouSpanA;
bool isTenkanSenCrossedUnderFutureSenkouSpanA;
//
bool isTenkanSenOverSenkouSpanB;
bool isTenkanSenUnderSenkouSpanB;
bool isTenkanSenOverFutureSenkouSpanB;
bool isTenkanSenUnderFutureSenkouSpanB;
bool isTenkanSenCrossedOverSenkouSpanB;
bool isTenkanSenCrossedUnderSenkouSpanB;
bool isTenkanSenCrossedOverFutureSenkouSpanB;
bool isTenkanSenCrossedUnderFutureSenkouSpanB;
//
bool isKijunSenOverSenkouSpanA;
bool isKijunSenUnderSenkouSpanA;
bool isKijunSenOverFutureSenkouSpanA;
bool isKijunSenUnderFutureSenkouSpanA;
bool isKijunSenCrossedOverSenkouSpanA;
bool isKijunSenCrossedUnderSenkouSpanA;
bool isKijunSenCrossedOverFutureSenkouSpanA;
bool isKijunSenCrossedUnderFutureSenkouSpanA;
//
bool isKijunSenOverSenkouSpanB;
bool isKijunSenUnderSenkouSpanB;
bool isKijunSenOverFutureSenkouSpanB;
bool isKijunSenUnderFutureSenkouSpanB;
bool isKijunSenCrossedOverSenkouSpanB;
bool isKijunSenCrossedUnderSenkouSpanB;
bool isKijunSenCrossedOverFutureSenkouSpanB;
bool isKijunSenCrossedUnderFutureSenkouSpanB;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXICHHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double tenkanSenBuffer[];
double kijunSenBuffer[];
double chikouSpanBuffer[];
double senkouSpanABuffer[];
double senkouSpanBBuffer[];
//
// Constructor ...
void XSCXICHHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXICHHelper()
{
}
//
// START Properties ...
//
//
// Show Tenkan Sen ...
bool ShowTenkanSen(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowTenkanSen == show)
{
return true;
}
//
mShowTenkanSen = show;
result = Init();
//
return result;
}
//
// Show Kijun Sen ...
bool ShowKijunSen(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowKijunSen == show)
{
return true;
}
//
mShowKijunSen = show;
result = Init();
//
return result;
}
//
// Show Chikou Span ...
bool ShowChikouSpan(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowChikouSpan == show)
{
return true;
}
//
mShowChikouSpan = show;
result = Init();
//
return result;
}
//
// Show Senkou Span A ...
bool ShowSenkouSpanA(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowSenkouSpanA == show)
{
return true;
}
//
mShowSenkouSpanA = show;
result = Init();
//
return result;
}
//
// Show Senkou Span B ...
bool ShowSenkouSpanB(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowSenkouSpanB == show)
{
return true;
}
//
mShowSenkouSpanB = show;
result = Init();
//
return result;
}
//
// Show Kumo ...
bool ShowKumo(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowKumo == show)
{
return true;
}
//
mShowKumo = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XICH" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = MathMax(result, mTenkanSenLength);
result = MathMax(result, mKijunSenLength);
result = MathMax(result, mSenkouSpanBLength);
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Inputs ...
//
result =
(mTenkanSenLength > 2 &&
mKijunSenLength > mTenkanSenLength &&
mSenkouSpanBLength > mKijunSenLength);
if (!result)
{
return result;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xich",
//
// Inputs ...
//
// TENKANSEN ...
"",
//
// Length ...
mTenkanSenLength,
//
// Calculation Mode ...
mTenkanSenMode,
//
// KIJUNSEN ...
"",
//
// Length ...
mKijunSenLength,
//
// Calculation Mode ...
mKijunSenMode,
//
// SENKOUSPANA ...
"",
//
// Length ...
mSenkouSpanBLength,
//
// Calculation Mode ...
mSenkouSpanBMode,
//
// CHIKOUSPAN ...
"",
//
// Price Type ...
mChikuoSpanAppliedTo,
//
// PRESENTATION ...
"",
//
// Show Tenkan Sen ...
mShowTenkanSen,
//
// Show Kijun Sen ...
mShowKijunSen,
//
// Show Kijun Sen + ...
mShowKijunSenPlus,
//
// Show Kijun Sen - ...
mShowKijunSenNegative,
//
// Show Chikou Span ...
mShowChikouSpan,
//
// Show Senkou Span A ...
mShowSenkouSpanA,
//
// Show Senkou Span B ...
mShowSenkouSpanB,
//
// Show Kumo ...
mShowKumo,
//
// Shift Kumo to Future ...
mShiftKumo
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XICHInputs GetConfig()
{
//
XICHInputs result;
//
result.tenkanSenLength = mTenkanSenLength;
result.tenkanSenMode = mTenkanSenMode;
result.kijunSenLength = mKijunSenLength;
result.kijunSenMode = mKijunSenMode;
result.senkouSpanBLength = mSenkouSpanBLength;
result.senkouSpanBMode = mSenkouSpanBMode;
result.chikuoSpanAppliedTo = mChikuoSpanAppliedTo;
result.showTenkanSen = mShowTenkanSen;
result.showKijunSen = mShowKijunSen;
result.showKijunSenPlus = mShowKijunSenPlus;
result.showKijunSenNegative = mShowKijunSenNegative;
result.showChikouSpan = mShowChikouSpan;
result.showSenkouSpanA = mShowSenkouSpanA;
result.showSenkouSpanB = mShowSenkouSpanB;
result.showKumo = mShowKumo;
result.shiftKumo = mShiftKumo;
//
return result;
}
//
// Set Config ...
bool SetConfig(XICHInputs &config)
{
//
bool result = false;
//
mTenkanSenLength = config.tenkanSenLength;
mTenkanSenMode = config.tenkanSenMode;
mKijunSenLength = config.kijunSenLength;
mKijunSenMode = config.kijunSenMode;
mSenkouSpanBLength = config.senkouSpanBLength;
mSenkouSpanBMode = config.senkouSpanBMode;
mChikuoSpanAppliedTo = config.chikuoSpanAppliedTo;
mShowTenkanSen = config.showTenkanSen;
mShowKijunSen = config.showKijunSen;
mShowKijunSenPlus = config.showKijunSenPlus;
mShowKijunSenNegative = config.showKijunSenNegative;
mShowChikouSpan = config.showChikouSpan;
mShowSenkouSpanA = config.showSenkouSpanA;
mShowSenkouSpanB = config.showSenkouSpanB;
mShowKumo = config.showKumo;
mShiftKumo = config.shiftKumo;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// Since Ichimoku Has Some Issues ...
mLoopbackBars = 52;
//
// TENKANSEN ...
ArraySetAsSeries(tenkanSenBuffer, true);
CopyBuffer(
mHandler,
XICH_TEANKANSEN_LINE,
barIndex,
mLoopbackBars,
tenkanSenBuffer);
//
// KIJUNSEN ...
ArraySetAsSeries(kijunSenBuffer, true);
CopyBuffer(
mHandler,
XICH_KIJUNSEN_LINE,
barIndex,
mLoopbackBars,
kijunSenBuffer);
//
// CHIKOUSPAN ...
ArraySetAsSeries(chikouSpanBuffer, true);
CopyBuffer(
mHandler,
XICH_CHIKOUSPAN_LINE,
barIndex + mKijunSenLength + 1,
mLoopbackBars,
chikouSpanBuffer);
//
// SENKOUSPANA ...
ArraySetAsSeries(senkouSpanABuffer, true);
CopyBuffer(
mHandler,
XICH_SENKOUSPANA_LINE,
-1 * (barIndex + mKijunSenLength),
mLoopbackBars,
senkouSpanABuffer);
//
// SENKOUSPANB ...
ArraySetAsSeries(senkouSpanBBuffer, true);
CopyBuffer(
mHandler,
XICH_SENKOUSPANB_LINE,
-1 * (barIndex + mKijunSenLength),
mLoopbackBars,
senkouSpanBBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XICHInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XICHInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double tenkanSen = tenkanSenBuffer[barIndex];
double tenkanSenPrev = tenkanSenBuffer[barIndex + 1];
//
double kijunSen = kijunSenBuffer[barIndex];
double kijunSenPrev = kijunSenBuffer[barIndex + 1];
//
double chikouSpan = chikouSpanBuffer[barIndex + mKijunSenLength];
double chikouSpanPrev = chikouSpanBuffer[barIndex + mKijunSenLength + 1];
//
double senkouSpanA = senkouSpanABuffer[barIndex + mKijunSenLength];
double senkouSpanAPrev = senkouSpanABuffer[barIndex + mKijunSenLength + 1];
//
double senkouSpanB = senkouSpanBBuffer[barIndex + mKijunSenLength];
double senkouSpanBPrev = senkouSpanBBuffer[barIndex + mKijunSenLength + 1];
//
double senkouSpanAFuture = senkouSpanABuffer[barIndex];
double senkouSpanAFuturePrev = senkouSpanABuffer[barIndex + 1];
//
double senkouSpanBFuture = senkouSpanBBuffer[barIndex];
double senkouSpanBFuturePrev = senkouSpanBBuffer[barIndex + 1];
//
bool isTenkanSenOverKijunSen =
tenkanSen > kijunSen;
bool isTenkanSenUnderKijunSen =
tenkanSen < kijunSen;
bool isTenkanSenCrossedOverKijunSen =
tenkanSen > kijunSen &&
tenkanSenPrev <= kijunSenPrev;
bool isTenkanSenCrossedUnderKijunSen =
tenkanSen < kijunSen &&
tenkanSenPrev >= kijunSenPrev;
//
bool isKumoBullish =
senkouSpanA > senkouSpanB;
bool isKumoBearish =
senkouSpanA < senkouSpanB;
bool isFutureKumoBullish =
senkouSpanAFuture > senkouSpanBFuture;
bool isFutureKumoBearish =
senkouSpanAFuture < senkouSpanBFuture;
bool isKumoSwitchedToBullish =
senkouSpanA > senkouSpanB &&
senkouSpanAPrev <= senkouSpanBPrev;
bool isKumoSwitchedToBearish =
senkouSpanA < senkouSpanB &&
senkouSpanAPrev >= senkouSpanBPrev;
bool isFutureKumoSwitchedToBullish =
senkouSpanAFuture > senkouSpanBFuture &&
senkouSpanAFuturePrev <= senkouSpanBFuturePrev;
bool isFutureKumoSwitchedToBearish =
senkouSpanAFuture < senkouSpanBFuture &&
senkouSpanAFuturePrev >= senkouSpanBFuturePrev;
//
bool isTenkanSenOverSenkouSpanA =
tenkanSen > senkouSpanA;
bool isTenkanSenUnderSenkouSpanA =
tenkanSen < senkouSpanA;
bool isTenkanSenOverFutureSenkouSpanA =
tenkanSen > senkouSpanAFuture;
bool isTenkanSenUnderFutureSenkouSpanA =
tenkanSen < senkouSpanAFuture;
bool isTenkanSenCrossedOverSenkouSpanA =
tenkanSen > senkouSpanA &&
tenkanSenPrev <= senkouSpanAPrev;
bool isTenkanSenCrossedUnderSenkouSpanA =
tenkanSen < senkouSpanA &&
tenkanSenPrev >= senkouSpanAPrev;
bool isTenkanSenCrossedOverFutureSenkouSpanA =
tenkanSen > senkouSpanAFuture &&
tenkanSenPrev <= senkouSpanAFuturePrev;
bool isTenkanSenCrossedUnderFutureSenkouSpanA =
tenkanSen < senkouSpanAFuture &&
tenkanSenPrev >= senkouSpanAFuturePrev;
//
bool isTenkanSenOverSenkouSpanB =
tenkanSen > senkouSpanB;
bool isTenkanSenUnderSenkouSpanB =
tenkanSen < senkouSpanB;
bool isTenkanSenOverFutureSenkouSpanB =
tenkanSen > senkouSpanBFuture;
bool isTenkanSenUnderFutureSenkouSpanB =
tenkanSen < senkouSpanBFuture;
bool isTenkanSenCrossedOverSenkouSpanB =
tenkanSen > senkouSpanB &&
tenkanSenPrev <= senkouSpanBPrev;
bool isTenkanSenCrossedUnderSenkouSpanB =
tenkanSen < senkouSpanB &&
tenkanSenPrev >= senkouSpanBPrev;
bool isTenkanSenCrossedOverFutureSenkouSpanB =
tenkanSen > senkouSpanBFuture &&
tenkanSenPrev <= senkouSpanBFuturePrev;
bool isTenkanSenCrossedUnderFutureSenkouSpanB =
tenkanSen < senkouSpanBFuture &&
tenkanSenPrev >= senkouSpanBFuturePrev;
//
bool isKijunSenOverSenkouSpanA =
kijunSen > senkouSpanA;
bool isKijunSenUnderSenkouSpanA =
kijunSen < senkouSpanA;
bool isKijunSenOverFutureSenkouSpanA =
kijunSen > senkouSpanAFuture;
bool isKijunSenUnderFutureSenkouSpanA =
kijunSen < senkouSpanAFuture;
bool isKijunSenCrossedOverSenkouSpanA =
kijunSen > senkouSpanA &&
kijunSenPrev <= senkouSpanAPrev;
bool isKijunSenCrossedUnderSenkouSpanA =
kijunSen < senkouSpanA &&
kijunSenPrev >= senkouSpanAPrev;
bool isKijunSenCrossedOverFutureSenkouSpanA =
kijunSen > senkouSpanAFuture &&
kijunSenPrev <= senkouSpanAFuturePrev;
bool isKijunSenCrossedUnderFutureSenkouSpanA =
kijunSen < senkouSpanAFuture &&
kijunSenPrev >= senkouSpanAFuturePrev;
//
bool isKijunSenOverSenkouSpanB =
kijunSen > senkouSpanB;
bool isKijunSenUnderSenkouSpanB =
kijunSen < senkouSpanB;
bool isKijunSenOverFutureSenkouSpanB =
kijunSen > senkouSpanBFuture;
bool isKijunSenUnderFutureSenkouSpanB =
kijunSen < senkouSpanBFuture;
bool isKijunSenCrossedOverSenkouSpanB =
kijunSen > senkouSpanB &&
kijunSenPrev <= senkouSpanB;
bool isKijunSenCrossedUnderSenkouSpanB =
kijunSen < senkouSpanB &&
kijunSenPrev >= senkouSpanB;
bool isKijunSenCrossedOverFutureSenkouSpanB =
kijunSen > senkouSpanBFuture &&
kijunSenPrev <= senkouSpanBFuturePrev;
bool isKijunSenCrossedUnderFutureSenkouSpanB =
kijunSen < senkouSpanBFuture &&
kijunSenPrev >= senkouSpanBFuturePrev;
//
result.tenkanSen = tenkanSen;
result.kijunSen = kijunSen;
result.chikouSpan = chikouSpan;
result.senkouSpanA = senkouSpanA;
result.senkouSpanB = senkouSpanB;
result.senkouSpanAFuture = senkouSpanAFuture;
result.senkouSpanBFuture = senkouSpanBFuture;
//
result.isTenkanSenOverKijunSen = isTenkanSenOverKijunSen;
result.isTenkanSenUnderKijunSen = isTenkanSenUnderKijunSen;
result.isTenkanSenCrossedOverKijunSen = isTenkanSenCrossedOverKijunSen;
result.isTenkanSenCrossedUnderKijunSen = isTenkanSenCrossedUnderKijunSen;
//
result.isKumoBullish = isKumoBullish;
result.isKumoBearish = isKumoBearish;
result.isFutureKumoBullish = isFutureKumoBullish;
result.isFutureKumoBearish = isFutureKumoBearish;
result.isKumoSwitchedToBullish = isKumoSwitchedToBullish;
result.isKumoSwitchedToBearish = isKumoSwitchedToBearish;
result.isFutureKumoSwitchedToBullish = isFutureKumoSwitchedToBullish;
result.isFutureKumoSwitchedToBearish = isFutureKumoSwitchedToBearish;
//
result.isTenkanSenOverSenkouSpanA = isTenkanSenOverSenkouSpanA;
result.isTenkanSenUnderSenkouSpanA = isTenkanSenUnderSenkouSpanA;
result.isTenkanSenOverFutureSenkouSpanA = isTenkanSenOverFutureSenkouSpanA;
result.isTenkanSenUnderFutureSenkouSpanA = isTenkanSenUnderFutureSenkouSpanA;
result.isTenkanSenCrossedOverSenkouSpanA = isTenkanSenCrossedOverSenkouSpanA;
result.isTenkanSenCrossedUnderSenkouSpanA = isTenkanSenCrossedUnderSenkouSpanA;
result.isTenkanSenCrossedOverFutureSenkouSpanA = isTenkanSenCrossedOverFutureSenkouSpanA;
result.isTenkanSenCrossedUnderFutureSenkouSpanA = isTenkanSenCrossedUnderFutureSenkouSpanA;
//
result.isTenkanSenOverSenkouSpanB = isTenkanSenOverSenkouSpanB;
result.isTenkanSenUnderSenkouSpanB = isTenkanSenUnderSenkouSpanB;
result.isTenkanSenOverFutureSenkouSpanB = isTenkanSenOverFutureSenkouSpanB;
result.isTenkanSenUnderFutureSenkouSpanB = isTenkanSenUnderFutureSenkouSpanB;
result.isTenkanSenCrossedOverSenkouSpanB = isTenkanSenCrossedOverSenkouSpanB;
result.isTenkanSenCrossedUnderSenkouSpanB = isTenkanSenCrossedUnderSenkouSpanB;
result.isTenkanSenCrossedOverFutureSenkouSpanB = isTenkanSenCrossedOverFutureSenkouSpanB;
result.isTenkanSenCrossedUnderFutureSenkouSpanB = isTenkanSenCrossedUnderFutureSenkouSpanB;
//
result.isKijunSenOverSenkouSpanA = isKijunSenOverSenkouSpanA;
result.isKijunSenUnderSenkouSpanA = isKijunSenUnderSenkouSpanA;
result.isKijunSenOverFutureSenkouSpanA = isKijunSenOverFutureSenkouSpanA;
result.isKijunSenUnderFutureSenkouSpanA = isKijunSenUnderFutureSenkouSpanA;
result.isKijunSenCrossedOverSenkouSpanA = isKijunSenCrossedOverSenkouSpanA;
result.isKijunSenCrossedUnderSenkouSpanA = isKijunSenCrossedUnderSenkouSpanA;
result.isKijunSenCrossedOverFutureSenkouSpanA = isKijunSenCrossedOverFutureSenkouSpanA;
result.isKijunSenCrossedUnderFutureSenkouSpanA = isKijunSenCrossedUnderFutureSenkouSpanA;
//
result.isKijunSenOverSenkouSpanB = isKijunSenOverSenkouSpanB;
result.isKijunSenUnderSenkouSpanB = isKijunSenUnderSenkouSpanB;
result.isKijunSenOverFutureSenkouSpanB = isKijunSenOverFutureSenkouSpanB;
result.isKijunSenUnderFutureSenkouSpanB = isKijunSenUnderFutureSenkouSpanB;
result.isKijunSenCrossedOverSenkouSpanB = isKijunSenCrossedOverSenkouSpanB;
result.isKijunSenCrossedUnderSenkouSpanB = isKijunSenCrossedUnderSenkouSpanB;
result.isKijunSenCrossedOverFutureSenkouSpanB = isKijunSenCrossedOverFutureSenkouSpanB;
result.isKijunSenCrossedUnderFutureSenkouSpanB = isKijunSenCrossedUnderFutureSenkouSpanB;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// TENKANSEN ...
//
// Length ...
int mTenkanSenLength;
//
// Calculation Mode ...
ENUM_X_ICHIMOKU_CALCULATION_MODE mTenkanSenMode;
//
// KIJUNSEN ...
//
// Length ...
int mKijunSenLength;
//
// Calculation Mode ...
ENUM_X_ICHIMOKU_CALCULATION_MODE mKijunSenMode;
//
// SENKOUSPANB ...
//
// Length ...
int mSenkouSpanBLength;
//
// Calculation Mode ...
ENUM_X_ICHIMOKU_CALCULATION_MODE mSenkouSpanBMode;
//
// CHIKOUSPAN ...
//
// Price Type ...
ENUM_APPLIED_PRICE mChikuoSpanAppliedTo;
//
// Presentation ...
//
// Show Tenkan Sen ...
bool mShowTenkanSen;
//
// Show Kijun Sen ...
bool mShowKijunSen;
//
// Show Kijun Sen + ...
bool mShowKijunSenPlus;
//
// Show Kijun Sen - ...
bool mShowKijunSenNegative;
//
// Show Chikou Span ...
bool mShowChikouSpan;
//
// Show Senkou Span A ...
bool mShowSenkouSpanA;
//
// Show Senkou Span B ...
bool mShowSenkouSpanB;
//
// Show Kumo ...
bool mShowKumo;
//
// Shift Kumo to Future ...
bool mShiftKumo;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,849 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXMRBHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XMRBInputs
{
//
// Ribbon 1 ...
int fast1Length; // Fast
int slow1Length; // Slow
//
// Ribbon 2 ...
int fast2Length; // Fast
int slow2Length; // Slow
//
// Ribbon 3 ...
int fast3Length; // Fast
int slow3Length; // Slow
//
// Ribbon 4 ...
int fast4Length; // Fast
int slow4Length; // Slow
//
// Ribbon 5 ...
int fast5Length; // Fast
int slow5Length; // Slow
//
// Calculation ...
ENUM_MA_METHOD ribbonMode; // Mode
ENUM_APPLIED_PRICE ribbonAppliedTo; // Applied To
//
// Presentation ...
bool showFastMa; // Show Fast
bool showSlowMa; // Show Slow
bool showRibbon; // Show Ribbon
};
//
// Index of Lines ...
enum ENUM_XMRB_BUFFERS
{
//
// Main Requirements ...
XMRB_FAST_LINE = 0,
XMRB_SLOW_LINE = 1,
//
// RIBBON 1 ...
XMRB_R1_FAST_LINE = 2,
XMRB_R1_SLOW_LINE = 3,
//
// RIBBON 2 ...
XMRB_R2_FAST_LINE = 4,
XMRB_R2_SLOW_LINE = 5,
//
// RIBBON 3 ...
XMRB_R3_FAST_LINE = 6,
XMRB_R3_SLOW_LINE = 7,
//
// RIBBON 4 ...
XMRB_R4_FAST_LINE = 8,
XMRB_R4_SLOW_LINE = 9,
//
// RIBBON 5 ...
XMRB_R5_FAST_LINE = 10,
XMRB_R5_SLOW_LINE = 11,
};
//
// Retrieve Info Model ...
struct XMRBInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double fast;
double slow;
double fastR1;
double slowR1;
double fastR2;
double slowR2;
double fastR3;
double slowR3;
double fastR4;
double slowR4;
double fastR5;
double slowR5;
//
// Conditions ...
//
bool isFastOverSlow;
bool isFastCrossedOverSlow;
bool isFastUnderSlow;
bool isFastCrossedUnderSlow;
//
bool isR1FastOverSlow;
bool isR1FastCrossedOverSlow;
bool isR1FastUnderSlow;
bool isR1FastCrossedUnderSlow;
//
bool isR2FastOverSlow;
bool isR2FastCrossedOverSlow;
bool isR2FastUnderSlow;
bool isR2FastCrossedUnderSlow;
//
bool isR3FastOverSlow;
bool isR3FastCrossedOverSlow;
bool isR3FastUnderSlow;
bool isR3FastCrossedUnderSlow;
//
bool isR4FastOverSlow;
bool isR4FastCrossedOverSlow;
bool isR4FastUnderSlow;
bool isR4FastCrossedUnderSlow;
//
bool isR5FastOverSlow;
bool isR5FastCrossedOverSlow;
bool isR5FastUnderSlow;
bool isR5FastCrossedUnderSlow;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXMRBHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double fastBuffer[];
double slowBuffer[];
double fastR1Buffer[];
double slowR1Buffer[];
double fastR2Buffer[];
double slowR2Buffer[];
double fastR3Buffer[];
double slowR3Buffer[];
double fastR4Buffer[];
double slowR4Buffer[];
double fastR5Buffer[];
double slowR5Buffer[];
//
// Constructor ...
void XSCXMRBHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXMRBHelper()
{
}
//
// START Properties ...
//
//
// Show Fast ...
bool ShowFast(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowFastMa == show)
{
return true;
}
//
mShowFastMa = show;
result = Init();
//
return result;
}
//
// Show Slow ...
bool ShowSlow(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowSlowMa == show)
{
return true;
}
//
mShowSlowMa = show;
result = Init();
//
return result;
}
//
// Show Ribbon ...
bool ShowRibbon(
bool show // Show or Hide
)
{
//
bool result = false;
//
if (mShowRibbon == show)
{
return true;
}
//
mShowRibbon = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XMRB" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = MathMax(mFast1Length, mFast2Length);
result = MathMax(result, mFast3Length);
result = MathMax(result, mFast4Length);
result = MathMax(result, mFast5Length);
//
result = MathMax(result, mSlow1Length);
result = MathMax(result, mSlow2Length);
result = MathMax(result, mSlow3Length);
result = MathMax(result, mSlow4Length);
result = MathMax(result, mSlow5Length);
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Inputs ...
result =
//
(mFast1Length > 2 &&
mFast2Length > mFast1Length &&
mFast3Length > mFast2Length &&
mFast4Length > mFast3Length &&
mFast5Length > mFast4Length &&
mSlow1Length > mFast1Length &&
mSlow2Length > mFast2Length &&
mSlow3Length > mFast3Length &&
mSlow4Length > mFast4Length &&
mSlow5Length > mFast5Length &&
mSlow2Length > mSlow1Length &&
mSlow3Length > mSlow2Length &&
mSlow4Length > mSlow3Length &&
mSlow5Length > mSlow4Length
//
)
//
;
if (!result)
{
return result;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xmrb",
//
// Inputs ...
//
// Ribbon 1 ...
"",
mFast1Length,
mSlow1Length,
//
// Ribbon 2 ...
"",
mFast2Length,
mSlow2Length,
//
// Ribbon 3 ...
"",
mFast3Length,
mSlow3Length,
//
// Ribbon 4 ...
"",
mFast4Length,
mSlow4Length,
//
// Ribbon 5 ...
"",
mFast5Length,
mSlow5Length,
//
// Calculation ...
"",
//
// Mode ...
mRibbonMode,
//
// Applied To ...
mRibbonAppliedTo,
//
// Presentation ...
"",
//
// Show Fast ...
mShowFastMa,
//
// Show Slow ...
mShowSlowMa,
//
// Show Ribbon ...
mShowRibbon
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XMRBInputs GetConfig()
{
//
XMRBInputs result;
//
result.fast1Length = mFast1Length;
result.slow1Length = mSlow1Length;
result.fast2Length = mFast2Length;
result.slow2Length = mSlow2Length;
result.fast3Length = mFast3Length;
result.slow3Length = mSlow3Length;
result.fast4Length = mFast4Length;
result.slow4Length = mSlow4Length;
result.fast5Length = mFast5Length;
result.slow5Length = mSlow5Length;
result.ribbonMode = mRibbonMode;
result.ribbonAppliedTo = mRibbonAppliedTo;
result.showFastMa = mShowFastMa;
result.showSlowMa = mShowSlowMa;
result.showRibbon = mShowRibbon;
//
return result;
}
//
// Set Config ...
bool SetConfig(XMRBInputs &config)
{
//
bool result = false;
//
mFast1Length = config.fast1Length;
mSlow1Length = config.slow1Length;
mFast2Length = config.fast2Length;
mSlow2Length = config.slow2Length;
mFast3Length = config.fast3Length;
mSlow3Length = config.slow3Length;
mFast4Length = config.fast4Length;
mSlow4Length = config.slow4Length;
mFast5Length = config.fast5Length;
mSlow5Length = config.slow5Length;
mRibbonMode = config.ribbonMode;
mRibbonAppliedTo = config.ribbonAppliedTo;
mShowFastMa = config.showFastMa;
mShowSlowMa = config.showSlowMa;
mShowRibbon = config.showRibbon;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// FAST ...
ArraySetAsSeries(fastBuffer, true);
CopyBuffer(
mHandler,
XMRB_FAST_LINE,
barIndex,
mLoopbackBars,
fastBuffer);
//
// SLOW ...
ArraySetAsSeries(slowBuffer, true);
CopyBuffer(
mHandler,
XMRB_SLOW_LINE,
barIndex,
mLoopbackBars,
slowBuffer);
//
// RIBBON 1 ...
//
// FAST ...
ArraySetAsSeries(fastR1Buffer, true);
CopyBuffer(
mHandler,
XMRB_R1_FAST_LINE,
barIndex,
mLoopbackBars,
fastR1Buffer);
//
// SLOW ...
ArraySetAsSeries(slowR1Buffer, true);
CopyBuffer(
mHandler,
XMRB_R1_SLOW_LINE,
barIndex,
mLoopbackBars,
slowR1Buffer);
//
// RIBBON 2 ...
//
// FAST ...
ArraySetAsSeries(fastR2Buffer, true);
CopyBuffer(
mHandler,
XMRB_R2_FAST_LINE,
barIndex,
mLoopbackBars,
fastR2Buffer);
//
// SLOW ...
ArraySetAsSeries(slowR2Buffer, true);
CopyBuffer(
mHandler,
XMRB_R2_SLOW_LINE,
barIndex,
mLoopbackBars,
slowR2Buffer);
//
// RIBBON 3 ...
//
// FAST ...
ArraySetAsSeries(fastR3Buffer, true);
CopyBuffer(
mHandler,
XMRB_R3_FAST_LINE,
barIndex,
mLoopbackBars,
fastR3Buffer);
//
// SLOW ...
ArraySetAsSeries(slowR3Buffer, true);
CopyBuffer(
mHandler,
XMRB_R3_SLOW_LINE,
barIndex,
mLoopbackBars,
slowR3Buffer);
//
// RIBBON 4 ...
//
// FAST ...
ArraySetAsSeries(fastR4Buffer, true);
CopyBuffer(
mHandler,
XMRB_R4_FAST_LINE,
barIndex,
mLoopbackBars,
fastR4Buffer);
//
// SLOW ...
ArraySetAsSeries(slowR4Buffer, true);
CopyBuffer(
mHandler,
XMRB_R4_SLOW_LINE,
barIndex,
mLoopbackBars,
slowR4Buffer);
//
// RIBBON 5 ...
//
// FAST ...
ArraySetAsSeries(fastR5Buffer, true);
CopyBuffer(
mHandler,
XMRB_R5_FAST_LINE,
barIndex,
mLoopbackBars,
fastR5Buffer);
//
// SLOW ...
ArraySetAsSeries(slowR5Buffer, true);
CopyBuffer(
mHandler,
XMRB_R5_SLOW_LINE,
barIndex,
mLoopbackBars,
slowR5Buffer);
}
//
// Retrieve Info at Specific Bar Index ...
XMRBInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XMRBInfo result;
//
if (barIndex < 0)
{
return result;
}
//
// Do Calculations ...
Calculate(barIndex);
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double fast = fastBuffer[barIndex];
double fastPrev = fastBuffer[barIndex + 1];
double slow = slowBuffer[barIndex];
double slowPrev = slowBuffer[barIndex + 1];
double fastR1 = fastR1Buffer[barIndex];
double fastR1Prev = fastR1Buffer[barIndex + 1];
double slowR1 = slowR1Buffer[barIndex];
double slowR1Prev = slowR1Buffer[barIndex + 1];
double fastR2 = fastR2Buffer[barIndex];
double fastR2Prev = fastR2Buffer[barIndex + 1];
double slowR2 = slowR2Buffer[barIndex];
double slowR2Prev = slowR2Buffer[barIndex + 1];
double fastR3 = fastR3Buffer[barIndex];
double fastR3Prev = fastR3Buffer[barIndex + 1];
double slowR3 = slowR3Buffer[barIndex];
double slowR3Prev = slowR3Buffer[barIndex + 1];
double fastR4 = fastR4Buffer[barIndex];
double fastR4Prev = fastR4Buffer[barIndex + 1];
double slowR4 = slowR4Buffer[barIndex];
double slowR4Prev = slowR4Buffer[barIndex + 1];
double fastR5 = fastR5Buffer[barIndex];
double fastR5Prev = fastR5Buffer[barIndex + 1];
double slowR5 = slowR5Buffer[barIndex];
double slowR5Prev = slowR5Buffer[barIndex + 1];
//
result.fast = fast;
result.slow = slow;
result.fastR1 = fastR1;
result.slowR1 = slowR1;
result.fastR2 = fastR2;
result.slowR2 = slowR2;
result.fastR3 = fastR3;
result.slowR3 = slowR3;
result.fastR4 = fastR4;
result.slowR4 = slowR4;
result.fastR5 = fastR5;
result.slowR5 = slowR5;
//
result.isFastOverSlow =
fast > slow;
result.isFastCrossedOverSlow =
fast > slow && fastPrev <= slowPrev;
result.isFastUnderSlow =
fast < slow;
result.isFastCrossedUnderSlow =
fast < slow && fastPrev >= slowPrev;
//
result.isR1FastOverSlow =
fastR1 > slowR1;
result.isR1FastCrossedOverSlow =
fastR1 > slowR1 && fastR1Prev <= slowR1Prev;
result.isR1FastUnderSlow =
fastR1 < slowR1;
result.isR1FastCrossedUnderSlow =
fastR1 < slowR1 && fastR1Prev >= slowR1Prev;
//
result.isR2FastOverSlow =
fastR2 > slowR2;
result.isR2FastCrossedOverSlow =
fastR2 > slowR2 && fastR2Prev <= slowR2Prev;
result.isR2FastUnderSlow =
fastR2 < slowR2;
result.isR2FastCrossedUnderSlow =
fastR2 < slowR2 && fastR2Prev >= slowR2Prev;
//
result.isR3FastOverSlow =
fastR3 > slowR3;
result.isR3FastCrossedOverSlow =
fastR3 > slowR3 && fastR3Prev <= slowR3Prev;
result.isR3FastUnderSlow =
fastR3 < slowR3;
result.isR3FastCrossedUnderSlow =
fastR3 < slowR3 && fastR3Prev >= slowR3Prev;
//
result.isR4FastOverSlow =
fastR4 > slowR4;
result.isR4FastCrossedOverSlow =
fastR4 > slowR4 && fastR4Prev <= slowR4Prev;
result.isR4FastUnderSlow =
fastR4 < slowR4;
result.isR4FastCrossedUnderSlow =
fastR4 < slowR4 && fastR4Prev >= slowR4Prev;
//
result.isR5FastOverSlow =
fastR5 > slowR5;
result.isR5FastCrossedOverSlow =
fastR5 > slowR5 && fastR5Prev <= slowR5Prev;
result.isR5FastUnderSlow =
fastR5 < slowR5;
result.isR5FastCrossedUnderSlow =
fastR5 < slowR5 && fastR5Prev >= slowR5Prev;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Ribbon 1 ...
int mFast1Length;
int mSlow1Length;
//
// Ribbon 2 ...
int mFast2Length;
int mSlow2Length;
//
// Ribbon 3 ...
int mFast3Length;
int mSlow3Length;
//
// Ribbon 4 ...
int mFast4Length;
int mSlow4Length;
//
// Ribbon 5 ...
int mFast5Length;
int mSlow5Length;
//
// Calculation ...
//
// Mode ...
ENUM_MA_METHOD mRibbonMode;
//
// Applied To ...
ENUM_APPLIED_PRICE mRibbonAppliedTo;
//
// Presentation ...
//
// Show Fast ...
bool mShowFastMa;
//
// Show Slow ...
bool mShowSlowMa;
//
// Show Ribbon ...
bool mShowRibbon;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,644 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXPVHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XPVInputs
{
//
// Makret Cycles ...
int shortLength; // Short Length
int mediumLength; // Medium Length
int longLength; // Long Length
int hindLength; // Hind Length
double fiboLevel1; // Fibio 1st Level
double fiboLevel2; // Fibio 2st Level
double fiboLevel3; // Fibio 3rd Level
//
// Detection Modes ...
ENUM_SERIESMODE hhMode; // Highest High Calculation Method
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
//
// Presentation ...
bool showPeaksAndVales; // Show Peaks and Vales
bool showLevels; // Show Levels
bool showFibo1Levels; // Show Fibo 1st Level
bool showFibo2Levels; // Show Fibo 2nd Level
bool showFibo3Levels; // Show Fibo 3rd Level
};
//
// Index of Lines ...
enum ENUM_XPV_BUFFERS
{
//
// Main Requirements ...
XPV_PEAKS_LINE = 0,
XPV_VALES_LINE = 1,
XPV_FL1_LINE = 6,
XPV_FL2_LINE = 8,
XPV_FL3_LINE = 10,
};
//
// Retrieve Info Model ...
struct XPVInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double peak;
double vale;
double fl1;
double fl2;
double fl3;
//
// Conditions ...
//
// Determines New Peaks Happens ...
bool isNewPeak;
//
// Determines New Vales Happens ...
bool isNewVale;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXPVHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double peaksBuffer[];
double valesBuffer[];
double fl1Buffer[];
double fl2Buffer[];
double fl3Buffer[];
//
// Constructor ...
void XSCXPVHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXPVHelper()
{
}
//
// START Properties ...
//
//
// Show Levels ...
bool ShowLevels(
bool show // Show or Hide Levels
)
{
//
bool result = false;
//
if (mShowLevels == show)
{
return true;
}
//
mShowLevels = show;
result = Init();
//
return result;
}
//
// Show Peaks and Vales ...
bool ShowPeaksAnVales(
bool show // Show or Hide Levels
)
{
//
bool result = false;
//
if (mShowPeaksAndVales == show)
{
return true;
}
//
mShowPeaksAndVales = show;
result = Init();
//
return result;
}
//
// Show Fibo 1st Level ...
bool ShowFibo1Levels(
bool show // Show or Hide Levels
)
{
//
bool result = false;
//
if (mShowFibo1Levels == show)
{
return true;
}
//
mShowFibo1Levels = show;
result = Init();
//
return result;
}
//
// Show Fibo 2nd Level ...
bool ShowFibo2Levels(
bool show // Show or Hide Levels
)
{
//
bool result = false;
//
if (mShowFibo2Levels == show)
{
return true;
}
//
mShowFibo2Levels = show;
result = Init();
//
return result;
}
//
// Show Fibo 3rd Level ...
bool ShowFibo3Levels(
bool show // Show or Hide Levels
)
{
//
bool result = false;
//
if (mShowFibo3Levels == show)
{
return true;
}
//
mShowFibo3Levels = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XPV" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = MathMax(mShortLength, mMediumLength);
result = MathMax(result, mLongLength);
result = MathMax(result, mHindLength);
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Args ...
result =
//
(mShortLength > 2 &&
mMediumLength > mShortLength &&
mLongLength > mMediumLength &&
mHindLength > mLongLength)
//
;
if (!result)
{
return false;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xpv",
//
// Inputs ...
//
// Market ...
"",
//
// Short Length ...
mShortLength,
//
// Medium Length
mMediumLength,
//
// Long Length ...
mLongLength,
//
// Hind Length ...
mHindLength,
//
// Fibio 1st Level ...
mFiboLevel1,
//
// Fibio 2st Level ...
mFiboLevel2,
//
// Fibio 3rd Level ...
mFiboLevel3,
//
// Detection Mode ...
"",
//
// Highest High Calculation Method ...
mHHMode,
//
// Lowest Low Calculation Method ...
mLLMode,
//
// Presentations ...
"",
//
// Show Peaks and Vales ...
mShowPeaksAndVales,
//
// Show Levels ...
mShowLevels,
//
// Show Fibo 1st Level ...
mShowFibo1Levels,
//
// Show Fibo 2nd Level ...
mShowFibo2Levels,
//
// Show Fibo 3rd Level ...
mShowFibo3Levels
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XPVInputs GetConfig()
{
//
XPVInputs result;
//
result.shortLength = mShortLength;
result.mediumLength = mMediumLength;
result.longLength = mLongLength;
result.hindLength = mHindLength;
result.fiboLevel1 = mFiboLevel1;
result.fiboLevel2 = mFiboLevel2;
result.fiboLevel3 = mFiboLevel3;
result.hhMode = mHHMode;
result.llMode = mLLMode;
result.showPeaksAndVales = mShowPeaksAndVales;
result.showLevels = mShowLevels;
result.showFibo1Levels = mShowFibo1Levels;
result.showFibo2Levels = mShowFibo2Levels;
result.showFibo3Levels = mShowFibo3Levels;
//
return result;
}
//
// Set Config ...
bool SetConfig(XPVInputs &config)
{
//
bool result = false;
//
mShortLength = config.shortLength;
mMediumLength = config.mediumLength;
mLongLength = config.longLength;
mHindLength = config.hindLength;
mFiboLevel1 = config.fiboLevel1;
mFiboLevel2 = config.fiboLevel2;
mFiboLevel3 = config.fiboLevel3;
mHHMode = config.hhMode;
mLLMode = config.llMode;
mShowPeaksAndVales = config.showPeaksAndVales;
mShowLevels = config.showLevels;
mShowFibo1Levels = config.showFibo1Levels;
mShowFibo2Levels = config.showFibo2Levels;
mShowFibo3Levels = config.showFibo3Levels;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// PEAKS ...
ArraySetAsSeries(peaksBuffer, true);
CopyBuffer(
mHandler,
XPV_PEAKS_LINE,
barIndex,
mLoopbackBars,
peaksBuffer);
//
// VALES ...
ArraySetAsSeries(valesBuffer, true);
CopyBuffer(
mHandler,
XPV_VALES_LINE,
barIndex,
mLoopbackBars,
valesBuffer);
//
// FIBBO LEVELS ...
//
// LEVEL 1 ...
ArraySetAsSeries(fl1Buffer, true);
CopyBuffer(
mHandler,
XPV_FL1_LINE,
barIndex,
mLoopbackBars,
fl1Buffer);
//
// LEVEL 2 ...
ArraySetAsSeries(fl2Buffer, true);
CopyBuffer(
mHandler,
XPV_FL2_LINE,
barIndex,
mLoopbackBars,
fl2Buffer);
//
// LEVEL 3 ...
ArraySetAsSeries(fl3Buffer, true);
CopyBuffer(
mHandler,
XPV_FL3_LINE,
barIndex,
mLoopbackBars,
fl3Buffer);
}
//
// Retrieve Info at Specific Bar Index ...
XPVInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XPVInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
result.peak = peaksBuffer[barIndex];
result.vale = valesBuffer[barIndex];
result.fl1 = fl1Buffer[barIndex];
result.fl2 = fl2Buffer[barIndex];
result.fl3 = fl3Buffer[barIndex];
//
result.isNewPeak =
peaksBuffer[barIndex] != peaksBuffer[barIndex + 1];
result.isNewVale =
valesBuffer[barIndex] != valesBuffer[barIndex + 1];
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Short Length ...
int mShortLength;
//
// Medium Length
int mMediumLength;
//
// Long Length ...
int mLongLength;
//
// Hind Length ...
int mHindLength;
//
// Fibio 1st Level ...
double mFiboLevel1;
//
// Fibio 2st Level ...
double mFiboLevel2;
//
// Fibio 3rd Level ...
double mFiboLevel3;
//
// Detection Mode ...
//
// Highest High Calculation Method ...
ENUM_SERIESMODE mHHMode;
//
// Lowest Low Calculation Method ...
ENUM_SERIESMODE mLLMode;
//
// Presentations ...
//
// Show Peaks and Vales ...
bool mShowPeaksAndVales;
//
// Show Levels ...
bool mShowLevels;
//
// Show Fibo 1st Level ...
bool mShowFibo1Levels;
//
// Show Fibo 2nd Level ...
bool mShowFibo2Levels;
//
// Show Fibo 3rd Level ...
bool mShowFibo3Levels;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,473 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXSSLCHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XSSLCInputs
{
//
// Market ...
int length; // Length
//
// Calculation ...
ENUM_MA_METHOD method; // Method
ENUM_APPLIED_PRICE upAppliedTo; // Up Applied To
ENUM_APPLIED_PRICE downAppliedTo; // Down Applied To
//
// Presentation ...
bool showUp; // Show Up
bool showDown; // Show Down
};
//
// Index of Lines ...
enum ENUM_XSSLC_BUFFERS
{
//
// Main Requirements ...
XSSLC_UP_LINE = 0,
XSSLC_DOWN_LINE = 1,
};
//
// Retrieve Info Model ...
struct XSSLCInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double up;
double down;
//
// Conditions ...
//
// Detect Trend is Bullish or not ...
bool isBullish;
//
// Detect Trend is Switched to Bullish Or not ...
bool isSwitchedBullish;
//
// Detect Trend is Bearish or not ...
bool isBearish;
//
// Detect Trend is Switched to Bearish Or not ...
bool isSwitchedBearish;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXSSLCHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double upBuffer[];
double downBuffer[];
//
// Constructor ...
void XSCXSSLCHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXSSLCHelper()
{
}
//
// START Properties ...
//
//
// Show Up ...
bool ShowUp(
bool show // Show or Hide Line
)
{
//
bool result = false;
//
if (mShowUp == show)
{
return true;
}
//
mShowUp = show;
result = Init();
//
return result;
}
//
// Show Down ...
bool ShowDown(
bool show // Show or Hide Line
)
{
//
bool result = false;
//
if (mShowDown == show)
{
return true;
}
//
mShowDown = show;
result = Init();
//
return result;
}
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XSSLC" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = mLength;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Args ...
result =
//
(mLength >= 2)
//
;
if (!result)
{
return false;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xsslc",
//
// Inputs ...
//
// Market ...
"",
//
// Length ...
mLength,
//
// Calculation ...
"",
//
// Method ...
mMethod,
//
// Up Applied To ...
mUpAppliedTo,
//
// Down Applied To ...
mDownAppliedTo,
//
// Presentation ...
"",
//
// Show Up ...
mShowUp,
//
// Show Down ...
mShowDown
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XSSLCInputs GetConfig()
{
//
XSSLCInputs result;
//
result.length = mLength;
result.method = mMethod;
result.upAppliedTo = mUpAppliedTo;
result.downAppliedTo = mDownAppliedTo;
result.showUp = mShowUp;
result.showDown = mShowDown;
//
return result;
}
//
// Set Config ...
bool SetConfig(XSSLCInputs &config)
{
//
bool result = false;
//
mLength = config.length;
mMethod = config.method;
mUpAppliedTo = config.upAppliedTo;
mDownAppliedTo = config.downAppliedTo;
mShowUp = config.showUp;
mShowDown = config.showDown;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// UP ...
ArraySetAsSeries(upBuffer, true);
CopyBuffer(
mHandler,
XSSLC_UP_LINE,
barIndex,
mLoopbackBars,
upBuffer);
//
// DOWN ...
ArraySetAsSeries(downBuffer, true);
CopyBuffer(
mHandler,
XSSLC_DOWN_LINE,
barIndex,
mLoopbackBars,
downBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XSSLCInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XSSLCInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
double up = upBuffer[barIndex];
double upPrev = upBuffer[barIndex + 1];
double down = downBuffer[barIndex];
double downPrev = downBuffer[barIndex + 1];
//
result.up = up;
result.down = down;
//
result.isBullish = up > down;
result.isBearish = up < down;
//
result.isSwitchedBullish =
up > down &&
upPrev <= downPrev;
result.isSwitchedBearish =
up < down &&
upPrev >= downPrev;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Market ...
//
// Length ...
int mLength;
//
// Calculation ...
//
// Method ...
ENUM_MA_METHOD mMethod;
//
// Up Applied To ...
ENUM_APPLIED_PRICE mUpAppliedTo;
//
// Down Applied To ...
ENUM_APPLIED_PRICE mDownAppliedTo;
//
// Presentation ...
//
// Show Up ...
bool mShowUp;
//
// Show Down ...
bool mShowDown;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
@@ -0,0 +1,439 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XSCXTMHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// START Definitions ...
//
//
// Inputs ...
struct XTMInputs
{
//
// Makret ...
int length; // Length
int shift; // Shift
//
// Calculations ...
ENUM_MA_METHOD method; // Method
ENUM_APPLIED_PRICE appliedTo; // Applied To
//
// Presentation ...
bool showLine; // Show Line
};
//
// Index of Lines ...
enum ENUM_XTM_BUFFERS
{
//
// Main Requirements ...
XTM_LINE = 0,
XTM_STATE_LINE = 1,
};
//
// XTM Indicator States ...
enum ENUM_XTM_STATES
{
X_XTM_BULLISH = 0,
X_XTM_BEARISH = 2,
X_XTM_NEUTURAL = 1,
};
//
// Retrieve Info Model ...
struct XTMInfo
{
//
// Symbol ...
string symbol;
//
// Period ...
ENUM_TIMEFRAMES period;
//
// Bar Time ...
datetime barTime;
//
// Bar Index ...
int barIndex;
//
// Values ...
double value;
//
// State ...
ENUM_XTM_STATES state;
//
// Conditions ...
//
// Detect Trend is Bullish or not ...
bool isBullish;
//
// Detect Trend is Switched to Bullish Or not ...
bool isSwitchedBullish;
//
// Detect Trend is Bearish or not ...
bool isBearish;
//
// Detect Trend is Switched to Bearish Or not ...
bool isSwitchedBearish;
//
// Detect Trend is Neutural or not ...
bool isNeutural;
//
// Detect Trend is Switched to Neutural Or not ...
bool isSwitchedNeutural;
};
//
// END Definitions ...
//
//
// START Import and Inclused requirements ...
//
//
// Includes ...
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xhelper.class.mq5"
//
// END Import and Inclused requirements ...
//
//
// START Overrides ...
//
//
// END Overrides ...
//
//
// a Class for Helping Indicators Requirements ...
class XSCXTMHelper : public XSCBaseHelper
{
//
// Public ...
public:
//
// Buffers ...
double valueBuffer[];
double stateBuffer[];
//
// Constructor ...
void XSCXTMHelper(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading Time Frame
) : XSCBaseHelper(symbol, period)
{
PrepareTag();
}
//
// Deconstructor ...
void ~XSCXTMHelper()
{
}
//
// START Properties ...
//
//
// END Properties ...
//
//
// START Provided Functions ...
//
//
// Prepare Tag ...
virtual void PrepareTag()
{
mTag = "XTM" + GetTagPrefix();
}
//
virtual int GetMaxLength()
{
//
int result = -1;
//
result = mLength;
//
return result;
}
//
// Initial Indicator Handler ...
bool Init()
{
//
bool result = false;
//
// Validate Args ...
result =
//
(mLength >= 2)
//
;
if (!result)
{
return false;
}
//
// Initialize Handler ...
mHandler = iCustom(
//
mSymbol,
mPeriod,
"x-saherelm.x121.xtm",
//
// Inputs ...
//
// Makret ...
"",
//
// Length ...
mLength,
//
// Shift ...
mShift,
//
// Calculations ...
"",
//
// Method ...
mMethod,
//
// Applied To ...
mAppliedTo,
//
// Presentation ...
"",
//
// Show Line ...
mShowLine
//
);
result = mHandler != INVALID_HANDLE;
//
return result;
}
//
// Retrieve Current Config ...
XTMInputs GetConfig()
{
//
XTMInputs result;
//
result.length = mLength;
result.shift = mShift;
result.method = mMethod;
result.appliedTo = mAppliedTo;
result.showLine = mShowLine;
//
return result;
}
//
// Set Config ...
bool SetConfig(XTMInputs &config)
{
//
bool result = false;
//
mLength = config.length;
mShift = config.shift;
mMethod = config.method;
mAppliedTo = config.appliedTo;
mShowLine = config.showLine;
//
result = Init();
//
return result;
}
//
// Reading Buffers based on Given Bar Index ...
virtual void Calculate(
int barIndex // Given Bar Index
)
{
//
// VALUE ...
ArraySetAsSeries(valueBuffer, true);
CopyBuffer(
mHandler,
XTM_LINE,
barIndex,
mLoopbackBars,
valueBuffer);
//
// STATE ...
ArraySetAsSeries(stateBuffer, true);
CopyBuffer(
mHandler,
XTM_STATE_LINE,
barIndex,
mLoopbackBars,
stateBuffer);
}
//
// Retrieve Info at Specific Bar Index ...
XTMInfo GetInfo(
int barIndex // Given Bar Index
)
{
//
XTMInfo result;
//
if (barIndex < 0)
{
return result;
}
//
barIndex--;
if (barIndex < 0) {
barIndex = 0;
}
//
// Do Calculations ...
Calculate(barIndex);
//
// Generate Candle Time ...
datetime barTime = GetCandleTime(
mSymbol,
mPeriod,
barIndex);
//
// Fill Result ...
result.symbol = mSymbol;
result.period = mPeriod;
result.barTime = barTime;
result.barIndex = barIndex;
//
result.value = valueBuffer[barIndex];
//
ENUM_XTM_STATES state = (ENUM_XTM_STATES)stateBuffer[barIndex];
ENUM_XTM_STATES prevState = (ENUM_XTM_STATES)stateBuffer[barIndex + 1];
result.state = state;
//
result.isBullish = state == X_XTM_BULLISH;
result.isBearish = state == X_XTM_BEARISH;
result.isNeutural = state == X_XTM_NEUTURAL;
//
result.isSwitchedBullish =
state == X_XTM_BULLISH && prevState != X_XTM_BULLISH;
result.isSwitchedBearish =
state == X_XTM_BEARISH && prevState != X_XTM_BEARISH;
result.isSwitchedNeutural =
state == X_XTM_NEUTURAL && prevState != X_XTM_NEUTURAL;
//
return result;
}
//
// END Provided Functions ...
//
//
// Protected ...
protected:
//
// Private ...
private:
//
// Indicator Properties ...
//
// Makret ...
//
// Length ...
int mLength;
//
// Shift ...
int mShift;
//
// Calculations ...
//
// Method ...
ENUM_MA_METHOD mMethod;
//
// Applied To ...
ENUM_APPLIED_PRICE mAppliedTo;
//
// Presentation ...
//
// Show Line ...
bool mShowLine;
};
//
// START Usefull Functions ...
//
//
// END Usefull Functions ...
//
File diff suppressed because it is too large Load Diff