add MQL5Test Workspace Content as BKP Solution ...
This commit is contained in:
BIN
Binary file not shown.
+470
@@ -0,0 +1,470 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XAMAInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXAMAHelper(symbol,
|
||||
period,
|
||||
config.length,
|
||||
config.fastEMA,
|
||||
config.slowEMA,
|
||||
config.maShift,
|
||||
config.appliedTo,
|
||||
config.showLine);
|
||||
}
|
||||
void XSCXAMAHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Length ...
|
||||
int length = 52,
|
||||
//
|
||||
// Fast EMA Length ...
|
||||
int fastEMA = 2,
|
||||
//
|
||||
// Slow EMA Length ...
|
||||
int slowEMA = 30,
|
||||
//
|
||||
// Shift ...
|
||||
int maShift = 0,
|
||||
//
|
||||
// Applied To ...
|
||||
ENUM_APPLIED_PRICE appliedTo = PRICE_LOW,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show Line ...
|
||||
bool showLine = true
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mLength = length;
|
||||
mFastEMA = fastEMA;
|
||||
mSlowEMA = slowEMA;
|
||||
mMaShift = maShift;
|
||||
mShowLine = showLine;
|
||||
mAppliedTo = appliedTo;
|
||||
|
||||
//
|
||||
PrepareTag();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCXAMAHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// START Properties ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Properties ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Prepare Tag ...
|
||||
virtual void PrepareTag()
|
||||
{
|
||||
mTag = "XAMA" + GetTagPrefix();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+330
@@ -0,0 +1,330 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XCCInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXCCHelper(symbol,
|
||||
period,
|
||||
config.upColor,
|
||||
config.downColor,
|
||||
config.lineColor,
|
||||
config.bearishColor,
|
||||
config.bullishColor,
|
||||
config.volumesColor,
|
||||
config.showCandles);
|
||||
}
|
||||
void XSCXCCHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Chart Style ...
|
||||
//
|
||||
// Up Color ...
|
||||
color upColor = clrLime,
|
||||
//
|
||||
// Down Color ...
|
||||
color downColor = clrRed,
|
||||
//
|
||||
// Line mode and Doji candlestick Color ...
|
||||
color lineColor = clrLime,
|
||||
//
|
||||
// Bearish Color ...
|
||||
color bearishColor = clrRed,
|
||||
//
|
||||
// Bullish Color ...
|
||||
color bullishColor = clrLime,
|
||||
//
|
||||
// Volumes Color ...
|
||||
color volumesColor = clrGreen,
|
||||
//
|
||||
// Presentations ...
|
||||
//
|
||||
// Show Candles ...
|
||||
bool showCandles = false
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mUpColor = upColor;
|
||||
mDownColor = downColor;
|
||||
mLineColor = lineColor;
|
||||
mBearishColor = bearishColor;
|
||||
mBullishColor = bullishColor;
|
||||
mVolumesColor = volumesColor;
|
||||
mShowCandles = showCandles;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+648
@@ -0,0 +1,648 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XCHEInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXCHEHelper(symbol,
|
||||
period,
|
||||
config.length,
|
||||
config.loopback,
|
||||
config.multiplier1,
|
||||
config.multiplier2,
|
||||
config.upAppliedTo,
|
||||
config.downAppliedTo,
|
||||
config.showLongExit1Line,
|
||||
config.showShortExit1Line,
|
||||
config.showLongExit2Line,
|
||||
config.showShortExit2Line);
|
||||
}
|
||||
void XSCXCHEHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Length ...
|
||||
int length = 35,
|
||||
//
|
||||
// Loopback ...
|
||||
int loopback = 26,
|
||||
//
|
||||
// 1st Multiplier ...
|
||||
double multiplier1 = 3.0,
|
||||
//
|
||||
// 2nd Multiplier ...
|
||||
double multiplier2 = 3.5,
|
||||
//
|
||||
// Calculation ...
|
||||
//
|
||||
// Up Zone Applied to ...
|
||||
ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH,
|
||||
//
|
||||
// Down Zone Applied to ...
|
||||
ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show 1st Long Exit ...
|
||||
bool showLongExit1Line = true,
|
||||
//
|
||||
// Show 1st Short Exit ...
|
||||
bool showShortExit1Line = true,
|
||||
//
|
||||
// Show 2st Long Exit ...
|
||||
bool showLongExit2Line = true,
|
||||
//
|
||||
// Show 2st Short Exit ...
|
||||
bool showShortExit2Line = true
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mLength = length;
|
||||
mLoopback = loopback;
|
||||
mMultiplier1 = multiplier1;
|
||||
mMultiplier2 = multiplier2;
|
||||
mUpAppliedTo = upAppliedTo;
|
||||
mDownAppliedTo = downAppliedTo;
|
||||
mShowLongExit1Line = showLongExit1Line;
|
||||
mShowShortExit1Line = showShortExit1Line;
|
||||
mShowLongExit2Line = showLongExit2Line;
|
||||
mShowShortExit2Line = showShortExit2Line;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+432
@@ -0,0 +1,432 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XHKInputs &config // Indicator Properties ...
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXHKHelper(symbol,
|
||||
period,
|
||||
config.drawCandles,
|
||||
config.drawCandleLines);
|
||||
}
|
||||
void XSCXHKHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Draw Hiken Ashi Candle ...
|
||||
bool drawCandles = true,
|
||||
//
|
||||
// Show HikenAshi Lines ...
|
||||
bool drawCandleLines = false
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mDrawCandles = drawCandles;
|
||||
mDrawCandleLines = drawCandleLines;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+565
@@ -0,0 +1,565 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XHULLInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXHULLHelper(symbol,
|
||||
period,
|
||||
config.length,
|
||||
config.divisor,
|
||||
config.upAppliedTo,
|
||||
config.downAppliedTo,
|
||||
config.showUpZone,
|
||||
config.showDownZone);
|
||||
}
|
||||
void XSCXHULLHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Length ...
|
||||
int length = 72,
|
||||
//
|
||||
// Divisor (Speed) ...
|
||||
double divisor = 2.0,
|
||||
//
|
||||
// Calculation ...
|
||||
//
|
||||
// Up Zone Applied to ...
|
||||
ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH,
|
||||
//
|
||||
// Down Zone Applied to ...
|
||||
ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show Up Zone ...
|
||||
bool showUpZone = true,
|
||||
//
|
||||
// Show Down Zone ...
|
||||
bool showDownZone = true
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mLength = length;
|
||||
mDivisor = divisor;
|
||||
mUpAppliedTo = upAppliedTo;
|
||||
mDownAppliedTo = downAppliedTo;
|
||||
mShowUpZone = showUpZone;
|
||||
mShowDownZone = showDownZone;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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);
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+1052
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
+908
@@ -0,0 +1,908 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XMRBInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXMRBHelper(symbol,
|
||||
period,
|
||||
config.fast1Length,
|
||||
config.slow1Length,
|
||||
config.fast2Length,
|
||||
config.slow2Length,
|
||||
config.fast3Length,
|
||||
config.slow3Length,
|
||||
config.fast4Length,
|
||||
config.slow4Length,
|
||||
config.fast5Length,
|
||||
config.slow5Length,
|
||||
config.ribbonMode,
|
||||
config.ribbonAppliedTo,
|
||||
config.showFastMa,
|
||||
config.showSlowMa,
|
||||
config.showRibbon);
|
||||
}
|
||||
void XSCXMRBHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Ribbon 1 ...
|
||||
int fast1Length = 3,
|
||||
int slow1Length = 5,
|
||||
//
|
||||
// Ribbon 2 ...
|
||||
int fast2Length = 8,
|
||||
int slow2Length = 13,
|
||||
//
|
||||
// Ribbon 3 ...
|
||||
int fast3Length = 21,
|
||||
int slow3Length = 34,
|
||||
//
|
||||
// Ribbon 4 ...
|
||||
int fast4Length = 55,
|
||||
int slow4Length = 89,
|
||||
//
|
||||
// Ribbon 5 ...
|
||||
int fast5Length = 144,
|
||||
int slow5Length = 233,
|
||||
//
|
||||
// Calculation ...
|
||||
//
|
||||
// Mode ...
|
||||
ENUM_MA_METHOD ribbonMode = MODE_EMA,
|
||||
//
|
||||
// Applied To ...
|
||||
ENUM_APPLIED_PRICE ribbonAppliedTo = PRICE_CLOSE,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show Fast ...
|
||||
bool showFastMa = true,
|
||||
//
|
||||
// Show Slow ...
|
||||
bool showSlowMa = true,
|
||||
//
|
||||
// Show Ribbon ...
|
||||
bool showRibbon = false
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mFast1Length = fast1Length;
|
||||
mSlow1Length = slow1Length;
|
||||
mFast2Length = fast2Length;
|
||||
mSlow2Length = slow2Length;
|
||||
mFast3Length = fast3Length;
|
||||
mSlow3Length = slow3Length;
|
||||
mFast4Length = fast4Length;
|
||||
mSlow4Length = slow4Length;
|
||||
mFast5Length = fast5Length;
|
||||
mSlow5Length = slow5Length;
|
||||
mRibbonMode = ribbonMode;
|
||||
mRibbonAppliedTo = ribbonAppliedTo;
|
||||
mShowFastMa = showFastMa;
|
||||
mShowSlowMa = showSlowMa;
|
||||
mShowRibbon = showRibbon;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 &&
|
||||
mFast3Length > mFast3Length &&
|
||||
mSlow4Length > mFast4Length &&
|
||||
mSlow5Length > mFast5Length &&
|
||||
mSlow2Length > mSlow1Length &&
|
||||
mFast3Length > mSlow2Length &&
|
||||
mSlow4Length > mFast3Length &&
|
||||
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 ...
|
||||
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);
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+518
@@ -0,0 +1,518 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// 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
|
||||
};
|
||||
|
||||
//
|
||||
// Index of Lines ...
|
||||
enum ENUM_XPV_BUFFERS
|
||||
{
|
||||
//
|
||||
// Main Requirements ...
|
||||
XPV_PEAKS_LINE = 0,
|
||||
XPV_VALES_LINE = 1,
|
||||
};
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//
|
||||
// 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[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCXPVHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
XPVInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXPVHelper(symbol,
|
||||
period,
|
||||
config.shortLength,
|
||||
config.mediumLength,
|
||||
config.longLength,
|
||||
config.hindLength,
|
||||
config.hhMode,
|
||||
config.llMode,
|
||||
config.showPeaksAndVales,
|
||||
config.showLevels);
|
||||
}
|
||||
void XSCXPVHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Short Length ...
|
||||
int shortLength = 9,
|
||||
//
|
||||
// Medium Length
|
||||
int mediumLength = 17,
|
||||
//
|
||||
// Long Length ...
|
||||
int longLength = 26,
|
||||
//
|
||||
// Hind Length ...
|
||||
int hindLength = 35,
|
||||
//
|
||||
// Detection Mode ...
|
||||
//
|
||||
// Highest High Calculation Method ...
|
||||
ENUM_SERIESMODE hhMode = MODE_HIGH,
|
||||
//
|
||||
// Lowest Low Calculation Method ...
|
||||
ENUM_SERIESMODE llMode = MODE_LOW,
|
||||
//
|
||||
// Presentations ...
|
||||
//
|
||||
// Show Peaks and Vales ...
|
||||
bool showPeaksAndVales = false,
|
||||
//
|
||||
// Show Levels ...
|
||||
bool showLevels = false
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mHHMode = hhMode;
|
||||
mLLMode = llMode;
|
||||
mLongLength = longLength;
|
||||
mHindLength = hindLength;
|
||||
mShowLevels = showLevels;
|
||||
mShortLength = shortLength;
|
||||
mMediumLength = mediumLength;
|
||||
mShowPeaksAndVales = showPeaksAndVales;
|
||||
|
||||
//
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// END Properties ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Prepare Tag ...
|
||||
virtual void PrepareTag()
|
||||
{
|
||||
mTag = "XPV" + GetTagPrefix();
|
||||
}
|
||||
|
||||
//
|
||||
// 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,
|
||||
//
|
||||
// Detection Mode ...
|
||||
"",
|
||||
//
|
||||
// Highest High Calculation Method ...
|
||||
mHHMode,
|
||||
//
|
||||
// Lowest Low Calculation Method ...
|
||||
mLLMode,
|
||||
//
|
||||
// Presentations ...
|
||||
"",
|
||||
//
|
||||
// Show Peaks and Vales ...
|
||||
mShowPeaksAndVales,
|
||||
//
|
||||
// Show Levels ...
|
||||
mShowLevels
|
||||
//
|
||||
);
|
||||
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.hhMode = mHHMode;
|
||||
result.llMode = mLLMode;
|
||||
result.showPeaksAndVales = mShowPeaksAndVales;
|
||||
result.showLevels = mShowLevels;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Config ...
|
||||
bool SetConfig(XPVInputs &config)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mShortLength = config.shortLength;
|
||||
mMediumLength = config.mediumLength;
|
||||
mLongLength = config.longLength;
|
||||
mHindLength = config.hindLength;
|
||||
mHHMode = config.hhMode;
|
||||
mLLMode = config.llMode;
|
||||
mShowPeaksAndVales = config.showPeaksAndVales;
|
||||
mShowLevels = config.showLevels;
|
||||
|
||||
//
|
||||
result = Init();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Buffers based on Given Bar Index ...
|
||||
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);
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Info at Specific Bar Index ...
|
||||
XPVInfo GetInfo(
|
||||
int barIndex // Given Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
XPVInfo result;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// 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.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;
|
||||
//
|
||||
// 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;
|
||||
};
|
||||
|
||||
//
|
||||
// START Usefull Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Usefull Functions ...
|
||||
//
|
||||
BIN
Binary file not shown.
+509
@@ -0,0 +1,509 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XSSLCInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXSSLCHelper(symbol,
|
||||
period,
|
||||
config.length,
|
||||
config.method,
|
||||
config.upAppliedTo,
|
||||
config.downAppliedTo,
|
||||
config.showUp,
|
||||
config.showDown);
|
||||
}
|
||||
void XSCXSSLCHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Length ...
|
||||
int length = 36,
|
||||
//
|
||||
// Calculation ...
|
||||
//
|
||||
// Method ...
|
||||
ENUM_MA_METHOD method = MODE_SMA,
|
||||
//
|
||||
// Up Applied To ...
|
||||
ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH,
|
||||
//
|
||||
// Down Applied To ...
|
||||
ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show Up ...
|
||||
bool showUp = true,
|
||||
//
|
||||
// Show Down ...
|
||||
bool showDown = true
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mLength = length;
|
||||
mMethod = method;
|
||||
mUpAppliedTo = upAppliedTo;
|
||||
mDownAppliedTo = downAppliedTo;
|
||||
|
||||
//
|
||||
mShowUp = showUp;
|
||||
mShowDown = showDown;
|
||||
|
||||
//
|
||||
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();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+468
@@ -0,0 +1,468 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
XTMInputs &config // Indicator Properties ...
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
XSCXTMHelper(symbol,
|
||||
period,
|
||||
config.length,
|
||||
config.shift,
|
||||
config.method,
|
||||
config.appliedTo,
|
||||
config.showLine);
|
||||
}
|
||||
void XSCXTMHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame
|
||||
//
|
||||
// Indicator Properties ...
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Length ...
|
||||
int length = 35,
|
||||
//
|
||||
// Shift ...
|
||||
int shift = 0,
|
||||
//
|
||||
// Calculations ...
|
||||
//
|
||||
// Method ...
|
||||
ENUM_MA_METHOD method = MODE_SMA,
|
||||
//
|
||||
// Applied To ...
|
||||
ENUM_APPLIED_PRICE appliedTo = PRICE_LOW,
|
||||
//
|
||||
// Presentation ...
|
||||
//
|
||||
// Show Line ...
|
||||
bool showLine = true
|
||||
//
|
||||
) : XSCBaseHelper(symbol, period)
|
||||
{
|
||||
//
|
||||
// Indicator Properties ...
|
||||
mShift = shift;
|
||||
mLength = length;
|
||||
mMethod = method;
|
||||
mShowLine = showLine;
|
||||
mAppliedTo = appliedTo;
|
||||
|
||||
//
|
||||
PrepareTag();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCXTMHelper()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// START Properties ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Properties ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Prepare Tag ...
|
||||
virtual void PrepareTag()
|
||||
{
|
||||
mTag = "XTM" + GetTagPrefix();
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
BIN
Binary file not shown.
+1158
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,965 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCX121Provider
|
||||
// Description: X121 Signal Provider ...
|
||||
//
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Import and Inclused requirements ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.xprovider.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xcc.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xhk.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xtm.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xpv.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xama.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xmrb.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xche.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xich.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xtrnd.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xsslc.helper.class.mq5"
|
||||
#include "../Helpers/x-saherelm.x121.xhull.helper.class.mq5"
|
||||
|
||||
//
|
||||
// END Import and Inclused requirements ...
|
||||
//
|
||||
|
||||
//
|
||||
// Here we Have to Define an Input Structure Model
|
||||
// for Provider Class to Handle Helpers Definitions ...
|
||||
struct X121ProviderInputs
|
||||
{
|
||||
//
|
||||
// XCC ...
|
||||
// Candle Styling ...
|
||||
XCCInputs xccConfig;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
// HikenAshi Candle Representing ...
|
||||
XHKInputs xhkConfig;
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
// Trend Magic ...
|
||||
XTMInputs xtmConfig;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
// Peaks And Vales ...
|
||||
XPVInputs xpvConfig;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
// Adaptive Moving Average ...
|
||||
XAMAInputs xamaConfig;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
// Moving Average Ribbon ...
|
||||
XMRBInputs xmrbConfig;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
// Chandelier Exit Points ...
|
||||
XCHEInputs xcheConfig;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
// Ichimopku Kinko Hyo ...
|
||||
XICHInputs xichConfig;
|
||||
|
||||
//
|
||||
// XTRND ...
|
||||
// Trend Detector ...
|
||||
XTRNDInputs xtrndConfig;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
// SSL Channel ...
|
||||
XSSLCInputs xsslcConfig;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
// Hull Trend Detection Channel ...
|
||||
XHULLInputs xhullConfig;
|
||||
};
|
||||
|
||||
//
|
||||
// Model Market Sense based On Current Captured conditions ...
|
||||
struct X121MarketConditions
|
||||
{
|
||||
//
|
||||
// Commonly Used Info ...
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
string symbol;
|
||||
|
||||
//
|
||||
// Period ...
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
// Bar Time ...
|
||||
datetime barTime;
|
||||
|
||||
//
|
||||
// Bar Index ...
|
||||
int barIndex;
|
||||
|
||||
//
|
||||
// Check Current Market Condition has Signal or not ...
|
||||
bool hasSignal;
|
||||
|
||||
//
|
||||
// If has any Signal, Models it's related info here ...
|
||||
XSignalInfo signal;
|
||||
|
||||
//
|
||||
// INDICATORS Market Sense ...
|
||||
|
||||
//
|
||||
// XCC ...
|
||||
// there is not any Info provided here ...
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XHKInfo xhkInfo;
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
XTMInfo xtmInfo;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XPVInfo xpvInfo;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
XAMAInfo xamaInfo;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
XMRBInfo xmrbInfo;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
XCHEInfo xcheInfo;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
XICHInfo xichInfo;
|
||||
|
||||
//
|
||||
// XTRND ...
|
||||
XTRNDInfo xtrndInfo;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
XSSLCInfo xsslcInfo;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
XHULLInfo xhullInfo;
|
||||
};
|
||||
|
||||
//
|
||||
// Notified a Signal was Appears ...
|
||||
typedef void (*TOnSignalConditions)(
|
||||
X121MarketConditions &info);
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Overrides ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Overrides ...
|
||||
//
|
||||
|
||||
//
|
||||
// a Base Class for All of our EA's ...
|
||||
class XSCX121Provider : public XSCEABaseProvider
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
X121ProviderInputs providedConfig;
|
||||
X121ProviderInputs currentConfig;
|
||||
X121ProviderInputs cleanConfig;
|
||||
|
||||
//
|
||||
// Indicator Helper Classes Instance ...
|
||||
|
||||
//
|
||||
// XCC ...
|
||||
XSCXCCHelper *mXCCHelper;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
XSCXHKHelper *mXHKHelper;
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
XSCXTMHelper *mXTMHelper;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
XSCXPVHelper *mXPVHelper;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
XSCXAMAHelper *mXAMAHelper;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
XSCXMRBHelper *mXMRBHelper;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
XSCXCHEHelper *mXCHEHelper;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
XSCXICHHelper *mXICHHelper;
|
||||
|
||||
//
|
||||
// XTRND ...
|
||||
XSCXTRNDHelper *mXTRNDHelper;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
XSCXSSLCHelper *mXSSLCHelper;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
XSCXHULLHelper *mXHULLHelper;
|
||||
|
||||
//
|
||||
// Define Helpers ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCX121Provider() : XSCEABaseProvider(_Symbol, _Period){};
|
||||
void XSCX121Provider(
|
||||
string symbol, // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES period // Trading Time Frame ...
|
||||
) : XSCEABaseProvider(symbol, period)
|
||||
{
|
||||
//
|
||||
// Prepare Default and Clean Config ...
|
||||
// in this Config non of Indicators doesn't Draw anything on chart ...
|
||||
X121ProviderInputs configs;
|
||||
|
||||
//
|
||||
// XCC ...
|
||||
// Candle Styling ...
|
||||
configs.xccConfig.upColor = clrLime;
|
||||
configs.xccConfig.downColor = clrRed;
|
||||
configs.xccConfig.lineColor = clrLime;
|
||||
configs.xccConfig.bearishColor = clrRed;
|
||||
configs.xccConfig.bullishColor = clrLime;
|
||||
configs.xccConfig.volumesColor = clrGreen;
|
||||
configs.xccConfig.showCandles = true;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
// HikenAshi Candle Representing ...
|
||||
configs.xhkConfig.drawCandles = false;
|
||||
configs.xhkConfig.drawCandleLines = false;
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
// Trend Magic ...
|
||||
configs.xtmConfig.length = 35;
|
||||
configs.xtmConfig.shift = 0;
|
||||
configs.xtmConfig.method = MODE_SMA;
|
||||
configs.xtmConfig.appliedTo = PRICE_LOW;
|
||||
configs.xtmConfig.showLine = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
// Peaks And Vales ...
|
||||
configs.xpvConfig.shortLength = 9;
|
||||
configs.xpvConfig.mediumLength = 17;
|
||||
configs.xpvConfig.longLength = 26;
|
||||
configs.xpvConfig.hindLength = 35;
|
||||
configs.xpvConfig.hhMode = MODE_HIGH;
|
||||
configs.xpvConfig.llMode = MODE_LOW;
|
||||
configs.xpvConfig.showPeaksAndVales = false;
|
||||
configs.xpvConfig.showLevels = false;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
// Adaptive Moving Average ...
|
||||
configs.xamaConfig.length = 52;
|
||||
configs.xamaConfig.fastEMA = 2;
|
||||
configs.xamaConfig.slowEMA = 30;
|
||||
configs.xamaConfig.maShift = 0;
|
||||
configs.xamaConfig.appliedTo = PRICE_LOW;
|
||||
configs.xamaConfig.showLine = false;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
// Moving Average Ribbon ...
|
||||
configs.xmrbConfig.fast1Length = 3;
|
||||
configs.xmrbConfig.slow1Length = 5;
|
||||
configs.xmrbConfig.fast2Length = 8;
|
||||
configs.xmrbConfig.slow2Length = 13;
|
||||
configs.xmrbConfig.fast3Length = 21;
|
||||
configs.xmrbConfig.slow3Length = 34;
|
||||
configs.xmrbConfig.fast4Length = 55;
|
||||
configs.xmrbConfig.slow4Length = 89;
|
||||
configs.xmrbConfig.fast5Length = 144;
|
||||
configs.xmrbConfig.slow5Length = 233;
|
||||
configs.xmrbConfig.ribbonMode = MODE_EMA;
|
||||
configs.xmrbConfig.ribbonAppliedTo = PRICE_CLOSE;
|
||||
configs.xmrbConfig.showFastMa = false;
|
||||
configs.xmrbConfig.showSlowMa = false;
|
||||
configs.xmrbConfig.showRibbon = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
// Chandelier Exit Points ...
|
||||
configs.xcheConfig.length = 35;
|
||||
configs.xcheConfig.loopback = 26;
|
||||
configs.xcheConfig.multiplier1 = 3;
|
||||
configs.xcheConfig.multiplier2 = 3;
|
||||
configs.xcheConfig.upAppliedTo = PRICE_HIGH;
|
||||
configs.xcheConfig.downAppliedTo = PRICE_LOW;
|
||||
configs.xcheConfig.showLongExit1Line = false;
|
||||
configs.xcheConfig.showShortExit1Line = false;
|
||||
configs.xcheConfig.showLongExit2Line = false;
|
||||
configs.xcheConfig.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
// Ichimopku Kinko Hyo ...
|
||||
configs.xichConfig.tenkanSenLength = 9;
|
||||
configs.xichConfig.tenkanSenMode = X_XICH_HH_LL_MODE;
|
||||
configs.xichConfig.kijunSenLength = 26;
|
||||
configs.xichConfig.kijunSenMode = X_XICH_HH_LL_MODE;
|
||||
configs.xichConfig.senkouSpanBLength = 52;
|
||||
configs.xichConfig.senkouSpanBMode = X_XICH_HH_LL_MODE;
|
||||
configs.xichConfig.chikuoSpanAppliedTo = PRICE_CLOSE;
|
||||
configs.xichConfig.showTenkanSen = false;
|
||||
configs.xichConfig.showKijunSen = false;
|
||||
configs.xichConfig.showKijunSenPlus = false;
|
||||
configs.xichConfig.showKijunSenNegative = false;
|
||||
configs.xichConfig.showChikouSpan = false;
|
||||
configs.xichConfig.showSenkouSpanA = false;
|
||||
configs.xichConfig.showSenkouSpanB = false;
|
||||
configs.xichConfig.showKumo = false;
|
||||
configs.xichConfig.shiftKumo = true;
|
||||
|
||||
//
|
||||
// XTRND ...
|
||||
// Trend Detector ...
|
||||
configs.xtrndConfig.cycleLength = 2;
|
||||
configs.xtrndConfig.numberOfVerifications = 2;
|
||||
configs.xtrndConfig.hhMode = MODE_HIGH;
|
||||
configs.xtrndConfig.llMode = MODE_LOW;
|
||||
configs.xtrndConfig.l1Method = X_PERIOD_AUTO;
|
||||
configs.xtrndConfig.l1Period = NULL;
|
||||
configs.xtrndConfig.l2Method = X_PERIOD_AUTO;
|
||||
configs.xtrndConfig.l2Period = NULL;
|
||||
configs.xtrndConfig.l3Method = X_PERIOD_AUTO;
|
||||
configs.xtrndConfig.l3Period = NULL;
|
||||
configs.xtrndConfig.showConsolidations = false;
|
||||
configs.xtrndConfig.showTrend = false;
|
||||
configs.xtrndConfig.showL1Trend = false;
|
||||
configs.xtrndConfig.showL2Trend = false;
|
||||
configs.xtrndConfig.showL3Trend = false;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
// SSL Channel ...
|
||||
configs.xsslcConfig.length = 36;
|
||||
configs.xsslcConfig.method = MODE_SMA;
|
||||
configs.xsslcConfig.upAppliedTo = PRICE_HIGH;
|
||||
configs.xsslcConfig.downAppliedTo = PRICE_LOW;
|
||||
configs.xsslcConfig.showUp = false;
|
||||
configs.xsslcConfig.showDown = false;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
// Hull Trend Detection Channel ...
|
||||
configs.xhullConfig.length = 72;
|
||||
configs.xhullConfig.divisor = 2;
|
||||
configs.xhullConfig.upAppliedTo = PRICE_HIGH;
|
||||
configs.xhullConfig.downAppliedTo = PRICE_LOW;
|
||||
configs.xhullConfig.showUpZone = false;
|
||||
configs.xhullConfig.showDownZone = false;
|
||||
|
||||
//
|
||||
// Clean Config ...
|
||||
cleanConfig = configs;
|
||||
|
||||
//
|
||||
XSCX121Provider(symbol, period, configs);
|
||||
}
|
||||
void XSCX121Provider(
|
||||
string symbol, // Trading Symbol ...
|
||||
ENUM_TIMEFRAMES period, // Trading Time Frame ...
|
||||
X121ProviderInputs &config // Configs ...
|
||||
)
|
||||
{
|
||||
//
|
||||
mTag = "X121Provider|" + mSymbol + "," + ToString(mPeriod);
|
||||
|
||||
// //
|
||||
// mCTimerHandler = iCustom(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// "x-saherelm.x121.xct",
|
||||
// //
|
||||
// // Inputs ...
|
||||
// clrYellow,
|
||||
// CORNER_RIGHT_LOWER,
|
||||
// true
|
||||
// //
|
||||
// );
|
||||
|
||||
//
|
||||
currentConfig = config;
|
||||
providedConfig = config;
|
||||
|
||||
//
|
||||
// Here we Have to Make Provided Config in Clean Style ...
|
||||
PrepareCleanConfig();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCX121Provider()
|
||||
{
|
||||
//
|
||||
IndicatorRelease(mCTimerHandler);
|
||||
|
||||
//
|
||||
// De construct Helpers ...
|
||||
delete mXCCHelper;
|
||||
delete mXHKHelper;
|
||||
delete mXTMHelper;
|
||||
delete mXPVHelper;
|
||||
delete mXAMAHelper;
|
||||
delete mXMRBHelper;
|
||||
delete mXCHEHelper;
|
||||
delete mXICHHelper;
|
||||
delete mXTRNDHelper;
|
||||
delete mXSSLCHelper;
|
||||
delete mXHULLHelper;
|
||||
}
|
||||
|
||||
//
|
||||
bool Init()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Instantiate all Indicators Helper Classes ...
|
||||
//
|
||||
// // XCC ...
|
||||
// mXCCHelper = new XSCXCCHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xccConfig);
|
||||
// result = mXCCHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// }
|
||||
|
||||
// //
|
||||
// // XHK ...
|
||||
// mXHKHelper = new XSCXHKHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xhkConfig);
|
||||
// result = mXHKHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
// mXTMHelper = new XSCXTMHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xtmConfig);
|
||||
// result = mXTMHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XPV ...
|
||||
// mXPVHelper = new XSCXPVHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xpvConfig);
|
||||
// result = mXPVHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// LogMessage("XPV Error: ");
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XAMA ...
|
||||
// mXAMAHelper = new XSCXAMAHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xamaConfig);
|
||||
// result = mXAMAHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XMRB ...
|
||||
// mXMRBHelper = new XSCXMRBHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xmrbConfig);
|
||||
// result = mXMRBHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XCHE ...
|
||||
// mXCHEHelper = new XSCXCHEHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xcheConfig);
|
||||
// result = mXCHEHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XICH ...
|
||||
// mXICHHelper = new XSCXICHHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xichConfig);
|
||||
// result = mXICHHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XTRND ...
|
||||
// mXTRNDHelper = new XSCXTRNDHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xtrndConfig);
|
||||
// result = mXTRNDHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XSSLC ...
|
||||
// mXSSLCHelper = new XSCXSSLCHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xsslcConfig);
|
||||
// result = mXSSLCHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
// //
|
||||
// // XHULL ...
|
||||
// mXHULLHelper = new XSCXHULLHelper(
|
||||
// mSymbol,
|
||||
// mPeriod,
|
||||
// currentConfig.xhullConfig);
|
||||
// result = mXHULLHelper.Init();
|
||||
// if (!result)
|
||||
// {
|
||||
// return result;
|
||||
// };
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
virtual void ProcessBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
virtual void ProcessTick()
|
||||
{
|
||||
ProcessSignals();
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Market Sense ...
|
||||
X121MarketConditions GetMarketConditions(
|
||||
int barIndex // Specified Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
X121MarketConditions result;
|
||||
|
||||
//
|
||||
// Fill Common Data ...
|
||||
result.symbol = mSymbol;
|
||||
result.period = mPeriod;
|
||||
result.barIndex = barIndex;
|
||||
|
||||
//
|
||||
datetime barTime = GetCandleTime(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex);
|
||||
result.barTime = barTime;
|
||||
|
||||
//
|
||||
result.xhkInfo = mXHKHelper.GetInfo(barIndex);
|
||||
result.xtmInfo = mXTMHelper.GetInfo(barIndex);
|
||||
result.xpvInfo = mXPVHelper.GetInfo(barIndex);
|
||||
result.xamaInfo = mXAMAHelper.GetInfo(barIndex);
|
||||
result.xmrbInfo = mXMRBHelper.GetInfo(barIndex);
|
||||
result.xcheInfo = mXCHEHelper.GetInfo(barIndex);
|
||||
result.xichInfo = mXICHHelper.GetInfo(barIndex);
|
||||
result.xtrndInfo = mXTRNDHelper.GetInfo(barIndex);
|
||||
result.xsslcInfo = mXSSLCHelper.GetInfo(barIndex);
|
||||
result.xhullInfo = mXHULLHelper.GetInfo(barIndex);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Specific On SignalConditions Event Handler ...
|
||||
int AddOnSignalConditionEventHandler(TOnSignalConditions handler)
|
||||
{
|
||||
//
|
||||
ArrayResize(
|
||||
mSignalConditionsEventHandlers,
|
||||
ArraySize(mSignalConditionsEventHandlers) + 1);
|
||||
|
||||
//
|
||||
int result = ArraySize(mSignalConditionsEventHandlers) - 1;
|
||||
mSignalConditionsEventHandlers[result] = handler;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove All On Signal Event Handler ...
|
||||
void ReoveOnSignalEventHandlers()
|
||||
{
|
||||
//
|
||||
ArrayFree(mSignalConditionsEventHandlers);
|
||||
}
|
||||
|
||||
//
|
||||
// Notify a Signal Found on all Event Listeners ...
|
||||
void NotifyOnSignalConditionsEvent(X121MarketConditions &info)
|
||||
{
|
||||
//
|
||||
int listenerCount = ArraySize(mSignalConditionsEventHandlers);
|
||||
if (listenerCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop Through Listeners ...
|
||||
for (int i = 0; i < listenerCount; i++)
|
||||
{
|
||||
//
|
||||
TOnSignalConditions listener = mSignalConditionsEventHandlers[i];
|
||||
|
||||
//
|
||||
listener(info);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// CCandle Timer ...
|
||||
int mCTimerHandler;
|
||||
|
||||
//
|
||||
// Signal Event Handlers ...
|
||||
TOnSignalConditions mSignalConditionsEventHandlers[];
|
||||
|
||||
//
|
||||
// Make Provided Config in Clean Style ...
|
||||
void PrepareCleanConfig()
|
||||
{
|
||||
//
|
||||
cleanConfig = providedConfig;
|
||||
|
||||
//
|
||||
// XCC ...
|
||||
// Candle Styling ...
|
||||
cleanConfig.xccConfig.showCandles = true;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
// HikenAshi Candle Representing ...
|
||||
cleanConfig.xhkConfig.drawCandles = false;
|
||||
cleanConfig.xhkConfig.drawCandleLines = false;
|
||||
|
||||
//
|
||||
// XTM ...
|
||||
// Trend Magic ...
|
||||
cleanConfig.xtmConfig.showLine = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
// Peaks And Vales ...
|
||||
cleanConfig.xpvConfig.showPeaksAndVales = false;
|
||||
cleanConfig.xpvConfig.showLevels = false;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
// Adaptive Moving Average ...
|
||||
cleanConfig.xamaConfig.showLine = false;
|
||||
|
||||
//
|
||||
// XMRB ...
|
||||
// Moving Average Ribbon ...
|
||||
cleanConfig.xmrbConfig.showFastMa = false;
|
||||
cleanConfig.xmrbConfig.showSlowMa = false;
|
||||
cleanConfig.xmrbConfig.showRibbon = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
// Chandelier Exit Points ...
|
||||
cleanConfig.xcheConfig.showLongExit1Line = false;
|
||||
cleanConfig.xcheConfig.showShortExit1Line = false;
|
||||
cleanConfig.xcheConfig.showLongExit2Line = false;
|
||||
cleanConfig.xcheConfig.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
// Ichimopku Kinko Hyo ...
|
||||
cleanConfig.xichConfig.showTenkanSen = false;
|
||||
cleanConfig.xichConfig.showKijunSen = false;
|
||||
cleanConfig.xichConfig.showKijunSenPlus = false;
|
||||
cleanConfig.xichConfig.showKijunSenNegative = false;
|
||||
cleanConfig.xichConfig.showChikouSpan = false;
|
||||
cleanConfig.xichConfig.showSenkouSpanA = false;
|
||||
cleanConfig.xichConfig.showSenkouSpanB = false;
|
||||
cleanConfig.xichConfig.showKumo = false;
|
||||
|
||||
//
|
||||
// XTRND ...
|
||||
// Trend Detector ...
|
||||
cleanConfig.xtrndConfig.showConsolidations = false;
|
||||
cleanConfig.xtrndConfig.showTrend = false;
|
||||
cleanConfig.xtrndConfig.showL1Trend = false;
|
||||
cleanConfig.xtrndConfig.showL2Trend = false;
|
||||
cleanConfig.xtrndConfig.showL3Trend = false;
|
||||
|
||||
//
|
||||
// XSSLC ...
|
||||
// SSL Channel ...
|
||||
cleanConfig.xsslcConfig.showUp = false;
|
||||
cleanConfig.xsslcConfig.showDown = false;
|
||||
|
||||
//
|
||||
// XHULL ...
|
||||
// Hull Trend Detection Channel ...
|
||||
cleanConfig.xhullConfig.showUpZone = false;
|
||||
cleanConfig.xhullConfig.showDownZone = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Here we are Capture Conditions and Check Signals ...
|
||||
// The Signals Must be Unique for each providers ...
|
||||
void ProcessSignals()
|
||||
{
|
||||
//
|
||||
X121MarketConditions conditions = GetMarketConditions(1);
|
||||
|
||||
//
|
||||
// BUY ...
|
||||
|
||||
//
|
||||
Clean(conditions.signal);
|
||||
bool hasLongSignal = HasLongSignal(conditions);
|
||||
if (hasLongSignal)
|
||||
{
|
||||
//
|
||||
NotifyOnSignalEvent(
|
||||
conditions.signal);
|
||||
NotifyOnSignalConditionsEvent(conditions);
|
||||
mWaitUntilNewCandle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// SELL ...
|
||||
|
||||
//
|
||||
Clean(conditions.signal);
|
||||
bool hasShortignal = HasShortSignal(conditions);
|
||||
if (hasShortignal)
|
||||
{
|
||||
//
|
||||
NotifyOnSignalEvent(
|
||||
conditions.signal);
|
||||
NotifyOnSignalConditionsEvent(conditions);
|
||||
mWaitUntilNewCandle = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check has Long Signal on Each Strategies ...
|
||||
bool HasLongSignal(X121MarketConditions &conditions)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check has Short Signal on Each Strategies ...
|
||||
bool HasShortSignal(X121MarketConditions &conditions)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Model Signal Providers Definitions ...
|
||||
struct X121SignalProvider
|
||||
{
|
||||
//
|
||||
// Provider use Which Symbol ...
|
||||
string symbol;
|
||||
|
||||
//
|
||||
// Provider use Which Time Frame ...
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
// Risk Amount Per Trades Related to Time Frames ...
|
||||
// Percent of Available Balance ...
|
||||
double riskAmount;
|
||||
|
||||
//
|
||||
// Desired Magic Number ...
|
||||
ulong magicNumber;
|
||||
|
||||
//
|
||||
// Provider ...
|
||||
XSCX121Provider provider;
|
||||
};
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Usefull Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Add Specific Provider to List ...
|
||||
void Add(
|
||||
X121SignalProvider &item, // item want to add
|
||||
X121SignalProvider &buffer[] // Destination buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
ArrayResize(
|
||||
buffer,
|
||||
ArraySize(buffer) + 1);
|
||||
|
||||
//
|
||||
buffer[ArraySize(buffer) - 1] = item;
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Identifier Tag ...
|
||||
string GenerateTag(X121SignalProvider &descriptor)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result = descriptor.symbol + "," + ToString(descriptor.period);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Usefull Functions ...
|
||||
//
|
||||
Reference in New Issue
Block a user