4782 lines
115 KiB
Plaintext
4782 lines
115 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSC121Provider
|
|
// Description: provides all Base Provider
|
|
// requirements For X121 ...
|
|
//
|
|
//
|
|
// 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
|
|
|
|
//
|
|
// Imports ...
|
|
|
|
//
|
|
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xmc.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xdon.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xzg.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xpv.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xstr.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xche.helper.mq5"
|
|
#include "../Helpers/x-saherelm.xosc.helper.mq5"
|
|
|
|
//
|
|
#include "../Classes/x-saherelm.xprovider.class.mq5"
|
|
#include "../Classes/x-saherelm.x121.xmcycle.class.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Signallers ...
|
|
enum ENUM_X121_SIGNAL_PROVIDERS
|
|
{
|
|
//
|
|
X121NONE,
|
|
X121XSP,
|
|
XTEST,
|
|
X786,
|
|
X121,
|
|
X110,
|
|
X92,
|
|
X128,
|
|
};
|
|
|
|
//
|
|
// X121 Provider Inputs ...
|
|
class X121ProviderInputs : public XSCBaseProviderInpts
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
string symbol;
|
|
ENUM_TIMEFRAMES period;
|
|
|
|
//
|
|
// S Market ...
|
|
ENUM_TIMEFRAMES sMarketPeriod; // Short Market Period
|
|
ENUM_X_PERIOD_METHOD sMarketMethod; // Short Market Period Method
|
|
string sMarketPrefix; // Short Market Prefix
|
|
|
|
//
|
|
// MEDIUM Market ...
|
|
ENUM_TIMEFRAMES mMarketPeriod; // Medium Market Period
|
|
ENUM_X_PERIOD_METHOD mMarketMethod; // Medium Market Period Method
|
|
string mMarketPrefix; // Medium Market Prefix
|
|
|
|
//
|
|
// LONG Market ...
|
|
ENUM_TIMEFRAMES lMarketPeriod; // Long Market Period
|
|
ENUM_X_PERIOD_METHOD lMarketMethod; // Long Market Period Method
|
|
string lMarketPrefix; // Long Market Prefix
|
|
|
|
//
|
|
// HIND Market ...
|
|
ENUM_TIMEFRAMES hMarketPeriod; // Hind Market Period
|
|
ENUM_X_PERIOD_METHOD hMarketMethod; // Hind Market Period Method
|
|
string hMarketPrefix; // Hind Market Prefix
|
|
|
|
//
|
|
// Indicators ...
|
|
XCCInputs ccInputs;
|
|
XCTInputs ctInputs;
|
|
XZGInputs zgInputs;
|
|
XPVInputs pvInputs;
|
|
XMCInputs mcInputs;
|
|
XICHInputs ichInputs;
|
|
XCHEInputs cheInputs;
|
|
XSTRInputs strInputs;
|
|
XDONInputs donInputs;
|
|
XOSCInputs oscInputs;
|
|
|
|
//
|
|
X121MCycleInputs cMarketInputs; // Curent Market Inputs
|
|
X121MCycleInputs sMarketInputs; // Short Market Inputs
|
|
X121MCycleInputs mMarketInputs; // Medium Market Inputs
|
|
X121MCycleInputs lMarketInputs; // Long Market Inputs
|
|
X121MCycleInputs hMarketInputs; // Hind Market Inputs
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Initialize Input ...
|
|
bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Base Requirements ...
|
|
result =
|
|
//
|
|
IsSpecifiedValid(symbol) &&
|
|
IsSpecifiedValid(period) &&
|
|
IsSpecifiedValid(sMarketMethod, sMarketPeriod) &&
|
|
IsSpecifiedValid(mMarketMethod, mMarketPeriod) &&
|
|
IsSpecifiedValid(lMarketMethod, lMarketPeriod) &&
|
|
IsSpecifiedValid(hMarketMethod, hMarketPeriod)
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (!zgInputs.IsValid())
|
|
{
|
|
zgInputs.Default();
|
|
}
|
|
if (!pvInputs.IsValid())
|
|
{
|
|
pvInputs.Default();
|
|
}
|
|
if (!mcInputs.IsValid())
|
|
{
|
|
mcInputs.Default();
|
|
}
|
|
if (!cheInputs.IsValid())
|
|
{
|
|
cheInputs.Default();
|
|
}
|
|
if (!strInputs.IsValid())
|
|
{
|
|
strInputs.Default();
|
|
}
|
|
if (!donInputs.IsValid())
|
|
{
|
|
donInputs.Default();
|
|
}
|
|
if (!oscInputs.IsValid())
|
|
{
|
|
oscInputs.Default();
|
|
}
|
|
if (!ichInputs.IsValid())
|
|
{
|
|
ichInputs.Default();
|
|
}
|
|
|
|
// //
|
|
// if (!cMarketInputs.IsValid())
|
|
// {
|
|
// cMarketInputs.Default();
|
|
// }
|
|
// if (!sMarketInputs.IsValid())
|
|
// {
|
|
// sMarketInputs.Default();
|
|
// }
|
|
// if (!mMarketInputs.IsValid())
|
|
// {
|
|
// mMarketInputs.Default();
|
|
// }
|
|
// if (!lMarketInputs.IsValid())
|
|
// {
|
|
// lMarketInputs.Default();
|
|
// }
|
|
// if (!hMarketInputs.IsValid())
|
|
// {
|
|
// hMarketInputs.Default();
|
|
// }
|
|
|
|
//
|
|
// Initialize Market Inputs ...
|
|
|
|
//
|
|
// Current ...
|
|
cMarketInputs.pvInputs = this.pvInputs;
|
|
cMarketInputs.zgInputs = this.zgInputs;
|
|
cMarketInputs.mcInputs = this.mcInputs;
|
|
cMarketInputs.strInputs = this.strInputs;
|
|
cMarketInputs.oscInputs = this.oscInputs;
|
|
cMarketInputs.cheInputs = this.cheInputs;
|
|
cMarketInputs.ichInputs = this.ichInputs;
|
|
cMarketInputs.donInputs = this.donInputs;
|
|
result = cMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_SHORT,
|
|
this.period,
|
|
X_PERIOD_MANUALLY,
|
|
"HOST",
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
sMarketInputs.pvInputs = this.pvInputs;
|
|
sMarketInputs.zgInputs = this.zgInputs;
|
|
sMarketInputs.mcInputs = this.mcInputs;
|
|
sMarketInputs.strInputs = this.strInputs;
|
|
sMarketInputs.oscInputs = this.oscInputs;
|
|
sMarketInputs.cheInputs = this.cheInputs;
|
|
sMarketInputs.ichInputs = this.ichInputs;
|
|
sMarketInputs.donInputs = this.donInputs;
|
|
result = sMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_SHORT,
|
|
this.sMarketPeriod,
|
|
this.sMarketMethod,
|
|
this.sMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Medium ...
|
|
mMarketInputs.pvInputs = this.pvInputs;
|
|
mMarketInputs.zgInputs = this.zgInputs;
|
|
mMarketInputs.mcInputs = this.mcInputs;
|
|
mMarketInputs.strInputs = this.strInputs;
|
|
mMarketInputs.oscInputs = this.oscInputs;
|
|
mMarketInputs.cheInputs = this.cheInputs;
|
|
mMarketInputs.ichInputs = this.ichInputs;
|
|
mMarketInputs.donInputs = this.donInputs;
|
|
result = mMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_MEDIUM,
|
|
this.mMarketPeriod,
|
|
this.mMarketMethod,
|
|
this.mMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Long ...
|
|
lMarketInputs.pvInputs = this.pvInputs;
|
|
lMarketInputs.zgInputs = this.zgInputs;
|
|
lMarketInputs.mcInputs = this.mcInputs;
|
|
lMarketInputs.strInputs = this.strInputs;
|
|
lMarketInputs.oscInputs = this.oscInputs;
|
|
lMarketInputs.cheInputs = this.cheInputs;
|
|
lMarketInputs.ichInputs = this.ichInputs;
|
|
lMarketInputs.donInputs = this.donInputs;
|
|
result = lMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_LONG,
|
|
this.lMarketPeriod,
|
|
this.lMarketMethod,
|
|
this.lMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Hind ...
|
|
hMarketInputs.pvInputs = this.pvInputs;
|
|
hMarketInputs.zgInputs = this.zgInputs;
|
|
hMarketInputs.mcInputs = this.mcInputs;
|
|
hMarketInputs.strInputs = this.strInputs;
|
|
hMarketInputs.oscInputs = this.oscInputs;
|
|
hMarketInputs.cheInputs = this.cheInputs;
|
|
hMarketInputs.ichInputs = this.ichInputs;
|
|
hMarketInputs.donInputs = this.donInputs;
|
|
result = hMarketInputs.Init(
|
|
this.symbol,
|
|
this.period,
|
|
X_MARKET_CYCLE_HIND,
|
|
this.hMarketPeriod,
|
|
this.hMarketMethod,
|
|
this.hMarketPrefix,
|
|
false //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = IsValid();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Validate Input ...
|
|
bool IsValid() override
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
//
|
|
IsSpecifiedValid(symbol) &&
|
|
IsSpecifiedValid(period) &&
|
|
IsSpecifiedValid(sMarketMethod, sMarketPeriod) &&
|
|
IsSpecifiedValid(mMarketMethod, mMarketPeriod) &&
|
|
IsSpecifiedValid(lMarketMethod, lMarketPeriod) &&
|
|
IsSpecifiedValid(hMarketMethod, hMarketPeriod) &&
|
|
//
|
|
ccInputs.IsValid() &&
|
|
ctInputs.IsValid() &&
|
|
zgInputs.IsValid() &&
|
|
pvInputs.IsValid() &&
|
|
mcInputs.IsValid() &&
|
|
cheInputs.IsValid() &&
|
|
strInputs.IsValid() &&
|
|
donInputs.IsValid() &&
|
|
oscInputs.IsValid() &&
|
|
ichInputs.IsValid() &&
|
|
//
|
|
cMarketInputs.IsValid() &&
|
|
sMarketInputs.IsValid() &&
|
|
mMarketInputs.IsValid() &&
|
|
lMarketInputs.IsValid() &&
|
|
hMarketInputs.IsValid()
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean() override
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
sMarketPeriod = NULL;
|
|
sMarketMethod = X_PERIOD_NOTHING;
|
|
sMarketPrefix = NULL;
|
|
|
|
//
|
|
mMarketPeriod = NULL;
|
|
mMarketMethod = X_PERIOD_NOTHING;
|
|
mMarketPrefix = NULL;
|
|
|
|
//
|
|
lMarketPeriod = NULL;
|
|
lMarketMethod = X_PERIOD_NOTHING;
|
|
lMarketPrefix = NULL;
|
|
|
|
//
|
|
hMarketPeriod = NULL;
|
|
hMarketMethod = X_PERIOD_NOTHING;
|
|
hMarketPrefix = NULL;
|
|
|
|
//
|
|
ccInputs.Clean();
|
|
ctInputs.Clean();
|
|
zgInputs.Clean();
|
|
pvInputs.Clean();
|
|
mcInputs.Clean();
|
|
cheInputs.Clean();
|
|
strInputs.Clean();
|
|
donInputs.Clean();
|
|
oscInputs.Clean();
|
|
ichInputs.Clean();
|
|
//
|
|
cMarketInputs.Clean();
|
|
sMarketInputs.Clean();
|
|
mMarketInputs.Clean();
|
|
lMarketInputs.Clean();
|
|
hMarketInputs.Clean();
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default() override
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
sMarketPeriod = NULL;
|
|
sMarketMethod = X_PERIOD_AUTO;
|
|
sMarketPrefix = NULL;
|
|
|
|
//
|
|
mMarketPeriod = NULL;
|
|
mMarketMethod = X_PERIOD_AUTO;
|
|
mMarketPrefix = NULL;
|
|
|
|
//
|
|
lMarketPeriod = NULL;
|
|
lMarketMethod = X_PERIOD_AUTO;
|
|
lMarketPrefix = NULL;
|
|
|
|
//
|
|
hMarketPeriod = NULL;
|
|
hMarketMethod = X_PERIOD_AUTO;
|
|
hMarketPrefix = NULL;
|
|
|
|
//
|
|
ccInputs.Default();
|
|
ctInputs.Default();
|
|
zgInputs.Default();
|
|
pvInputs.Default();
|
|
mcInputs.Default();
|
|
cheInputs.Default();
|
|
strInputs.Default();
|
|
donInputs.Default();
|
|
oscInputs.Default();
|
|
ichInputs.Default();
|
|
cMarketInputs.Default();
|
|
sMarketInputs.Default();
|
|
mMarketInputs.Default();
|
|
lMarketInputs.Default();
|
|
hMarketInputs.Default();
|
|
}
|
|
|
|
//
|
|
// Max ...
|
|
int Max() override
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Symbol ...
|
|
bool SetSymbol(string value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsSpecifiedValid(value);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
symbol = value;
|
|
cMarketInputs.cycle.symbol = value;
|
|
sMarketInputs.cycle.symbol = value;
|
|
mMarketInputs.cycle.symbol = value;
|
|
lMarketInputs.cycle.symbol = value;
|
|
hMarketInputs.cycle.symbol = value;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Period ...
|
|
bool SetPeriod(ENUM_TIMEFRAMES value)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = IsSpecifiedValid(value);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
period = value;
|
|
cMarketInputs.cycle.period = value;
|
|
sMarketInputs.cycle.period = value;
|
|
mMarketInputs.cycle.period = value;
|
|
lMarketInputs.cycle.period = value;
|
|
hMarketInputs.cycle.period = value;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// X121 Provider Market Conditions ...
|
|
class X121MarketConditions : public XSCBaseProviderMarketConditions
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
X121MCycleConditions cMarketConditions; // Current Market Conditions
|
|
X121MCycleConditions sMarketConditions; // Short Market Conditions
|
|
X121MCycleConditions mMarketConditions; // Medium Market Conditions
|
|
X121MCycleConditions lMarketConditions; // Long Market Conditions
|
|
X121MCycleConditions hMarketConditions; // Hind Market Conditions
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clear()
|
|
{
|
|
//
|
|
symbol = NULL;
|
|
period = NULL;
|
|
|
|
//
|
|
Clean(bars);
|
|
|
|
//
|
|
ArraySetAsSeries(bars, true);
|
|
|
|
//
|
|
cMarketConditions.Clear();
|
|
sMarketConditions.Clear();
|
|
mMarketConditions.Clear();
|
|
lMarketConditions.Clear();
|
|
hMarketConditions.Clear();
|
|
}
|
|
|
|
//
|
|
void GenerateScore(
|
|
double &bullishScore, // Bullish Score
|
|
double &bearishScore, // Bearish Score
|
|
double cMarketMultiplier = 1, // Current Market Score Multiplier
|
|
double sMarketMultiplier = 1.1, // Short Market Score Multiplier
|
|
double mMarketMultiplier = 1.2, // Medium Market Score Multiplier
|
|
double lMarketMultiplier = 1.6, // Long Market Score Multiplier
|
|
double hMarketMultiplier = 1.8 // Hind Market Score Multiplier
|
|
)
|
|
{
|
|
//
|
|
// Current Market ...
|
|
double cMarketBullScore = 0;
|
|
double cMarketBearScore = 0;
|
|
cMarketConditions.GenerateScore(
|
|
cMarketBullScore,
|
|
cMarketBearScore,
|
|
cMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Short Market ...
|
|
double sMarketBullScore = 0;
|
|
double sMarketBearScore = 0;
|
|
sMarketConditions.GenerateScore(
|
|
sMarketBullScore,
|
|
sMarketBearScore,
|
|
sMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Medium Market ...
|
|
double mMarketBullScore = 0;
|
|
double mMarketBearScore = 0;
|
|
mMarketConditions.GenerateScore(
|
|
mMarketBullScore,
|
|
mMarketBearScore,
|
|
mMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Long Market ...
|
|
double lMarketBullScore = 0;
|
|
double lMarketBearScore = 0;
|
|
lMarketConditions.GenerateScore(
|
|
lMarketBullScore,
|
|
lMarketBearScore,
|
|
lMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Hind Market ...
|
|
double hMarketBullScore = 0;
|
|
double hMarketBearScore = 0;
|
|
hMarketConditions.GenerateScore(
|
|
hMarketBullScore,
|
|
hMarketBearScore,
|
|
hMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
// Calculate Summary Scores ...
|
|
|
|
//
|
|
bullishScore =
|
|
//
|
|
cMarketBullScore +
|
|
sMarketBullScore +
|
|
mMarketBullScore +
|
|
lMarketBullScore +
|
|
hMarketBullScore
|
|
//
|
|
;
|
|
|
|
//
|
|
bearishScore =
|
|
//
|
|
cMarketBearScore +
|
|
sMarketBearScore +
|
|
mMarketBearScore +
|
|
lMarketBearScore +
|
|
hMarketBearScore
|
|
//
|
|
;
|
|
}
|
|
|
|
//
|
|
virtual string GenerateSummary(
|
|
const bool onlySummary = false, // Only Generate Conditions Summary
|
|
double cMarketMultiplier = 1, // Current Market Score Multiplier
|
|
double sMarketMultiplier = 1.1, // Short Market Score Multiplier
|
|
double mMarketMultiplier = 1.2, // Medium Market Score Multiplier
|
|
double lMarketMultiplier = 1.6, // Long Market Score Multiplier
|
|
double hMarketMultiplier = 1.8, // Hind Market Score Multiplier
|
|
const string separator = "\n", // Separator
|
|
string provided = NULL, // Additional Info about Type, Provider and Symbol
|
|
const bool ignoreFalseConditions = true // Ignore False Conditions
|
|
)
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
double bullScore = 0;
|
|
double bearScore = 0;
|
|
GenerateScore(
|
|
bullScore,
|
|
bearScore,
|
|
cMarketMultiplier,
|
|
sMarketMultiplier,
|
|
mMarketMultiplier,
|
|
lMarketMultiplier,
|
|
hMarketMultiplier //
|
|
);
|
|
|
|
//
|
|
string commonStr =
|
|
//
|
|
"Commons: " + separator +
|
|
"-----------------------------" + separator +
|
|
"Symbol: " + symbol + separator +
|
|
"Period: " + ToString(period) + separator +
|
|
"Time: " + ToString(TimeCurrent()) + separator +
|
|
"-----------" + separator +
|
|
"Cycles: " + separator +
|
|
"-----------" + separator +
|
|
sMarketConditions.GetTitle() + separator +
|
|
mMarketConditions.GetTitle() + separator +
|
|
lMarketConditions.GetTitle() + separator +
|
|
hMarketConditions.GetTitle() + separator +
|
|
"-----------" + separator +
|
|
"Scores: " + separator +
|
|
"-----------" + separator +
|
|
"Bullish: " + ToString(bullScore) + separator +
|
|
"Bearish: " + ToString(bearScore) + separator +
|
|
"-----------------------------" + separator +
|
|
//
|
|
// TODO: Add Scores Later ...
|
|
separator +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
string cMarketConditionsStr = cMarketConditions.GenerateSummary(onlySummary, cMarketMultiplier);
|
|
string sMarketConditionsStr = sMarketConditions.GenerateSummary(onlySummary, sMarketMultiplier);
|
|
string mMarketConditionsStr = mMarketConditions.GenerateSummary(onlySummary, mMarketMultiplier);
|
|
string lMarketConditionsStr = lMarketConditions.GenerateSummary(onlySummary, lMarketMultiplier);
|
|
string hMarketConditionsStr = hMarketConditions.GenerateSummary(onlySummary, hMarketMultiplier);
|
|
|
|
//
|
|
result =
|
|
//
|
|
"[" + GetToken() + "]" + separator +
|
|
(IsSpecifiedValid(provided) ? provided + separator : "") +
|
|
"-----------------------------" + separator +
|
|
commonStr +
|
|
(!onlySummary
|
|
? cMarketConditionsStr +
|
|
sMarketConditionsStr +
|
|
mMarketConditionsStr +
|
|
lMarketConditionsStr +
|
|
hMarketConditionsStr +
|
|
""
|
|
: "") +
|
|
""
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// For Data Collector ...
|
|
string GetToken()
|
|
{
|
|
return GetSpecificToken(this);
|
|
}
|
|
bool IsModelValid()
|
|
{
|
|
return false;
|
|
}
|
|
string ToModelString()
|
|
{
|
|
return NULL;
|
|
}
|
|
bool ParseModel(string content)
|
|
{
|
|
return false;
|
|
}
|
|
int FindIndex(X121MarketConditions &items[])
|
|
{
|
|
return -1;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
|
|
//
|
|
// X121 Provider Class ...
|
|
class XSCX121Provider : public XSCBaseProvider
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XSCXCCHelper *ccHelper; // Candle Clear
|
|
XSCXCTHelper *ctHelper; // Candle Timer
|
|
|
|
//
|
|
XSCX121Market *cMarket; // Current Market
|
|
XSCX121Market *sMarket; // Short Market
|
|
XSCX121Market *mMarket; // Medium Market
|
|
XSCX121Market *lMarket; // Long Market
|
|
XSCX121Market *hMarket; // Hind Market
|
|
|
|
//
|
|
// Constructor ...
|
|
XSCX121Provider(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period // Trading PEriod
|
|
) : XSCBaseProvider(symbol, period)
|
|
{
|
|
//
|
|
ccHelper = new XSCXCCHelper();
|
|
ctHelper = new XSCXCTHelper();
|
|
|
|
//
|
|
// Instantiate X121 Market Cycles Classes ...
|
|
cMarket = new XSCX121Market();
|
|
sMarket = new XSCX121Market();
|
|
mMarket = new XSCX121Market();
|
|
lMarket = new XSCX121Market();
|
|
hMarket = new XSCX121Market();
|
|
|
|
//
|
|
mNumberOfItems = 15;
|
|
mNumberOfSRVerified = 71;
|
|
mMinRequiredSupportAndResistances = 30;
|
|
}
|
|
|
|
//
|
|
// Properties Gettr(s) / Setter(s) ...
|
|
|
|
//
|
|
void SetNumberOfSRVerified(int value)
|
|
{
|
|
mNumberOfSRVerified = value;
|
|
}
|
|
|
|
//
|
|
int GetNumberOfSRVerified()
|
|
{
|
|
return mNumberOfSRVerified;
|
|
}
|
|
|
|
//
|
|
void SetNumberOfItems(int value)
|
|
{
|
|
mNumberOfItems = value;
|
|
}
|
|
|
|
//
|
|
int GetNumberOfItems()
|
|
{
|
|
return mNumberOfItems;
|
|
}
|
|
|
|
//
|
|
void SetMinRequiredSupportAndResistances(int value)
|
|
{
|
|
mMinRequiredSupportAndResistances = value;
|
|
}
|
|
|
|
//
|
|
int GetMinRequiredSupportAndResistances()
|
|
{
|
|
return mMinRequiredSupportAndResistances;
|
|
}
|
|
|
|
//
|
|
// Overrides ...
|
|
|
|
//
|
|
// DeInit all Requirements ...
|
|
void DeInit() override
|
|
{
|
|
//
|
|
delete ccHelper;
|
|
delete ctHelper;
|
|
|
|
//
|
|
delete cMarket;
|
|
delete sMarket;
|
|
delete mMarket;
|
|
delete lMarket;
|
|
delete hMarket;
|
|
}
|
|
|
|
//
|
|
// Functions ...
|
|
|
|
//
|
|
// Init all Requirements ...
|
|
bool Init(X121ProviderInputs &inputs)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate ...
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
string mSymbol = GetSymbol();
|
|
ENUM_TIMEFRAMES mPeriod = GetPeriod();
|
|
|
|
//
|
|
// Init Indicators Helpers ...
|
|
|
|
//
|
|
// CT ...
|
|
result = ctHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.ctInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// CC ...
|
|
result = ccHelper
|
|
.Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
mInputs.ccInputs
|
|
//
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Initialize X121 Market Cycles ...
|
|
|
|
//
|
|
// Current Market ...
|
|
result = cMarket
|
|
.Init(mInputs.cMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Short Market ...
|
|
result = sMarket
|
|
.Init(mInputs.sMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Medium Market ...
|
|
result = mMarket
|
|
.Init(mInputs.mMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Long Market ...
|
|
result = lMarket
|
|
.Init(mInputs.lMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Hind Market ...
|
|
result = hMarket
|
|
.Init(mInputs.hMarketInputs);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Set Default Position's Type ...
|
|
// Enable / Disable Long (Buy), Short (Sell) ...
|
|
void SetSignalTypeState(
|
|
ENUM_POSITION_TYPE type, // Which types are Signals be Targetted
|
|
bool state // Which State is going to Set
|
|
)
|
|
{
|
|
//
|
|
if (IsLong(type))
|
|
{
|
|
mIsLongEnable = state;
|
|
}
|
|
else
|
|
{
|
|
mIsShortEnable = state;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Set Signal Providers ...
|
|
void SetSignalProviderState(
|
|
ENUM_X121_SIGNAL_PROVIDERS provider, // Provider State
|
|
bool state // Which state is going to set ...
|
|
)
|
|
{
|
|
//
|
|
if (provider == X121NONE)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
switch (provider)
|
|
{
|
|
//
|
|
case X121XSP:
|
|
mIsX121XSPSignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case XTEST:
|
|
mIsXTESTSignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X786:
|
|
mIsX786SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X121:
|
|
mIsX121SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X110:
|
|
mIsX110SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X92:
|
|
mIsX92SignalProviderEnable = state;
|
|
break;
|
|
|
|
//
|
|
case X128:
|
|
mIsX128SignalProviderEnable = state;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
void SetSignalProviderStates(
|
|
ENUM_X121_SIGNAL_PROVIDERS &providers[], // Collection of Providers ...
|
|
bool state // Which state is going to set ...
|
|
)
|
|
{
|
|
//
|
|
int providersCount = ArraySize(providers);
|
|
if (providersCount <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < providersCount; i++)
|
|
{
|
|
SetSignalProviderState(providers[i], state);
|
|
}
|
|
}
|
|
|
|
//
|
|
string GetTag()
|
|
{
|
|
//
|
|
string result = NULL;
|
|
|
|
//
|
|
result =
|
|
//
|
|
GetToken() +
|
|
"[" +
|
|
GetSymbol() +
|
|
"," +
|
|
ToString(GetPeriod()) +
|
|
"]"
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void GetMarketConditions(
|
|
X121MarketConditions &mConditions, // Market Conditions Result
|
|
int barIndex = 0 // Specified Bar Index
|
|
)
|
|
{
|
|
//
|
|
mConditions.Clear();
|
|
|
|
//
|
|
CalculateConditions(mConditions, barIndex);
|
|
}
|
|
|
|
//
|
|
// Check Market For Signal ...
|
|
bool HasSignal(
|
|
int barIndex,
|
|
XSignal &mSignal, // Hold's Signal if Exists ...
|
|
X121MarketConditions &mConditions // Hold's Market Conditions ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Enable Process ...
|
|
result = !CanIgnoreProcess();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mWaitsUntilNewBar = false;
|
|
|
|
//
|
|
// Validate Enable Type of Signalling ...
|
|
result = mIsLongEnable || mIsShortEnable;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Now we Have to Pass the Conditions to Each Signal Provider
|
|
// for Retrieving Signals Based On them ...
|
|
|
|
//
|
|
// Reading Market Conditions ...
|
|
GetMarketConditions(mConditions, barIndex);
|
|
AddScores(mConditions);
|
|
|
|
//
|
|
int signalPusher = 0;
|
|
bool hasLong = false;
|
|
bool hasShort = false;
|
|
string provider = "";
|
|
|
|
//
|
|
double providedSL = 0;
|
|
double providedTP = 0;
|
|
double providedR2r = 0;
|
|
|
|
//
|
|
// Long ...
|
|
if (mIsLongEnable)
|
|
{
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
hasLong = HasSpecificSignal(
|
|
barIndex,
|
|
POSITION_TYPE_BUY,
|
|
provider,
|
|
signalPusher,
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
if (mIsShortEnable)
|
|
{
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
hasShort = HasSpecificSignal(
|
|
barIndex,
|
|
POSITION_TYPE_SELL,
|
|
provider,
|
|
signalPusher,
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
}
|
|
|
|
//
|
|
result = hasLong || hasShort;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Prepare Signal ...
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
//
|
|
// Here We Have to Prepare Signal ...
|
|
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
double tpPoint = 60;
|
|
double slPoint = 30;
|
|
double volume = 0.01;
|
|
double tpPrice = PointToPrice(
|
|
tpPoint,
|
|
symbol //
|
|
);
|
|
double slPrice = PointToPrice(
|
|
slPoint,
|
|
symbol //
|
|
);
|
|
ENUM_POSITION_TYPE type = hasLong
|
|
? POSITION_TYPE_BUY
|
|
: POSITION_TYPE_SELL;
|
|
ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET;
|
|
double entry = GetEntry(
|
|
symbol,
|
|
type //
|
|
);
|
|
|
|
//
|
|
double tp = 0;
|
|
double sl = 0;
|
|
|
|
//
|
|
ENUM_X_SIGNAL_MANAGING_ACTIONS action = X_SIGNAL_USE_NOTHING;
|
|
|
|
//
|
|
// TODO: Make Configurable ...
|
|
double r2r = providedR2r;
|
|
if (r2r <= 0)
|
|
{
|
|
r2r = 1.5;
|
|
}
|
|
|
|
//
|
|
sl = 0;
|
|
tp = 0;
|
|
|
|
//
|
|
// TP based on SL and Risk to Reward ...
|
|
if (providedSL > 0)
|
|
{
|
|
//
|
|
sl = providedSL;
|
|
|
|
//
|
|
double risk = MathAbs(entry - sl);
|
|
|
|
//
|
|
double reward = risk * r2r;
|
|
|
|
//
|
|
tp = hasLong
|
|
? entry + reward
|
|
: entry - reward;
|
|
}
|
|
else
|
|
//
|
|
// SL based on TP and Risk to Reward ...
|
|
if (providedTP > 0)
|
|
{
|
|
//
|
|
tp = providedTP;
|
|
|
|
//
|
|
double reward = MathAbs(entry - tp);
|
|
|
|
//
|
|
double risk = reward / r2r;
|
|
|
|
//
|
|
sl = hasLong
|
|
? entry - risk
|
|
: entry + risk;
|
|
}
|
|
|
|
//
|
|
// TODOO: Remove this ...
|
|
sl = hasLong
|
|
? GetMaxVales(true)
|
|
: GetMinPeaks(true);
|
|
double risk = MathAbs(entry - sl);
|
|
double reward = risk * r2r;
|
|
tp = hasLong
|
|
? entry + reward
|
|
: entry - reward;
|
|
|
|
//
|
|
result = mSignal.Prepare(
|
|
symbol,
|
|
provider,
|
|
period,
|
|
type,
|
|
mode,
|
|
entry,
|
|
volume,
|
|
action,
|
|
sl,
|
|
tp
|
|
//
|
|
);
|
|
|
|
//
|
|
// Generate Support Signal for Specified Provider ...
|
|
if (result && provider == ToString(X121NONE))
|
|
{
|
|
//
|
|
double cKijunSen = cMarket.ich.GetKijunSen(0);
|
|
double sKijunSen = sMarket.ich.GetKijunSen(0);
|
|
double mKijunSen = mMarket.ich.GetKijunSen(0);
|
|
double lKijunSen = lMarket.ich.GetKijunSen(0);
|
|
double hKijunSen = hMarket.ich.GetKijunSen(0);
|
|
|
|
//
|
|
double kijunSens[] = {
|
|
cKijunSen,
|
|
sKijunSen,
|
|
mKijunSen,
|
|
lKijunSen,
|
|
hKijunSen //
|
|
};
|
|
|
|
//
|
|
double lesserKijun = FindLesserThan(
|
|
entry,
|
|
kijunSens,
|
|
true //
|
|
);
|
|
|
|
//
|
|
double biggerKijun = FindBiggerThan(
|
|
entry,
|
|
kijunSens,
|
|
true //
|
|
);
|
|
|
|
//
|
|
ENUM_POSITION_TYPE sType =
|
|
hasLong
|
|
? POSITION_TYPE_SELL
|
|
: POSITION_TYPE_BUY;
|
|
|
|
bool isLongS = IsLong(sType);
|
|
|
|
//
|
|
double sEntry =
|
|
isLongS
|
|
? biggerKijun
|
|
: lesserKijun;
|
|
|
|
//
|
|
double peakMin = GetMinPeaks(true);
|
|
double peakMax = GetMinPeaks(true);
|
|
double valeMin = GetMaxVales(true);
|
|
double valeMax = GetMaxVales(true);
|
|
|
|
//
|
|
double sTP =
|
|
isLongS
|
|
? peakMin
|
|
: valeMax;
|
|
|
|
//
|
|
double sSL =
|
|
isLongS
|
|
? valeMin
|
|
: peakMax;
|
|
|
|
//
|
|
double sVolume = mSignal.volume * 2;
|
|
|
|
//
|
|
// Prepare ...
|
|
XSignal sSignal;
|
|
bool isValid = sSignal.Prepare(
|
|
mSignal.symbol,
|
|
mSignal.provider,
|
|
mSignal.period,
|
|
sType,
|
|
X_ORDER_MODE_STOP,
|
|
sEntry,
|
|
sVolume,
|
|
X_SIGNAL_USE_NOTHING,
|
|
sSL,
|
|
sTP //
|
|
);
|
|
if (isValid)
|
|
{
|
|
//
|
|
AddRef(
|
|
sSignal,
|
|
mSignal.supports //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
mWaitsUntilNewBar = true;
|
|
}
|
|
}
|
|
|
|
//
|
|
UpdateSupportsAndResistances();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check for any Guards ...
|
|
bool HasGuard(XGuard &guards[])
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Try to Find Support and Resistances if Configured ...
|
|
FindSupportAndResistances();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Generate EQM Support Signals ...
|
|
int GenerateEQMSupportSignals(XSignal &supports[])
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(supports);
|
|
|
|
//
|
|
// TODO: Implement Support Mechanism ...
|
|
// we are in EQUITY STATE ...
|
|
// so we have to
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
void Draw()
|
|
{
|
|
//
|
|
string symbol = GetSymbol();
|
|
ENUM_TIMEFRAMES period = GetPeriod();
|
|
|
|
//
|
|
ulong chID = FindChartID(
|
|
symbol,
|
|
period);
|
|
if (chID < 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int subWindow = 0;
|
|
|
|
//
|
|
int offset = 0;
|
|
|
|
//
|
|
cMarket.Draw(chID, subWindow, offset);
|
|
sMarket.Draw(chID, subWindow, offset);
|
|
mMarket.Draw(chID, subWindow, offset);
|
|
lMarket.Draw(chID, subWindow, offset);
|
|
hMarket.Draw(chID, subWindow, offset);
|
|
}
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
|
|
//
|
|
int CountSupportResistances()
|
|
{
|
|
return ArraySize(mSupportResistances);
|
|
}
|
|
|
|
//
|
|
bool GenerateSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
ENUM_POSITION_TYPE type, // Position Type ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (count <= 0)
|
|
{
|
|
count = 1;
|
|
}
|
|
|
|
//
|
|
if (step <= 0)
|
|
{
|
|
//
|
|
if (useAtrAsStep)
|
|
{
|
|
step = cMarket.osc.GetATR(0);
|
|
}
|
|
else
|
|
{
|
|
step = 0;
|
|
}
|
|
}
|
|
|
|
//
|
|
supRes.Clean();
|
|
|
|
//
|
|
double price = GetExit(
|
|
GetSymbol(),
|
|
type //
|
|
);
|
|
|
|
//
|
|
result = supRes.Init(
|
|
price,
|
|
mSupportResistances,
|
|
count,
|
|
step);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GenerateLongSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = GenerateSupRes(
|
|
supRes,
|
|
POSITION_TYPE_BUY,
|
|
count,
|
|
step,
|
|
useAtrAsStep //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool GenerateShortSupRes(
|
|
XOHCLSupRes &supRes, // SupRes Instance ...
|
|
int count = 5,
|
|
double step = 0,
|
|
bool useAtrAsStep = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = GenerateSupRes(
|
|
supRes,
|
|
POSITION_TYPE_BUY,
|
|
count,
|
|
step,
|
|
useAtrAsStep //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Peask and Vales Finder ...
|
|
|
|
//
|
|
void GetPeaks(
|
|
double &peaks[],
|
|
bool ignoreCurrent = false //
|
|
)
|
|
{
|
|
//
|
|
Clean(peaks);
|
|
|
|
//
|
|
//
|
|
double cPeak = cMarket.pv.GetPeak(0);
|
|
double sPeak = sMarket.pv.GetPeak(0);
|
|
double mPeak = mMarket.pv.GetPeak(0);
|
|
double lPeak = lMarket.pv.GetPeak(0);
|
|
double hPeak = hMarket.pv.GetPeak(0);
|
|
|
|
//
|
|
double mPeaks[] = {
|
|
cPeak,
|
|
sPeak,
|
|
mPeak,
|
|
lPeak,
|
|
hPeak //
|
|
};
|
|
|
|
//
|
|
if (ignoreCurrent)
|
|
{
|
|
//
|
|
Remove(
|
|
cPeak,
|
|
mPeaks //
|
|
);
|
|
}
|
|
|
|
//
|
|
Copy(
|
|
mPeaks,
|
|
peaks //
|
|
);
|
|
}
|
|
|
|
//
|
|
void GetVales(
|
|
double &vales[],
|
|
bool ignoreCurrent = false //
|
|
)
|
|
{
|
|
//
|
|
Clean(vales);
|
|
|
|
//
|
|
double cVale = cMarket.pv.GetVale(0);
|
|
double sVale = sMarket.pv.GetVale(0);
|
|
double mVale = mMarket.pv.GetVale(0);
|
|
double lVale = lMarket.pv.GetVale(0);
|
|
double hVale = hMarket.pv.GetVale(0);
|
|
|
|
//
|
|
double mVales[] = {
|
|
cVale,
|
|
sVale,
|
|
mVale,
|
|
lVale,
|
|
hVale //
|
|
};
|
|
|
|
//
|
|
if (ignoreCurrent)
|
|
{
|
|
//
|
|
Remove(
|
|
cVale,
|
|
mVales //
|
|
);
|
|
}
|
|
|
|
//
|
|
Copy(
|
|
mVales,
|
|
vales //
|
|
);
|
|
}
|
|
|
|
//
|
|
double GetMinPeaks(bool ignoreCurrent = false)
|
|
{
|
|
//
|
|
double peaks[];
|
|
GetPeaks(
|
|
peaks,
|
|
ignoreCurrent //
|
|
);
|
|
|
|
//
|
|
double minPeak = GetMin(peaks);
|
|
double maxPeak = GetMax(peaks);
|
|
|
|
//
|
|
return minPeak;
|
|
}
|
|
|
|
//
|
|
double GetMaxPeaks(bool ignoreCurrent = false)
|
|
{
|
|
//
|
|
double peaks[];
|
|
GetPeaks(
|
|
peaks,
|
|
ignoreCurrent //
|
|
);
|
|
|
|
//
|
|
double minPeak = GetMin(peaks);
|
|
double maxPeak = GetMax(peaks);
|
|
|
|
//
|
|
return maxPeak;
|
|
}
|
|
|
|
//
|
|
double GetMinVales(bool ignoreCurrent = false)
|
|
{
|
|
//
|
|
double vales[];
|
|
GetVales(
|
|
vales,
|
|
ignoreCurrent //
|
|
);
|
|
|
|
//
|
|
double minVale = GetMin(vales);
|
|
double maxVale = GetMax(vales);
|
|
|
|
//
|
|
return minVale;
|
|
}
|
|
|
|
//
|
|
double GetMaxVales(bool ignoreCurrent = false)
|
|
{
|
|
//
|
|
double vales[];
|
|
GetVales(
|
|
vales,
|
|
ignoreCurrent //
|
|
);
|
|
|
|
//
|
|
double minVale = GetMin(vales);
|
|
double maxVale = GetMax(vales);
|
|
|
|
//
|
|
return maxVale;
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
X121ProviderInputs mInputs;
|
|
|
|
//
|
|
// Support and Resistances ...
|
|
|
|
//
|
|
// Check has Enough Support and Resistance ...
|
|
bool HasEnoughSupportAndResistance()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (mNumberOfSRVerified <= 0 ||
|
|
mMinRequiredSupportAndResistances <= 0)
|
|
{
|
|
result = true;
|
|
}
|
|
else
|
|
{
|
|
//
|
|
int currentSRsCount = CountSupportResistances();
|
|
result = currentSRsCount >= mMinRequiredSupportAndResistances;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Update Bar Index base Support and Resistances ....
|
|
void UpdateSupportsAndResistances(
|
|
int barIndex = 0 //
|
|
)
|
|
{
|
|
//
|
|
if (mNumberOfSRVerified <= 0 ||
|
|
mMinRequiredSupportAndResistances <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int before = CountSupportResistances();
|
|
|
|
//
|
|
// XICH ...
|
|
|
|
//
|
|
// Current ...
|
|
|
|
//
|
|
if (cMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = cMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (cMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = cMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (cMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = cMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
|
|
//
|
|
if (sMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = sMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (sMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = sMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (sMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = sMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Medium ...
|
|
|
|
//
|
|
if (mMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = mMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (mMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = mMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (mMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = mMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Long ...
|
|
|
|
//
|
|
if (lMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = lMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (lMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = lMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (lMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = lMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// Hind ...
|
|
|
|
//
|
|
if (hMarket.ich.IsSameKijunSen(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedKijunSen = hMarket.ich.GetKijunSen(barIndex);
|
|
AddSRValue(selectedKijunSen);
|
|
}
|
|
|
|
//
|
|
if (hMarket.ich.IsSameSenkouSpanA(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanA = hMarket.ich.GetSenkouSpanA(barIndex);
|
|
AddSRValue(selectedSenkouSpanA);
|
|
}
|
|
|
|
//
|
|
if (hMarket.ich.IsSameSenkouSpanB(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSenkouSpanB = hMarket.ich.GetSenkouSpanB(barIndex);
|
|
AddSRValue(selectedSenkouSpanB);
|
|
}
|
|
|
|
//
|
|
// XDON ...
|
|
|
|
//
|
|
// Short Market ...
|
|
|
|
//
|
|
if (sMarket.don.IsSameUpperO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperO = sMarket.don.GetUpperO(barIndex);
|
|
AddSRValue(selectedUpperO);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameLowerO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerO = sMarket.don.GetLowerO(barIndex);
|
|
AddSRValue(selectedLowerO);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameUpperC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperC = sMarket.don.GetUpperC(barIndex);
|
|
AddSRValue(selectedUpperC);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameLowerC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerC = sMarket.don.GetLowerC(barIndex);
|
|
AddSRValue(selectedLowerC);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameUpperH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperH = sMarket.don.GetUpperH(barIndex);
|
|
AddSRValue(selectedUpperH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameLowerH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerH = sMarket.don.GetLowerH(barIndex);
|
|
AddSRValue(selectedLowerH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameUpperL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperL = sMarket.don.GetUpperL(barIndex);
|
|
AddSRValue(selectedUpperL);
|
|
}
|
|
|
|
//
|
|
if (sMarket.don.IsSameLowerL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerL = sMarket.don.GetLowerL(barIndex);
|
|
AddSRValue(selectedLowerL);
|
|
}
|
|
|
|
//
|
|
// Medium Market ...
|
|
|
|
//
|
|
if (mMarket.don.IsSameUpperO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperO = mMarket.don.GetUpperO(barIndex);
|
|
AddSRValue(selectedUpperO);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameLowerO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerO = mMarket.don.GetLowerO(barIndex);
|
|
AddSRValue(selectedLowerO);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameUpperC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperC = mMarket.don.GetUpperC(barIndex);
|
|
AddSRValue(selectedUpperC);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameLowerC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerC = mMarket.don.GetLowerC(barIndex);
|
|
AddSRValue(selectedLowerC);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameUpperH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperH = mMarket.don.GetUpperH(barIndex);
|
|
AddSRValue(selectedUpperH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameLowerH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerH = mMarket.don.GetLowerH(barIndex);
|
|
AddSRValue(selectedLowerH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameUpperL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperL = mMarket.don.GetUpperL(barIndex);
|
|
AddSRValue(selectedUpperL);
|
|
}
|
|
|
|
//
|
|
if (mMarket.don.IsSameLowerL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerL = mMarket.don.GetLowerL(barIndex);
|
|
AddSRValue(selectedLowerL);
|
|
}
|
|
|
|
//
|
|
// Long Market ...
|
|
|
|
//
|
|
if (lMarket.don.IsSameUpperO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperO = lMarket.don.GetUpperO(barIndex);
|
|
AddSRValue(selectedUpperO);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameLowerO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerO = lMarket.don.GetLowerO(barIndex);
|
|
AddSRValue(selectedLowerO);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameUpperC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperC = lMarket.don.GetUpperC(barIndex);
|
|
AddSRValue(selectedUpperC);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameLowerC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerC = lMarket.don.GetLowerC(barIndex);
|
|
AddSRValue(selectedLowerC);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameUpperH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperH = lMarket.don.GetUpperH(barIndex);
|
|
AddSRValue(selectedUpperH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameLowerH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerH = lMarket.don.GetLowerH(barIndex);
|
|
AddSRValue(selectedLowerH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameUpperL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperL = lMarket.don.GetUpperL(barIndex);
|
|
AddSRValue(selectedUpperL);
|
|
}
|
|
|
|
//
|
|
if (lMarket.don.IsSameLowerL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerL = lMarket.don.GetLowerL(barIndex);
|
|
AddSRValue(selectedLowerL);
|
|
}
|
|
|
|
//
|
|
// Hind Market ...
|
|
|
|
//
|
|
if (hMarket.don.IsSameUpperO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperO = hMarket.don.GetUpperO(barIndex);
|
|
AddSRValue(selectedUpperO);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameLowerO(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerO = hMarket.don.GetLowerO(barIndex);
|
|
AddSRValue(selectedLowerO);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameUpperC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperC = hMarket.don.GetUpperC(barIndex);
|
|
AddSRValue(selectedUpperC);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameLowerC(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerC = hMarket.don.GetLowerC(barIndex);
|
|
AddSRValue(selectedLowerC);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameUpperH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperH = hMarket.don.GetUpperH(barIndex);
|
|
AddSRValue(selectedUpperH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameLowerH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerH = hMarket.don.GetLowerH(barIndex);
|
|
AddSRValue(selectedLowerH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameUpperL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedUpperL = hMarket.don.GetUpperL(barIndex);
|
|
AddSRValue(selectedUpperL);
|
|
}
|
|
|
|
//
|
|
if (hMarket.don.IsSameLowerL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLowerL = hMarket.don.GetLowerL(barIndex);
|
|
AddSRValue(selectedLowerL);
|
|
}
|
|
|
|
//
|
|
// XPV ...
|
|
|
|
//
|
|
// Short Market ...
|
|
|
|
//
|
|
if (sMarket.pv.IsSamePeak(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedPeak = sMarket.pv.GetPeak(barIndex);
|
|
AddSRValue(selectedPeak);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameVale(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedVale = sMarket.pv.GetVale(barIndex);
|
|
AddSRValue(selectedVale);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameFib1(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib1 = sMarket.pv.GetFib1(barIndex);
|
|
AddSRValue(selectedFib1);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameFib2(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib2 = sMarket.pv.GetFib2(barIndex);
|
|
AddSRValue(selectedFib2);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameFib3(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib3 = sMarket.pv.GetFib3(barIndex);
|
|
AddSRValue(selectedFib3);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameFib4(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib4 = sMarket.pv.GetFib4(barIndex);
|
|
AddSRValue(selectedFib4);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameFib5(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib5 = sMarket.pv.GetFib5(barIndex);
|
|
AddSRValue(selectedFib5);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameSCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCHH = sMarket.pv.GetSCHH(barIndex);
|
|
AddSRValue(selectedSCHH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameSCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCLL = sMarket.pv.GetSCLL(barIndex);
|
|
AddSRValue(selectedSCLL);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameMCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCHH = sMarket.pv.GetMCHH(barIndex);
|
|
AddSRValue(selectedMCHH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameMCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCLL = sMarket.pv.GetMCLL(barIndex);
|
|
AddSRValue(selectedMCLL);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameLCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCHH = sMarket.pv.GetLCHH(barIndex);
|
|
AddSRValue(selectedLCHH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameLCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCLL = sMarket.pv.GetLCLL(barIndex);
|
|
AddSRValue(selectedLCLL);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameHCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCHH = sMarket.pv.GetHCHH(barIndex);
|
|
AddSRValue(selectedHCHH);
|
|
}
|
|
|
|
//
|
|
if (sMarket.pv.IsSameHCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCLL = sMarket.pv.GetHCLL(barIndex);
|
|
AddSRValue(selectedHCLL);
|
|
}
|
|
|
|
//
|
|
// Medium Market ...
|
|
|
|
//
|
|
if (mMarket.pv.IsSamePeak(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedPeak = mMarket.pv.GetPeak(barIndex);
|
|
AddSRValue(selectedPeak);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameVale(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedVale = mMarket.pv.GetVale(barIndex);
|
|
AddSRValue(selectedVale);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameFib1(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib1 = mMarket.pv.GetFib1(barIndex);
|
|
AddSRValue(selectedFib1);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameFib2(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib2 = mMarket.pv.GetFib2(barIndex);
|
|
AddSRValue(selectedFib2);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameFib3(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib3 = mMarket.pv.GetFib3(barIndex);
|
|
AddSRValue(selectedFib3);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameFib4(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib4 = mMarket.pv.GetFib4(barIndex);
|
|
AddSRValue(selectedFib4);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameFib5(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib5 = mMarket.pv.GetFib5(barIndex);
|
|
AddSRValue(selectedFib5);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameSCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCHH = mMarket.pv.GetSCHH(barIndex);
|
|
AddSRValue(selectedSCHH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameSCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCLL = mMarket.pv.GetSCLL(barIndex);
|
|
AddSRValue(selectedSCLL);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameMCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCHH = mMarket.pv.GetMCHH(barIndex);
|
|
AddSRValue(selectedMCHH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameMCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCLL = mMarket.pv.GetMCLL(barIndex);
|
|
AddSRValue(selectedMCLL);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameLCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCHH = mMarket.pv.GetLCHH(barIndex);
|
|
AddSRValue(selectedLCHH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameLCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCLL = mMarket.pv.GetLCLL(barIndex);
|
|
AddSRValue(selectedLCLL);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameHCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCHH = mMarket.pv.GetHCHH(barIndex);
|
|
AddSRValue(selectedHCHH);
|
|
}
|
|
|
|
//
|
|
if (mMarket.pv.IsSameHCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCLL = mMarket.pv.GetHCLL(barIndex);
|
|
AddSRValue(selectedHCLL);
|
|
}
|
|
|
|
//
|
|
// Long Market ...
|
|
|
|
//
|
|
if (lMarket.pv.IsSamePeak(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedPeak = lMarket.pv.GetPeak(barIndex);
|
|
AddSRValue(selectedPeak);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameVale(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedVale = lMarket.pv.GetVale(barIndex);
|
|
AddSRValue(selectedVale);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameFib1(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib1 = lMarket.pv.GetFib1(barIndex);
|
|
AddSRValue(selectedFib1);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameFib2(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib2 = lMarket.pv.GetFib2(barIndex);
|
|
AddSRValue(selectedFib2);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameFib3(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib3 = lMarket.pv.GetFib3(barIndex);
|
|
AddSRValue(selectedFib3);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameFib4(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib4 = lMarket.pv.GetFib4(barIndex);
|
|
AddSRValue(selectedFib4);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameFib5(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib5 = lMarket.pv.GetFib5(barIndex);
|
|
AddSRValue(selectedFib5);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameSCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCHH = lMarket.pv.GetSCHH(barIndex);
|
|
AddSRValue(selectedSCHH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameSCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCLL = lMarket.pv.GetSCLL(barIndex);
|
|
AddSRValue(selectedSCLL);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameMCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCHH = lMarket.pv.GetMCHH(barIndex);
|
|
AddSRValue(selectedMCHH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameMCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCLL = lMarket.pv.GetMCLL(barIndex);
|
|
AddSRValue(selectedMCLL);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameLCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCHH = lMarket.pv.GetLCHH(barIndex);
|
|
AddSRValue(selectedLCHH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameLCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCLL = lMarket.pv.GetLCLL(barIndex);
|
|
AddSRValue(selectedLCLL);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameHCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCHH = lMarket.pv.GetHCHH(barIndex);
|
|
AddSRValue(selectedHCHH);
|
|
}
|
|
|
|
//
|
|
if (lMarket.pv.IsSameHCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCLL = lMarket.pv.GetHCLL(barIndex);
|
|
AddSRValue(selectedHCLL);
|
|
}
|
|
|
|
//
|
|
// Hind Market ...
|
|
|
|
//
|
|
if (hMarket.pv.IsSamePeak(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedPeak = hMarket.pv.GetPeak(barIndex);
|
|
AddSRValue(selectedPeak);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameVale(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedVale = hMarket.pv.GetVale(barIndex);
|
|
AddSRValue(selectedVale);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameFib1(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib1 = hMarket.pv.GetFib1(barIndex);
|
|
AddSRValue(selectedFib1);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameFib2(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib2 = hMarket.pv.GetFib2(barIndex);
|
|
AddSRValue(selectedFib2);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameFib3(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib3 = hMarket.pv.GetFib3(barIndex);
|
|
AddSRValue(selectedFib3);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameFib4(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib4 = hMarket.pv.GetFib4(barIndex);
|
|
AddSRValue(selectedFib4);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameFib5(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedFib5 = hMarket.pv.GetFib5(barIndex);
|
|
AddSRValue(selectedFib5);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameSCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCHH = hMarket.pv.GetSCHH(barIndex);
|
|
AddSRValue(selectedSCHH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameSCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedSCLL = hMarket.pv.GetSCLL(barIndex);
|
|
AddSRValue(selectedSCLL);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameMCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCHH = hMarket.pv.GetMCHH(barIndex);
|
|
AddSRValue(selectedMCHH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameMCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedMCLL = hMarket.pv.GetMCLL(barIndex);
|
|
AddSRValue(selectedMCLL);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameLCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCHH = hMarket.pv.GetLCHH(barIndex);
|
|
AddSRValue(selectedLCHH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameLCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedLCLL = hMarket.pv.GetLCLL(barIndex);
|
|
AddSRValue(selectedLCLL);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameHCHH(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCHH = hMarket.pv.GetHCHH(barIndex);
|
|
AddSRValue(selectedHCHH);
|
|
}
|
|
|
|
//
|
|
if (hMarket.pv.IsSameHCLL(barIndex, mNumberOfSRVerified))
|
|
{
|
|
//
|
|
double selectedHCLL = hMarket.pv.GetHCLL(barIndex);
|
|
AddSRValue(selectedHCLL);
|
|
}
|
|
|
|
//
|
|
int after = CountSupportResistances();
|
|
|
|
//
|
|
if (after > before)
|
|
{
|
|
//
|
|
string message = "Found: " + ToString(after - before) + " new Pivot ...";
|
|
Print(message);
|
|
}
|
|
}
|
|
|
|
//
|
|
void FindSupportAndResistances()
|
|
{
|
|
//
|
|
bool hasEnough = HasEnoughSupportAndResistance();
|
|
if (hasEnough)
|
|
{
|
|
//
|
|
// if (IsNewBar())
|
|
// {
|
|
// UpdateSupportsAndResistances();
|
|
// }
|
|
return;
|
|
}
|
|
|
|
//
|
|
int idx = 0;
|
|
while (!HasEnoughSupportAndResistance())
|
|
{
|
|
//
|
|
UpdateSupportsAndResistances(idx);
|
|
|
|
//
|
|
if (HasEnoughSupportAndResistance())
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
idx += 50;
|
|
|
|
//
|
|
// Print("idx: " + ToString(idx) + ", Count: " + ToString(CountSupportResistances()));
|
|
Print("Pivots: " + ToString(CountSupportResistances()));
|
|
}
|
|
}
|
|
|
|
//
|
|
void AddSRValue(double value)
|
|
{
|
|
//
|
|
if (value <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
AddIfNotExists(
|
|
value,
|
|
mSupportResistances //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
int mNumberOfItems; // Number of Buffer Ites Read in Conditions ...
|
|
|
|
//
|
|
// Support and Resistance ...
|
|
|
|
//
|
|
int mNumberOfSRVerified; // Number of Verifications for Selecting Support and Resistances ...
|
|
|
|
//
|
|
int mMinRequiredSupportAndResistances; // Minimum Requirement Supports and Resistances ...
|
|
|
|
//
|
|
double mSupportResistances[]; // Holds Supports and Resistances ...
|
|
|
|
//
|
|
// Bullish and Bearish Scores ...
|
|
|
|
//
|
|
double mBullishScore[];
|
|
double mBearishScore[];
|
|
|
|
//
|
|
// Store Market Conditions Scores ...
|
|
void AddScores(X121MarketConditions &conditions)
|
|
{
|
|
//
|
|
double bullishScore = 0;
|
|
double bearishScore = 0;
|
|
conditions.GenerateScore(
|
|
bullishScore,
|
|
bearishScore //
|
|
);
|
|
|
|
//
|
|
ArraySetAsSeries(mBullishScore, false);
|
|
ArraySetAsSeries(mBearishScore, false);
|
|
|
|
//
|
|
Add(
|
|
bullishScore,
|
|
mBullishScore //
|
|
);
|
|
|
|
//
|
|
Add(
|
|
bearishScore,
|
|
mBearishScore //
|
|
);
|
|
|
|
//
|
|
ArraySetAsSeries(mBullishScore, true);
|
|
ArraySetAsSeries(mBearishScore, true);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Score Averages ...
|
|
double GetBullishScoreAverage(
|
|
int start = 0,
|
|
int count = 7 //
|
|
)
|
|
{
|
|
//
|
|
return GetAverage(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Scores Max Value ...
|
|
double GetBullishScoreMax(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMax(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bullish Scores Min Value ...
|
|
double GetBullishScoreMin(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMin(
|
|
mBullishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Score Averages ...
|
|
double GetBearishScoreAverage(
|
|
int start = 0,
|
|
int count = 7 //
|
|
)
|
|
{
|
|
//
|
|
return GetAverage(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Scores Max Value ...
|
|
double GetBearishScoreMax(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMax(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Find Bearish Scores Min Value ...
|
|
double GetBearishScoreMin(
|
|
int start = 0,
|
|
int count = 71 //
|
|
)
|
|
{
|
|
//
|
|
return GetMin(
|
|
mBearishScore,
|
|
start,
|
|
count //
|
|
);
|
|
}
|
|
|
|
//
|
|
bool IsScorePassedForLong()
|
|
{
|
|
//
|
|
double bullishScore = mBullishScore[0];
|
|
double bullishScoreAVG7 = GetBullishScoreAverage(0, 7);
|
|
|
|
//
|
|
double bearishScore = mBearishScore[0];
|
|
double bearishScoreAVG7 = GetBearishScoreAverage(0, 7);
|
|
|
|
//
|
|
bool result =
|
|
//
|
|
ArraySize(mBullishScore) >= 7 &&
|
|
ArraySize(mBearishScore) >= 7 &&
|
|
bullishScore > bearishScore &&
|
|
bullishScore > mBullishScore[1] &&
|
|
bullishScore > bullishScoreAVG7 &&
|
|
bearishScore < bearishScoreAVG7
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool IsScorePassedForShort()
|
|
{
|
|
|
|
//
|
|
double bullishScore = mBullishScore[0];
|
|
double bullishScoreAVG7 = GetBullishScoreAverage(0, 7);
|
|
|
|
//
|
|
double bearishScore = mBearishScore[0];
|
|
double bearishScoreAVG7 = GetBearishScoreAverage(0, 7);
|
|
|
|
//
|
|
bool result =
|
|
//
|
|
ArraySize(mBullishScore) >= 7 &&
|
|
ArraySize(mBearishScore) >= 7 &&
|
|
bearishScore > bullishScore &&
|
|
bearishScore > mBearishScore[1] &&
|
|
bearishScore > bearishScoreAVG7 &&
|
|
bullishScore < bullishScoreAVG7
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Signallers ...
|
|
|
|
//
|
|
bool mIsLongEnable;
|
|
bool mIsShortEnable;
|
|
|
|
//
|
|
bool mIsX121XSPSignalProviderEnable;
|
|
bool mIsX128SignalProviderEnable;
|
|
bool mIsX92SignalProviderEnable;
|
|
bool mIsX786SignalProviderEnable;
|
|
bool mIsX121SignalProviderEnable;
|
|
bool mIsX110SignalProviderEnable;
|
|
bool mIsXTESTSignalProviderEnable;
|
|
|
|
//
|
|
//
|
|
// Detect Signal ...
|
|
bool HasSpecificSignal(
|
|
int barIndex, // Specified Bar Index ...
|
|
ENUM_POSITION_TYPE mType, // Specific Signal Type ...
|
|
string &provider, // Signal Provider ...
|
|
int &signalPusher, // Number Of Same Time Signals ...
|
|
X121MarketConditions &mConditions, // Specified Market Conition ...
|
|
double &providedSL,
|
|
double &providedTP,
|
|
double &providedR2r //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Signal Type is Enables ...
|
|
bool isLong = IsLong(mType);
|
|
result =
|
|
(isLong && mIsLongEnable) ||
|
|
(!isLong && mIsShortEnable);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Now we have to Filter based on Enabled Signal Providers ...
|
|
|
|
//
|
|
// Long ...
|
|
if (isLong && mIsLongEnable)
|
|
{
|
|
//
|
|
XSignal lSignal;
|
|
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
bool hasX121XSPSignal = false;
|
|
bool hasXTESTSignal = false;
|
|
bool hasX786Signal = false;
|
|
bool hasX121Signal = false;
|
|
bool hasX110Signal = false;
|
|
bool hasX92Signal = false;
|
|
bool hasX128Signal = false;
|
|
|
|
//
|
|
// XPS ...
|
|
if (mIsX121XSPSignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121XSPSignal = X121XSPHasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX121XSPSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121XSP);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// XTEST ...
|
|
if (mIsXTESTSignalProviderEnable)
|
|
{
|
|
//
|
|
hasXTESTSignal = XTESTHasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasXTESTSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(XTEST);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X786 ...
|
|
if (mIsX786SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX786Signal = X786HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX786Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X786);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X121 ...
|
|
if (mIsX121SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121Signal = X121HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX121Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X110 ...
|
|
if (mIsX110SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX110Signal = X110HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX110Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X110);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X92 ...
|
|
if (mIsX92SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX92Signal = X92HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX92Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X92);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X128 ...
|
|
if (mIsX128SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX128Signal = X128HasSpecifiedLongSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX128Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X128);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasX121XSPSignal
|
|
//
|
|
||
|
|
//
|
|
hasXTESTSignal
|
|
//
|
|
||
|
|
//
|
|
hasX786Signal
|
|
//
|
|
||
|
|
//
|
|
hasX121Signal
|
|
//
|
|
||
|
|
//
|
|
hasX110Signal
|
|
//
|
|
||
|
|
//
|
|
hasX92Signal
|
|
//
|
|
||
|
|
//
|
|
hasX128Signal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
// Short ...
|
|
if (!isLong && mIsShortEnable)
|
|
{
|
|
//
|
|
XSignal sSignal;
|
|
|
|
//
|
|
signalPusher = 0;
|
|
|
|
//
|
|
bool hasX121XSPSignal = false;
|
|
bool hasXTESTSignal = false;
|
|
bool hasX786Signal = false;
|
|
bool hasX121Signal = false;
|
|
bool hasX110Signal = false;
|
|
bool hasX92Signal = false;
|
|
bool hasX128Signal = false;
|
|
|
|
//
|
|
// X121XSP ...
|
|
if (mIsX121XSPSignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121XSPSignal = X121XSPHasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX121XSPSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121XSP);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// XTEST ...
|
|
if (mIsXTESTSignalProviderEnable)
|
|
{
|
|
//
|
|
hasXTESTSignal = XTESTHasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasXTESTSignal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(XTEST);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X786 ...
|
|
if (mIsX786SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX786Signal = X786HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX786Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X786);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X121 ...
|
|
if (mIsX121SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX121Signal = X121HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX121Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X121);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X110 ...
|
|
if (mIsX110SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX110Signal = X110HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX110Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X110);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X92 ...
|
|
if (mIsX92SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX92Signal = X92HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX92Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X92);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
// X128 ...
|
|
if (mIsX128SignalProviderEnable)
|
|
{
|
|
//
|
|
hasX128Signal = X128HasSpecifiedShortSignal(
|
|
mConditions,
|
|
providedSL,
|
|
providedTP,
|
|
providedR2r //
|
|
);
|
|
|
|
//
|
|
if (hasX128Signal)
|
|
{
|
|
//
|
|
if (!IsValid(provider))
|
|
{
|
|
provider = ToString(X128);
|
|
}
|
|
|
|
//
|
|
signalPusher++;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
hasX121XSPSignal
|
|
//
|
|
||
|
|
//
|
|
hasXTESTSignal
|
|
//
|
|
||
|
|
//
|
|
hasX786Signal
|
|
//
|
|
||
|
|
//
|
|
hasX121Signal
|
|
//
|
|
||
|
|
//
|
|
hasX110Signal
|
|
//
|
|
||
|
|
//
|
|
hasX92Signal
|
|
//
|
|
||
|
|
//
|
|
hasX128Signal
|
|
//
|
|
;
|
|
|
|
//
|
|
if (result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
void CalculateConditions(
|
|
X121MarketConditions &mConditions, // Market Conditions Result
|
|
int barIndex = 0 // Specified Bar Index
|
|
)
|
|
{
|
|
//
|
|
mConditions.Clear();
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
if (barIndex >= CountBars())
|
|
{
|
|
barIndex = CountBars() + 2;
|
|
}
|
|
|
|
//
|
|
int curr = barIndex + 1;
|
|
int prev = curr + 1;
|
|
|
|
//
|
|
mConditions.symbol = GetSymbol();
|
|
mConditions.period = GetPeriod();
|
|
mConditions.time = iTime(
|
|
mConditions.symbol,
|
|
mConditions.period,
|
|
barIndex //
|
|
);
|
|
|
|
//
|
|
GetBars(
|
|
mConditions.bars,
|
|
mConditions.symbol,
|
|
mConditions.period,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
// X121 Cycles Conditions ...
|
|
|
|
//
|
|
cMarket.GetMarketConditions(
|
|
mConditions.cMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
sMarket.GetMarketConditions(
|
|
mConditions.sMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
mMarket.GetMarketConditions(
|
|
mConditions.mMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
lMarket.GetMarketConditions(
|
|
mConditions.lMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
|
|
//
|
|
hMarket.GetMarketConditions(
|
|
mConditions.hMarketConditions,
|
|
barIndex,
|
|
mNumberOfItems //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Signalling based On Signallers ...
|
|
|
|
//
|
|
// X121XSP ...
|
|
|
|
//
|
|
bool X121XSPHasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool XTESTHasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XSTR ...
|
|
bool X786HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
// //
|
|
// bool isCMStrLong =
|
|
// //
|
|
// mConditions.cMarketConditions.isTrendSwitchedToBullish &&
|
|
// (mConditions.hMarketConditions.isTrendBullish &&
|
|
// mConditions.lMarketConditions.isTrendBullish &&
|
|
// mConditions.mMarketConditions.isTrendBullish &&
|
|
// mConditions.sMarketConditions.isTrendBullish)
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// bool isSMStrLong =
|
|
// //
|
|
// mConditions.sMarketConditions.isTrendSwitchedToBullish &&
|
|
// (mConditions.hMarketConditions.isTrendBullish &&
|
|
// mConditions.lMarketConditions.isTrendBullish &&
|
|
// mConditions.mMarketConditions.isTrendBullish &&
|
|
// mConditions.cMarketConditions.isTrendBullish)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
bool isMMStrLong =
|
|
//
|
|
mConditions.mMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isLMStrLong =
|
|
//
|
|
mConditions.lMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.hMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHMStrLong =
|
|
//
|
|
mConditions.hMarketConditions.isTrendSwitchedToBullish &&
|
|
(mConditions.lMarketConditions.isTrendBullish &&
|
|
mConditions.mMarketConditions.isTrendBullish &&
|
|
mConditions.sMarketConditions.isTrendBullish &&
|
|
mConditions.cMarketConditions.isTrendBullish)
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForLong();
|
|
|
|
//
|
|
result =
|
|
//
|
|
// isCMStrLong
|
|
// //
|
|
// ||
|
|
//
|
|
// isSMStrLong
|
|
// //
|
|
// ||
|
|
//
|
|
isMMStrLong
|
|
//
|
|
||
|
|
//
|
|
isLMStrLong
|
|
//
|
|
||
|
|
//
|
|
isHMStrLong
|
|
//
|
|
;
|
|
|
|
//
|
|
// result = result && isScorePassed;
|
|
|
|
//
|
|
// if (result)
|
|
// {
|
|
// sl = GetMinVales();
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XMC ...
|
|
bool X121HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Current Market ...
|
|
// bool isCMCLong =
|
|
// //
|
|
// (
|
|
// //
|
|
// (mConditions.cMarketConditions.isSlowOverVerifier &&
|
|
// mConditions.cMarketConditions.isFastCrossedOverVerifier)
|
|
// //
|
|
// ||
|
|
// //
|
|
// (mConditions.cMarketConditions.isFastOverVerifier &&
|
|
// mConditions.cMarketConditions.isSlowCrossedOverVerifier)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// (mConditions.cMarketConditions.isCloseOverFast &&
|
|
// mConditions.cMarketConditions.isCloseOverSlow &&
|
|
// mConditions.cMarketConditions.isCloseOverVerifier)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Short Market ...
|
|
// bool isSMCLong =
|
|
// //
|
|
// (
|
|
// //
|
|
// (mConditions.sMarketConditions.isSlowOverVerifier &&
|
|
// mConditions.sMarketConditions.isFastCrossedOverVerifier)
|
|
// //
|
|
// ||
|
|
// //
|
|
// (mConditions.sMarketConditions.isFastOverVerifier &&
|
|
// mConditions.sMarketConditions.isSlowCrossedOverVerifier)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// (mConditions.sMarketConditions.isCloseOverFast &&
|
|
// mConditions.sMarketConditions.isCloseOverSlow &&
|
|
// mConditions.sMarketConditions.isCloseOverVerifier)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Medium Market ...
|
|
bool isMMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.mMarketConditions.isSlowOverVerifier &&
|
|
mConditions.mMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isFastOverVerifier &&
|
|
mConditions.mMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.mMarketConditions.isCloseOverFast &&
|
|
mConditions.mMarketConditions.isCloseOverSlow &&
|
|
mConditions.mMarketConditions.isCloseOverVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Long Market ...
|
|
bool isLMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.lMarketConditions.isSlowOverVerifier &&
|
|
mConditions.lMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isFastOverVerifier &&
|
|
mConditions.lMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.lMarketConditions.isCloseOverFast &&
|
|
mConditions.lMarketConditions.isCloseOverSlow &&
|
|
mConditions.lMarketConditions.isCloseOverVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Hind Market ...
|
|
bool isHMCLong =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.hMarketConditions.isSlowOverVerifier &&
|
|
mConditions.hMarketConditions.isFastCrossedOverVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.hMarketConditions.isFastOverVerifier &&
|
|
mConditions.hMarketConditions.isSlowCrossedOverVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.hMarketConditions.isCloseOverFast &&
|
|
mConditions.hMarketConditions.isCloseOverSlow &&
|
|
mConditions.hMarketConditions.isCloseOverVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForLong();
|
|
|
|
//
|
|
result =
|
|
// //
|
|
// isCMCLong
|
|
// //
|
|
// ||
|
|
// //
|
|
// isSMCLong
|
|
// //
|
|
// ||
|
|
//
|
|
isMMCLong
|
|
//
|
|
||
|
|
//
|
|
isLMCLong
|
|
//
|
|
||
|
|
//
|
|
isHMCLong
|
|
//
|
|
;
|
|
|
|
//
|
|
// result = result && isScorePassed;
|
|
|
|
// //
|
|
// if (result)
|
|
// {
|
|
// sl = GetMinVales();
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE ...
|
|
bool X110HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
// //
|
|
// bool isCCHELong =
|
|
// //
|
|
// (mConditions.cMarketConditions.isCHESwitchedInStrongLong &&
|
|
// (mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.hMarketConditions.isCHEInStrongLong))
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// bool isSCHELong =
|
|
// //
|
|
// (mConditions.sMarketConditions.isCHESwitchedInStrongLong &&
|
|
// (mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
// mConditions.hMarketConditions.isCHEInStrongLong))
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
bool isMCHELong =
|
|
//
|
|
(mConditions.mMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isLCHELong =
|
|
//
|
|
(mConditions.lMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.hMarketConditions.isCHEInStrongLong))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHCHELong =
|
|
//
|
|
(mConditions.hMarketConditions.isCHESwitchedInStrongLong &&
|
|
(mConditions.cMarketConditions.isCHEInStrongLong &&
|
|
mConditions.sMarketConditions.isCHEInStrongLong &&
|
|
mConditions.mMarketConditions.isCHEInStrongLong &&
|
|
mConditions.lMarketConditions.isCHEInStrongLong))
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForLong();
|
|
|
|
//
|
|
result =
|
|
// //
|
|
// isCCHELong
|
|
// //
|
|
// ||
|
|
// //
|
|
// isSCHELong
|
|
// //
|
|
// ||
|
|
//
|
|
isMCHELong
|
|
//
|
|
||
|
|
//
|
|
isLCHELong
|
|
//
|
|
||
|
|
//
|
|
isHCHELong
|
|
//
|
|
;
|
|
|
|
//
|
|
// result = result && isScorePassed;
|
|
|
|
// //
|
|
// if (result)
|
|
// {
|
|
// sl = GetMinVales();
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use Scores ...
|
|
bool X92HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XICH ...
|
|
bool X128HasSpecifiedLongSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool X121XSPHasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool XTESTHasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XSTR ...
|
|
bool X786HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
// //
|
|
// bool isCMStrShort =
|
|
// //
|
|
// mConditions.cMarketConditions.isTrendSwitchedToBearish &&
|
|
// (mConditions.hMarketConditions.isTrendBearish &&
|
|
// mConditions.lMarketConditions.isTrendBearish &&
|
|
// mConditions.mMarketConditions.isTrendBearish &&
|
|
// mConditions.sMarketConditions.isTrendBearish)
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// bool isSMStrShort =
|
|
// //
|
|
// mConditions.sMarketConditions.isTrendSwitchedToBearish &&
|
|
// (mConditions.hMarketConditions.isTrendBearish &&
|
|
// mConditions.lMarketConditions.isTrendBearish &&
|
|
// mConditions.mMarketConditions.isTrendBearish &&
|
|
// mConditions.cMarketConditions.isTrendBearish)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
bool isMMStrShort =
|
|
//
|
|
mConditions.mMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isLMStrShort =
|
|
//
|
|
mConditions.lMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.hMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish)
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHMStrShort =
|
|
//
|
|
mConditions.hMarketConditions.isTrendSwitchedToBearish &&
|
|
(mConditions.lMarketConditions.isTrendBearish &&
|
|
mConditions.mMarketConditions.isTrendBearish &&
|
|
mConditions.sMarketConditions.isTrendBearish &&
|
|
mConditions.cMarketConditions.isTrendBearish)
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForShort();
|
|
|
|
//
|
|
result =
|
|
// //
|
|
// isCMStrShort
|
|
// //
|
|
// ||
|
|
// //
|
|
// isSMStrShort
|
|
// //
|
|
// ||
|
|
//
|
|
isMMStrShort
|
|
//
|
|
||
|
|
//
|
|
isLMStrShort
|
|
//
|
|
||
|
|
//
|
|
isHMStrShort
|
|
//
|
|
;
|
|
|
|
//
|
|
// result = result && isScorePassed;
|
|
|
|
// //
|
|
// if (result)
|
|
// {
|
|
// sl = GetMaxPeaks();
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XMC ...
|
|
bool X121HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Current Market ...
|
|
// bool isCMCShort =
|
|
// //
|
|
// (
|
|
// //
|
|
// (mConditions.cMarketConditions.isSlowUnderVerifier &&
|
|
// mConditions.cMarketConditions.isFastCrossedUnderVerifier)
|
|
// //
|
|
// ||
|
|
// //
|
|
// (mConditions.cMarketConditions.isFastUnderVerifier &&
|
|
// mConditions.cMarketConditions.isSlowCrossedUnderVerifier)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// (mConditions.cMarketConditions.isCloseUnderFast &&
|
|
// mConditions.cMarketConditions.isCloseUnderSlow &&
|
|
// mConditions.cMarketConditions.isCloseUnderVerifier)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Short Market ...
|
|
// bool isSMCShort =
|
|
// //
|
|
// (
|
|
// //
|
|
// (mConditions.sMarketConditions.isSlowUnderVerifier &&
|
|
// mConditions.sMarketConditions.isFastCrossedUnderVerifier)
|
|
// //
|
|
// ||
|
|
// //
|
|
// (mConditions.sMarketConditions.isFastUnderVerifier &&
|
|
// mConditions.sMarketConditions.isSlowCrossedUnderVerifier)
|
|
// //
|
|
// )
|
|
// //
|
|
// &&
|
|
// //
|
|
// (mConditions.sMarketConditions.isCloseUnderFast &&
|
|
// mConditions.sMarketConditions.isCloseUnderSlow &&
|
|
// mConditions.sMarketConditions.isCloseUnderVerifier)
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
// Medium Market ...
|
|
bool isMMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.mMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.mMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.mMarketConditions.isFastUnderVerifier &&
|
|
mConditions.mMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.mMarketConditions.isCloseUnderFast &&
|
|
mConditions.mMarketConditions.isCloseUnderSlow &&
|
|
mConditions.mMarketConditions.isCloseUnderVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Long Market ...
|
|
bool isLMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.lMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.lMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.lMarketConditions.isFastUnderVerifier &&
|
|
mConditions.lMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.lMarketConditions.isCloseUnderFast &&
|
|
mConditions.lMarketConditions.isCloseUnderSlow &&
|
|
mConditions.lMarketConditions.isCloseUnderVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// Hind Market ...
|
|
bool isHMCShort =
|
|
//
|
|
(
|
|
//
|
|
(mConditions.hMarketConditions.isSlowUnderVerifier &&
|
|
mConditions.hMarketConditions.isFastCrossedUnderVerifier)
|
|
//
|
|
||
|
|
//
|
|
(mConditions.hMarketConditions.isFastUnderVerifier &&
|
|
mConditions.hMarketConditions.isSlowCrossedUnderVerifier)
|
|
//
|
|
)
|
|
//
|
|
&&
|
|
//
|
|
(mConditions.hMarketConditions.isCloseUnderFast &&
|
|
mConditions.hMarketConditions.isCloseUnderSlow &&
|
|
mConditions.hMarketConditions.isCloseUnderVerifier)
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForShort();
|
|
|
|
//
|
|
result =
|
|
// //
|
|
// isCMCShort
|
|
// //
|
|
// ||
|
|
// //
|
|
// isSMCShort
|
|
// //
|
|
// ||
|
|
//
|
|
isMMCShort
|
|
//
|
|
||
|
|
//
|
|
isLMCShort
|
|
//
|
|
||
|
|
//
|
|
isHMCShort
|
|
//
|
|
;
|
|
|
|
// //
|
|
// result = result && isScorePassed;
|
|
|
|
// //
|
|
// if (result)
|
|
// {
|
|
// sl = GetMaxPeaks();
|
|
// }
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XCHE ...
|
|
bool X110HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
// //
|
|
// bool isCCHEShort =
|
|
// //
|
|
// (mConditions.cMarketConditions.isCHESwitchedInStrongShort &&
|
|
// (mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.hMarketConditions.isCHEInStrongShort))
|
|
// //
|
|
// ;
|
|
|
|
// //
|
|
// bool isSCHEShort =
|
|
// //
|
|
// (mConditions.sMarketConditions.isCHESwitchedInStrongShort &&
|
|
// (mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
// mConditions.hMarketConditions.isCHEInStrongShort))
|
|
// //
|
|
// ;
|
|
|
|
//
|
|
bool isMCHEShort =
|
|
//
|
|
(mConditions.mMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isLCHEShort =
|
|
//
|
|
(mConditions.lMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.hMarketConditions.isCHEInStrongShort))
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isHCHEShort =
|
|
//
|
|
(mConditions.hMarketConditions.isCHESwitchedInStrongShort &&
|
|
(mConditions.cMarketConditions.isCHEInStrongShort &&
|
|
mConditions.sMarketConditions.isCHEInStrongShort &&
|
|
mConditions.mMarketConditions.isCHEInStrongShort &&
|
|
mConditions.lMarketConditions.isCHEInStrongShort))
|
|
//
|
|
;
|
|
|
|
//
|
|
// bool isScorePassed = IsScorePassedForShort();
|
|
|
|
//
|
|
result =
|
|
// //
|
|
// isCCHEShort
|
|
// //
|
|
// ||
|
|
// //
|
|
// isSCHEShort
|
|
// //
|
|
// ||
|
|
//
|
|
isMCHEShort
|
|
//
|
|
||
|
|
//
|
|
isLCHEShort
|
|
//
|
|
||
|
|
//
|
|
isHCHEShort
|
|
//
|
|
;
|
|
|
|
//
|
|
// result = result && isScorePassed;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use Scores ...
|
|
bool X92HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Use XICH ...
|
|
bool X128HasSpecifiedShortSignal(
|
|
X121MarketConditions &mConditions, //
|
|
double &sl, // Provided SL ...
|
|
double &tp, // Provided TP ...
|
|
double &r2r // Risk Reward Ratio ...
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
};
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Model Provider Descriptor ...
|
|
struct X121ProviderDescriptor
|
|
{
|
|
//
|
|
string symbol; // Trading Symbol
|
|
ENUM_TIMEFRAMES period; // Trading Timeframe
|
|
bool allowLong; // Allow Long Signals
|
|
bool allowShort; // Allow Short Signals
|
|
ENUM_X121_SIGNAL_PROVIDERS signallers[]; // Allowed Signal Providers
|
|
|
|
//
|
|
X121ProviderInputs inputs;
|
|
XSCX121Provider *provider;
|
|
|
|
//
|
|
XSignal signal;
|
|
X121MarketConditions conditions;
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
bool Init()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = this.Init(
|
|
this.symbol,
|
|
this.period,
|
|
this.signallers,
|
|
this.allowLong,
|
|
this.allowShort //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool Init(
|
|
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
|
|
bool mAllowLong = true, // Allow Long Signals
|
|
bool mAllowShort = true // Allow Short Signals
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = this.Init(
|
|
this.symbol,
|
|
this.period,
|
|
mSignallers,
|
|
mAllowLong,
|
|
mAllowShort //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool Init(
|
|
string mSymbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES mPeriod, // Trading Timeframe
|
|
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
|
|
bool mAllowLong = true, // Allow Long Signals
|
|
bool mAllowShort = true // Allow Short Signals
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
inputs.IsValid() &&
|
|
IsValid(mSymbol) &&
|
|
IsValid(mPeriod) &&
|
|
(allowLong || allowShort) &&
|
|
ArraySize(mSignallers) > 0
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
this.symbol = mSymbol;
|
|
this.period = mPeriod;
|
|
this.allowLong = mAllowLong;
|
|
this.allowShort = mAllowShort;
|
|
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS tmp[];
|
|
Copy(
|
|
mSignallers,
|
|
tmp //
|
|
);
|
|
Copy(
|
|
tmp,
|
|
this.signallers //
|
|
);
|
|
|
|
//
|
|
// Instantiate Provider ...
|
|
provider = new XSCX121Provider(
|
|
this.symbol,
|
|
this.period //
|
|
);
|
|
|
|
//
|
|
// Set Long/Short State ...
|
|
|
|
//
|
|
provider
|
|
.SetSignalTypeState(
|
|
POSITION_TYPE_BUY,
|
|
this.allowLong //
|
|
);
|
|
|
|
//
|
|
provider
|
|
.SetSignalTypeState(
|
|
POSITION_TYPE_SELL,
|
|
this.allowShort //
|
|
);
|
|
|
|
//
|
|
// Enable Required Signallers ...
|
|
provider
|
|
.SetSignalProviderStates(
|
|
this.signallers,
|
|
true //
|
|
);
|
|
|
|
//
|
|
// Now Must to Initialize Provider ...
|
|
result = provider.Init(
|
|
this.inputs //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
void Clean()
|
|
{
|
|
//
|
|
signal.Clean();
|
|
conditions.Clear();
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid(bool validateInputs = true)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(symbol) &&
|
|
IsValid(period) &&
|
|
(validateInputs
|
|
? inputs.IsValid()
|
|
: true) &&
|
|
(allowLong || allowShort) &&
|
|
ArraySize(signallers) > 0
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Signal ...
|
|
bool HasSignal(int barIndex = 0)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Clear Signal and Conditions ...
|
|
Clean();
|
|
|
|
//
|
|
result = provider.HasSignal(
|
|
barIndex,
|
|
signal,
|
|
conditions //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
void GetAllX121SignalProviders(ENUM_X121_SIGNAL_PROVIDERS &result[])
|
|
{
|
|
//
|
|
Clean(result);
|
|
|
|
//
|
|
Add(X121NONE, result);
|
|
Add(X121XSP, result);
|
|
Add(XTEST, result);
|
|
Add(X786, result);
|
|
Add(X121, result);
|
|
Add(X110, result);
|
|
Add(X92, result);
|
|
Add(X128, result);
|
|
}
|
|
|
|
//
|
|
string ToString(ENUM_X121_SIGNAL_PROVIDERS value)
|
|
{
|
|
return EnumToString(value);
|
|
}
|
|
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS ToX121SignalProvider(string content)
|
|
{
|
|
//
|
|
ENUM_X121_SIGNAL_PROVIDERS result = X121NONE;
|
|
|
|
//
|
|
if (!IsValid(content))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
if (content == ToString(X121NONE))
|
|
{
|
|
result = X121NONE;
|
|
}
|
|
else if (content == ToString(X121XSP))
|
|
{
|
|
result = X121XSP;
|
|
}
|
|
else if (content == ToString(XTEST))
|
|
{
|
|
result = XTEST;
|
|
}
|
|
else if (content == ToString(X786))
|
|
{
|
|
result = X786;
|
|
}
|
|
else if (content == ToString(X121))
|
|
{
|
|
result = X121;
|
|
}
|
|
else if (content == ToString(X110))
|
|
{
|
|
result = X110;
|
|
}
|
|
else if (content == ToString(X92))
|
|
{
|
|
result = X92;
|
|
}
|
|
else if (content == ToString(X128))
|
|
{
|
|
result = X128;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// |