1789 lines
39 KiB
Plaintext
1789 lines
39 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// 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.xct.helper.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"
|
|
|
|
//
|
|
// Seriallizer Library ...
|
|
#include "../Libraries/x-saherelm.seriallizer.lib.mq5"
|
|
|
|
//
|
|
// END Import and Inclused requirements ...
|
|
//
|
|
|
|
//
|
|
// Here we Have to Define an Input Structure Model
|
|
// for Provider Class to Handle Helpers Definitions ...
|
|
struct X121ProviderInputs
|
|
{
|
|
//
|
|
// XCT ...
|
|
// Candle Timer ...
|
|
XCTInputs xctConfig;
|
|
|
|
//
|
|
// 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;
|
|
|
|
//
|
|
XCandleRemains barRemains;
|
|
|
|
//
|
|
// Bar Index ...
|
|
int barIndex;
|
|
|
|
//
|
|
// Check Current Market Condition has Signal or not ...
|
|
bool hasSignal;
|
|
|
|
//
|
|
// If has any Signal, Models it's related info here ...
|
|
XSignal signal;
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
// if provides Signal ...
|
|
XOHCLSupRes supportResistances;
|
|
|
|
//
|
|
// Change Price Steps ...
|
|
double momentumStep;
|
|
|
|
//
|
|
// INDICATORS Market Sense ...
|
|
|
|
//
|
|
// XCT ...
|
|
// there is not any Info provided here ...
|
|
|
|
//
|
|
// 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);
|
|
|
|
//
|
|
// All Available Signal Types ...
|
|
enum ENUM_X121_SIGNAL_PROVIDERS
|
|
{
|
|
NONE, // NONE ...
|
|
XPVF, // Peakse and Vales Using Fibo ...
|
|
XCHNL, // SSL Channel and MRB Signals ...
|
|
XTRND, // Trend Base ...
|
|
};
|
|
|
|
//
|
|
// 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 ...
|
|
|
|
//
|
|
// XCT ...
|
|
XSCXCTHelper *mXCTHelper;
|
|
|
|
//
|
|
// 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;
|
|
|
|
//
|
|
// Hull Pivot Points ...
|
|
double upZonePivots[];
|
|
double downZonePivots[];
|
|
|
|
//
|
|
// Peaks and Vales Verifications Number ...
|
|
double peaksPivots[];
|
|
double valesPivots[];
|
|
|
|
//
|
|
double ichPivots[];
|
|
|
|
//
|
|
double fiboPivots[];
|
|
|
|
//
|
|
int pvConsequences;
|
|
|
|
//
|
|
// Constructor ...
|
|
void XSCX121Provider(
|
|
string symbol, // Trading Symbol ...
|
|
ENUM_TIMEFRAMES period // Trading Time Frame ...
|
|
)
|
|
{
|
|
//
|
|
mMinPivots = 100;
|
|
pvConsequences = 26;
|
|
mDisableXPVFShort = false;
|
|
mDisableXPVFLong = false;
|
|
|
|
//
|
|
PrepareTag();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
void ~XSCX121Provider()
|
|
{
|
|
//
|
|
IndicatorRelease(mCTimerHandler);
|
|
|
|
//
|
|
// De construct Helpers ...
|
|
delete mXCTHelper;
|
|
delete mXCCHelper;
|
|
delete mXHKHelper;
|
|
delete mXTMHelper;
|
|
delete mXPVHelper;
|
|
delete mXAMAHelper;
|
|
delete mXMRBHelper;
|
|
delete mXCHEHelper;
|
|
delete mXICHHelper;
|
|
delete mXTRNDHelper;
|
|
delete mXSSLCHelper;
|
|
delete mXHULLHelper;
|
|
}
|
|
|
|
//
|
|
int GetMinPivots() {
|
|
return mMinPivots;
|
|
}
|
|
|
|
//
|
|
virtual void PrepareTag()
|
|
{
|
|
mTag = "X121Provider((" + mSymbol + ")(" + ToString(mPeriod) + ")";
|
|
}
|
|
|
|
//
|
|
virtual bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Instantiate all Indicators Helper Classes ...
|
|
|
|
//
|
|
// XCT ...
|
|
mXCTHelper = new XSCXCTHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXCTHelper.SetConfig(currentConfig.xctConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCC ...
|
|
mXCCHelper = new XSCXCCHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXCCHelper.SetConfig(currentConfig.xccConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XHK ...
|
|
mXHKHelper = new XSCXHKHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXHKHelper.SetConfig(currentConfig.xhkConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XTM ...
|
|
mXTMHelper = new XSCXTMHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXTMHelper.SetConfig(currentConfig.xtmConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XPV ...
|
|
mXPVHelper = new XSCXPVHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXPVHelper.SetConfig(currentConfig.xpvConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XAMA ...
|
|
mXAMAHelper = new XSCXAMAHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXAMAHelper.SetConfig(currentConfig.xamaConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XMRB ...
|
|
mXMRBHelper = new XSCXMRBHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXMRBHelper.SetConfig(currentConfig.xmrbConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XCHE ...
|
|
mXCHEHelper = new XSCXCHEHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXCHEHelper.SetConfig(currentConfig.xcheConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XICH ...
|
|
mXICHHelper = new XSCXICHHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXICHHelper.SetConfig(currentConfig.xichConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XTRND ...
|
|
mXTRNDHelper = new XSCXTRNDHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXTRNDHelper.SetConfig(currentConfig.xtrndConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XSSLC ...
|
|
mXSSLCHelper = new XSCXSSLCHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXSSLCHelper.SetConfig(currentConfig.xsslcConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
// XHULL ...
|
|
mXHULLHelper = new XSCXHULLHelper(
|
|
mSymbol,
|
|
mPeriod);
|
|
result = mXHULLHelper.SetConfig(currentConfig.xhullConfig);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
};
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
virtual int GetMaxLength()
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
result = MathMax(result, mXCTHelper.GetMaxLength());
|
|
result = MathMax(result, mXCCHelper.GetMaxLength());
|
|
result = MathMax(result, mXHKHelper.GetMaxLength());
|
|
result = MathMax(result, mXTMHelper.GetMaxLength());
|
|
result = MathMax(result, mXPVHelper.GetMaxLength());
|
|
result = MathMax(result, mXAMAHelper.GetMaxLength());
|
|
result = MathMax(result, mXMRBHelper.GetMaxLength());
|
|
result = MathMax(result, mXCHEHelper.GetMaxLength());
|
|
result = MathMax(result, mXICHHelper.GetMaxLength());
|
|
result = MathMax(result, mXTRNDHelper.GetMaxLength());
|
|
result = MathMax(result, mXSSLCHelper.GetMaxLength());
|
|
result = MathMax(result, mXHULLHelper.GetMaxLength());
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
virtual int GetCalculatedBars()
|
|
{
|
|
//
|
|
int result = -1;
|
|
|
|
//
|
|
int mXCTBars = mXCTHelper.GetCalculatedBars();
|
|
int mXCCBars = mXCCHelper.GetCalculatedBars();
|
|
int mXHKBars = mXHKHelper.GetCalculatedBars();
|
|
int mXTMBars = mXTMHelper.GetCalculatedBars();
|
|
int mXPVBars = mXPVHelper.GetCalculatedBars();
|
|
int mXAMABars = mXAMAHelper.GetCalculatedBars();
|
|
int mXMRBBars = mXMRBHelper.GetCalculatedBars();
|
|
int mXCHEBars = mXCHEHelper.GetCalculatedBars();
|
|
int mXICHBars = mXICHHelper.GetCalculatedBars();
|
|
int mXTRNDBars = mXTRNDHelper.GetCalculatedBars();
|
|
int mXSSLCBars = mXSSLCHelper.GetCalculatedBars();
|
|
int mXHULLBars = mXHULLHelper.GetCalculatedBars();
|
|
|
|
//
|
|
int min = MathMin(mXCTBars, mXCCBars);
|
|
min = MathMin(min, mXHKBars);
|
|
min = MathMin(min, mXTMBars);
|
|
min = MathMin(min, mXPVBars);
|
|
min = MathMin(min, mXAMABars);
|
|
min = MathMin(min, mXMRBBars);
|
|
min = MathMin(min, mXCHEBars);
|
|
min = MathMin(min, mXICHBars);
|
|
min = MathMin(min, mXTRNDBars);
|
|
min = MathMin(min, mXSSLCBars);
|
|
min = MathMin(min, mXHULLBars);
|
|
|
|
//
|
|
int max = MathMax(mXCTBars, mXCCBars);
|
|
max = MathMax(max, mXHKBars);
|
|
max = MathMax(max, mXTMBars);
|
|
max = MathMax(max, mXPVBars);
|
|
max = MathMax(max, mXAMABars);
|
|
max = MathMax(max, mXMRBBars);
|
|
max = MathMax(max, mXCHEBars);
|
|
max = MathMax(max, mXICHBars);
|
|
max = MathMax(max, mXTRNDBars);
|
|
max = MathMax(max, mXSSLCBars);
|
|
max = MathMax(max, mXHULLBars);
|
|
|
|
//
|
|
result = min;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
virtual void ProcessBuffers()
|
|
{
|
|
UpdatePivotPoints();
|
|
}
|
|
|
|
//
|
|
virtual bool ProcessTick(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
if (CanIgnoreTick()) {
|
|
return false;
|
|
}
|
|
|
|
//
|
|
return ProcessSignals(conditions);
|
|
}
|
|
|
|
//
|
|
X121ProviderInputs GetConfig()
|
|
{
|
|
//
|
|
X121ProviderInputs result;
|
|
|
|
//
|
|
result = currentConfig;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool SetConfig(X121ProviderInputs &config)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
PrepareConfig(config);
|
|
|
|
//
|
|
result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool ResetDefaultConfig()
|
|
{
|
|
//
|
|
bool result = SetConfig(providedConfig);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool ShowCleanConfig()
|
|
{
|
|
//
|
|
currentConfig = cleanConfig;
|
|
|
|
//
|
|
bool result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool ShowDefaultConfig()
|
|
{
|
|
//
|
|
currentConfig = providedConfig;
|
|
|
|
//
|
|
bool result = Init();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// 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;
|
|
|
|
//
|
|
int remainedCandle = barIndex > 0
|
|
? barIndex - 1
|
|
: barIndex;
|
|
GetCandleRemainsTime(
|
|
result.barRemains,
|
|
mSymbol,
|
|
mPeriod,
|
|
remainedCandle);
|
|
|
|
//
|
|
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;
|
|
}
|
|
|
|
//
|
|
// TODO: Complete this ...
|
|
XOHCLSupRes GetSupportsAndResistances(
|
|
XSignal &signal, // Signal
|
|
int requirements = 10)
|
|
{
|
|
//
|
|
XOHCLSupRes result;
|
|
|
|
//
|
|
int totalBars = Bars(
|
|
mSymbol,
|
|
mPeriod);
|
|
|
|
//
|
|
int idx = 0;
|
|
|
|
//
|
|
while (
|
|
idx < totalBars - 17 ||
|
|
ArraySize(result.sup) < requirements ||
|
|
ArraySize(result.res) < requirements)
|
|
{
|
|
//
|
|
// Here we Try to Find Support and Resistances ...
|
|
|
|
//
|
|
idx++;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GuardCheck(XGuard &guards[])
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
Clean(guards);
|
|
|
|
//
|
|
// Implement Guards Check ...
|
|
|
|
//
|
|
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);
|
|
}
|
|
}
|
|
|
|
//
|
|
void ProccessPivotPoints()
|
|
{
|
|
//
|
|
if (mStartPivotScan)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
mStartPivotScan = true;
|
|
|
|
//
|
|
int maxLength = GetMaxLength();
|
|
int cBars = GetCalculatedBars();
|
|
int scanSize = cBars - maxLength - 1;
|
|
for (int i = 1; i < scanSize; i++)
|
|
{
|
|
//
|
|
UpdatePivotPoints(i);
|
|
|
|
//
|
|
int pivotsCount = CountPivots();
|
|
if (pivotsCount >= mMinPivots)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
int CountPivots()
|
|
{
|
|
//
|
|
int pivotSizes[];
|
|
int upZoneCount = ArraySize(upZonePivots);
|
|
if (upZoneCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
upZoneCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int downZoneCount = ArraySize(downZonePivots);
|
|
if (downZoneCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
downZoneCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int peaksCount = ArraySize(peaksPivots);
|
|
if (peaksCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
peaksCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int valesCount = ArraySize(valesPivots);
|
|
if (valesCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
valesCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int fibsCount = ArraySize(fiboPivots);
|
|
if (fibsCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
fibsCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int ichsCount = ArraySize(ichPivots);
|
|
if (ichsCount > 0)
|
|
{
|
|
//
|
|
Add(
|
|
ichsCount,
|
|
pivotSizes);
|
|
}
|
|
|
|
//
|
|
int result = ArraySize(pivotSizes) > 0
|
|
? pivotSizes[ArrayMaximum(pivotSizes)]
|
|
: 0;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// CCandle Timer ...
|
|
int mCTimerHandler;
|
|
|
|
//
|
|
// Signal Event Handlers ...
|
|
TOnSignalConditions mSignalConditionsEventHandlers[];
|
|
|
|
//
|
|
// Make Provided Config in Clean Style ...
|
|
void PrepareConfig(X121ProviderInputs &config)
|
|
{
|
|
//
|
|
cleanConfig = config;
|
|
|
|
//
|
|
// XCT ...
|
|
// Candle Timing ...
|
|
cleanConfig.xctConfig.showCandleTime = false;
|
|
|
|
//
|
|
// 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;
|
|
cleanConfig.xpvConfig.showFibo1Levels = false;
|
|
cleanConfig.xpvConfig.showFibo2Levels = false;
|
|
cleanConfig.xpvConfig.showFibo3Levels = 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;
|
|
|
|
//
|
|
providedConfig = config;
|
|
currentConfig = config;
|
|
}
|
|
|
|
//
|
|
int mMinPivots;
|
|
bool mStartPivotScan;
|
|
bool mDisableXPVFLong;
|
|
bool mDisableXPVFShort;
|
|
double mLastMomentumStep;
|
|
|
|
//
|
|
// Find Required Pivots for Support and Resistance ...
|
|
void UpdatePivotPoints(
|
|
int barIndex = 1 // Specified Candle ...
|
|
)
|
|
{
|
|
//
|
|
mXCTHelper.Calculate(barIndex);
|
|
mXCCHelper.Calculate(barIndex);
|
|
mXHKHelper.Calculate(barIndex);
|
|
mXTMHelper.Calculate(barIndex);
|
|
mXPVHelper.Calculate(barIndex);
|
|
mXAMAHelper.Calculate(barIndex);
|
|
mXMRBHelper.Calculate(barIndex);
|
|
mXCHEHelper.Calculate(barIndex);
|
|
mXICHHelper.Calculate(barIndex);
|
|
mXTRNDHelper.Calculate(barIndex);
|
|
mXSSLCHelper.Calculate(barIndex);
|
|
mXHULLHelper.Calculate(barIndex);
|
|
|
|
//
|
|
// Detect Peask and Vales Pivots ...
|
|
|
|
//
|
|
// Detect Hull Pivots ...
|
|
// find Hull Trend Changes ...
|
|
int idx = 1;
|
|
bool isHullUpChanged =
|
|
//
|
|
(
|
|
//
|
|
(XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx] == XHULL_STATE_BULLISH &&
|
|
(XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx + 1] != XHULL_STATE_BULLISH
|
|
//
|
|
)
|
|
//
|
|
||
|
|
//
|
|
(
|
|
//
|
|
(XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx] == XHULL_STATE_BEARISH &&
|
|
(XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx + 1] != XHULL_STATE_BEARISH
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHullDownChanged =
|
|
//
|
|
(
|
|
//
|
|
(XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx] == XHULL_STATE_BULLISH &&
|
|
(XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx + 1] != XHULL_STATE_BULLISH
|
|
//
|
|
)
|
|
//
|
|
||
|
|
//
|
|
(
|
|
//
|
|
(XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx] == XHULL_STATE_BEARISH &&
|
|
(XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx + 1] != XHULL_STATE_BEARISH
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Find Change State ...
|
|
if (isHullUpChanged ||
|
|
isHullDownChanged)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
mXHULLHelper.upBuffer[idx],
|
|
upZonePivots);
|
|
|
|
//
|
|
AddIfNotExists(
|
|
mXHULLHelper.downBuffer[idx],
|
|
downZonePivots);
|
|
}
|
|
|
|
//
|
|
// Find Momentom Step ...
|
|
if (isHullUpChanged &&
|
|
isHullDownChanged)
|
|
{
|
|
//
|
|
mLastMomentumStep = MathAbs(mXHULLHelper.upBuffer[idx] - mXHULLHelper.downBuffer[idx]);
|
|
mLastMomentumStep = NormalizePrice(
|
|
mLastMomentumStep,
|
|
mSymbol);
|
|
}
|
|
|
|
//
|
|
// Find Peaks and Vales ...
|
|
double selectedFib1 = mXPVHelper.fl1Buffer[idx];
|
|
double selectedFib2 = mXPVHelper.fl2Buffer[idx];
|
|
double selectedFib3 = mXPVHelper.fl3Buffer[idx];
|
|
double selectedPeak = mXPVHelper.peaksBuffer[idx];
|
|
double selectedVale = mXPVHelper.valesBuffer[idx];
|
|
|
|
//
|
|
double selectedTenkanSen = mXICHHelper.tenkanSenBuffer[idx];
|
|
double selectedKijunSen = mXICHHelper.kijunSenBuffer[idx];
|
|
|
|
//
|
|
int fib1Verified = 0;
|
|
int fib2Verified = 0;
|
|
int fib3Verified = 0;
|
|
int peaksVerified = 0;
|
|
int valesVerified = 0;
|
|
int kijunSenVerified = 0;
|
|
int tenkanSenVerified = 0;
|
|
int senkouSpanAVerified = 0;
|
|
int senkouSpanBVerified = 0;
|
|
for (int i = barIndex + 1; i < pvConsequences + barIndex + 1; i++)
|
|
{
|
|
//
|
|
int idx = i - barIndex;
|
|
|
|
//
|
|
// PEAKS and VALES ...
|
|
|
|
//
|
|
if (selectedPeak == mXPVHelper.peaksBuffer[idx])
|
|
{
|
|
peaksVerified++;
|
|
}
|
|
else
|
|
{
|
|
peaksVerified = 0;
|
|
}
|
|
|
|
//
|
|
if (selectedVale == mXPVHelper.valesBuffer[idx])
|
|
{
|
|
valesVerified++;
|
|
}
|
|
else
|
|
{
|
|
valesVerified = 0;
|
|
}
|
|
|
|
//
|
|
if (selectedFib1 == mXPVHelper.fl1Buffer[idx])
|
|
{
|
|
fib1Verified++;
|
|
}
|
|
else
|
|
{
|
|
fib1Verified = 0;
|
|
}
|
|
|
|
//
|
|
if (selectedFib2 == mXPVHelper.fl2Buffer[idx])
|
|
{
|
|
fib2Verified++;
|
|
}
|
|
else
|
|
{
|
|
fib2Verified = 0;
|
|
}
|
|
|
|
//
|
|
if (selectedFib3 == mXPVHelper.fl3Buffer[idx])
|
|
{
|
|
fib3Verified++;
|
|
}
|
|
else
|
|
{
|
|
fib3Verified = 0;
|
|
}
|
|
|
|
//
|
|
// ICHIMOKU Kinko Hyo ...
|
|
|
|
//
|
|
if (selectedTenkanSen == mXICHHelper.tenkanSenBuffer[idx])
|
|
{
|
|
tenkanSenVerified++;
|
|
}
|
|
else
|
|
{
|
|
tenkanSenVerified = 0;
|
|
}
|
|
|
|
//
|
|
if (selectedKijunSen == mXICHHelper.kijunSenBuffer[idx])
|
|
{
|
|
kijunSenVerified++;
|
|
}
|
|
else
|
|
{
|
|
kijunSenVerified++;
|
|
}
|
|
}
|
|
|
|
//
|
|
if (peaksVerified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedPeak,
|
|
peaksPivots);
|
|
}
|
|
|
|
//
|
|
if (valesVerified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedVale,
|
|
valesPivots);
|
|
}
|
|
|
|
//
|
|
if (fib1Verified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedFib1,
|
|
fiboPivots);
|
|
}
|
|
|
|
//
|
|
if (fib2Verified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedFib2,
|
|
fiboPivots);
|
|
}
|
|
|
|
//
|
|
if (fib3Verified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedFib3,
|
|
fiboPivots);
|
|
}
|
|
|
|
//
|
|
if (tenkanSenVerified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedTenkanSen,
|
|
ichPivots);
|
|
}
|
|
|
|
//
|
|
if (kijunSenVerified >= pvConsequences)
|
|
{
|
|
//
|
|
AddIfNotExists(
|
|
selectedKijunSen,
|
|
ichPivots);
|
|
}
|
|
|
|
// //
|
|
// if (senkouSpanAVerified >= pvConsequences)
|
|
// {
|
|
// //
|
|
// AddIfNotExists(
|
|
// selectedSenkouSpanA,
|
|
// ichPivots);
|
|
// }
|
|
|
|
// //
|
|
// if (senkouSpanBVerified >= pvConsequences)
|
|
// {
|
|
// //
|
|
// AddIfNotExists(
|
|
// selectedSenkouSpanB,
|
|
// ichPivots);
|
|
// }
|
|
}
|
|
|
|
//
|
|
void FillPivotPoints(
|
|
double &result[])
|
|
{
|
|
//
|
|
Clean(result);
|
|
|
|
//
|
|
int pCount = CountPivots();
|
|
if (pCount <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
upZonePivots,
|
|
result);
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
downZonePivots,
|
|
result);
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
peaksPivots,
|
|
result);
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
valesPivots,
|
|
result);
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
fiboPivots,
|
|
result);
|
|
|
|
//
|
|
AddsIfNotExists(
|
|
ichPivots,
|
|
result);
|
|
}
|
|
|
|
//
|
|
// Here we are Capture Conditions and Check Signals ...
|
|
// The Signals Must be Unique for each providers ...
|
|
bool ProcessSignals(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
X121MarketConditions mConditions = GetMarketConditions(1);
|
|
|
|
//
|
|
// BUY ...
|
|
|
|
//
|
|
Clean(mConditions.signal);
|
|
bool hasLongSignal = HasLongSignal(mConditions);
|
|
if (hasLongSignal)
|
|
{
|
|
//
|
|
NotifyOnSignalEvent(
|
|
mConditions.signal);
|
|
NotifyOnSignalConditionsEvent(mConditions);
|
|
mWaitUntilNewCandle = true;
|
|
|
|
//
|
|
conditions = mConditions;
|
|
return true;
|
|
}
|
|
|
|
//
|
|
// SELL ...
|
|
|
|
//
|
|
Clean(mConditions.signal);
|
|
bool hasShortignal = HasShortSignal(mConditions);
|
|
if (hasShortignal)
|
|
{
|
|
//
|
|
NotifyOnSignalEvent(
|
|
mConditions.signal);
|
|
NotifyOnSignalConditionsEvent(mConditions);
|
|
mWaitUntilNewCandle = true;
|
|
|
|
//
|
|
conditions = mConditions;
|
|
return true;
|
|
}
|
|
|
|
//
|
|
return false;
|
|
}
|
|
|
|
//
|
|
// Check has Long Signal on Each Strategies ...
|
|
bool HasLongSignal(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
double entry = GetEntry(
|
|
mSymbol,
|
|
POSITION_TYPE_BUY);
|
|
|
|
//
|
|
XOHCL c1 = GetCandle(
|
|
mSymbol,
|
|
mPeriod,
|
|
1);
|
|
|
|
//
|
|
double pivots[];
|
|
FillPivotPoints(pivots);
|
|
XOHCLSupRes supRes = ExtractSupportAndResistance(
|
|
1,
|
|
pivots,
|
|
15);
|
|
X121MarketConditions mConditions = GetMarketConditions(1);
|
|
|
|
//
|
|
mXPVHelper.Calculate(1);
|
|
|
|
//
|
|
Clean(mConditions.signal);
|
|
|
|
//
|
|
// XPVF Signal Provider ...
|
|
bool xPVFSignal = false;
|
|
if (!mDisableXPVFLong)
|
|
{
|
|
//
|
|
xPVFSignal =
|
|
//
|
|
mConditions.xpvInfo.isNewPeak &&
|
|
mXPVHelper.peaksBuffer[0] < mXPVHelper.peaksBuffer[1] &&
|
|
mXPVHelper.valesBuffer[0] == mXPVHelper.valesBuffer[1]
|
|
//
|
|
;
|
|
|
|
//
|
|
if (xPVFSignal)
|
|
{
|
|
//
|
|
Add(
|
|
ToString(XPVF),
|
|
mConditions.signal.providers);
|
|
|
|
//
|
|
mConditions.signal.r2r = 1.5;
|
|
mConditions.signal.riskAmount = 0.005;
|
|
mConditions.signal.mode = X_ORDER_MODE_MARKET;
|
|
mConditions.signal.entry = entry;
|
|
mConditions.signal.sl = 0; // mXCHEHelper.longExit2[1];
|
|
mConditions.signal.tp = 0;
|
|
|
|
//
|
|
// mConditions.signal.calculateTP = true;
|
|
// mConditions.signal.useRiskAmountAsVolume = false;
|
|
// mConditions.signal.useSupportAndResistance = true;
|
|
|
|
//
|
|
// mDisableXPVFLong = true;
|
|
// mDisableXPVFShort = false;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
xPVFSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
conditions = mConditions;
|
|
|
|
//
|
|
conditions.supportResistances = supRes;
|
|
conditions.momentumStep = mLastMomentumStep;
|
|
|
|
//
|
|
conditions.signal.symbol = mSymbol;
|
|
conditions.signal.period = mPeriod;
|
|
conditions.signal.type = POSITION_TYPE_BUY;
|
|
|
|
//
|
|
conditions.hasSignal = true;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check has Short Signal on Each Strategies ...
|
|
bool HasShortSignal(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
double entry = GetEntry(
|
|
mSymbol,
|
|
POSITION_TYPE_SELL);
|
|
|
|
//
|
|
XOHCL c1 = GetCandle(
|
|
mSymbol,
|
|
mPeriod,
|
|
1);
|
|
|
|
//
|
|
double pivots[];
|
|
FillPivotPoints(pivots);
|
|
XOHCLSupRes supRes = ExtractSupportAndResistance(
|
|
1,
|
|
pivots,
|
|
15);
|
|
|
|
//
|
|
X121MarketConditions mConditions = GetMarketConditions(1);
|
|
|
|
//
|
|
mXPVHelper.Calculate(1);
|
|
|
|
//
|
|
Clean(mConditions.signal);
|
|
|
|
//
|
|
// XPVF Signal Provider ...
|
|
bool xPVFSignal = false;
|
|
if (!mDisableXPVFShort)
|
|
{
|
|
//
|
|
xPVFSignal =
|
|
//
|
|
mConditions.xpvInfo.isNewVale &&
|
|
mXPVHelper.valesBuffer[0] > mXPVHelper.valesBuffer[1] &&
|
|
mXPVHelper.peaksBuffer[0] == mXPVHelper.peaksBuffer[1]
|
|
//
|
|
;
|
|
|
|
//
|
|
if (xPVFSignal)
|
|
{
|
|
//
|
|
Add(
|
|
ToString(XPVF),
|
|
mConditions.signal.providers);
|
|
|
|
//
|
|
mConditions.signal.r2r = 1.5;
|
|
mConditions.signal.riskAmount = 0.005;
|
|
mConditions.signal.mode = X_ORDER_MODE_STOP;
|
|
mConditions.signal.entry = entry;
|
|
mConditions.signal.sl = 0;
|
|
mConditions.signal.tp = mXPVHelper.valesBuffer[1];
|
|
|
|
//
|
|
mConditions.signal.calculateTP = true;
|
|
mConditions.signal.useRiskAmountAsVolume = false;
|
|
mConditions.signal.useSupportAndResistance = true;
|
|
|
|
//
|
|
// mDisableXPVFShort = true;
|
|
// mDisableXPVFLong = false;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
xPVFSignal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
conditions = mConditions;
|
|
|
|
//
|
|
conditions.supportResistances = supRes;
|
|
conditions.momentumStep = mLastMomentumStep;
|
|
|
|
//
|
|
conditions.signal.symbol = mSymbol;
|
|
conditions.signal.period = mPeriod;
|
|
conditions.signal.type = POSITION_TYPE_SELL;
|
|
|
|
//
|
|
conditions.hasSignal = true;
|
|
}
|
|
|
|
//
|
|
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;
|
|
}
|
|
|
|
//
|
|
// Converts a Signal provider to String ...
|
|
string ToString(ENUM_X121_SIGNAL_PROVIDERS provider)
|
|
{
|
|
return EnumToString(provider);
|
|
}
|
|
|
|
//
|
|
// convert an String to Signal provider ...
|
|
ENUM_X121_SIGNAL_PROVIDERS ToProvider(string provider)
|
|
{
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS result = NONE;
|
|
|
|
//
|
|
if (ToString(NONE) == provider)
|
|
{
|
|
result = NONE;
|
|
}
|
|
else if (ToString(XPVF) == provider)
|
|
{
|
|
result = XPVF;
|
|
}
|
|
else if (ToString(XCHNL) == provider)
|
|
{
|
|
result = XCHNL;
|
|
}
|
|
else if (ToString(XTRND) == provider)
|
|
{
|
|
result = XTRND;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Extract Provider Type from Signal Commnet ...
|
|
ENUM_X121_SIGNAL_PROVIDERS ExtractPositionProvider(XPosition &position)
|
|
{
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS result = NONE;
|
|
|
|
//
|
|
string providerStr =
|
|
ExtractString(
|
|
position.comment,
|
|
XProviderToken + "(",
|
|
")");
|
|
if (StringLen(providerStr) <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = ToProvider(providerStr);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Generate Provider String for Using in Positions Comment ...
|
|
// NOTE: if there is more than One Provider, it takes first
|
|
// provider as main and the others used to increase volume ...
|
|
string GenerateProvidersString(XSignal &signal)
|
|
{
|
|
//
|
|
string result = "";
|
|
|
|
//
|
|
int providersCount = ArraySize(signal.providers);
|
|
if (providersCount <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = XProviderToken + "(" + signal.providers[0] + ")";
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// END Usefull Functions ...
|
|
//
|