last ...
This commit is contained in:
@@ -182,6 +182,14 @@ class XSCX121SetupCycles : public XSCBaseAlert
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
X121SignalGenerator signalGenerator;
|
||||
|
||||
//
|
||||
X121SetupCycleInputs cCycle; // Current (Host) Cycle
|
||||
X121SetupCycleInputs sCycle; // Short Cycle
|
||||
X121SetupCycleInputs mCycle; // Medium Cycle
|
||||
X121SetupCycleInputs lCycle; // Long Cycle
|
||||
X121SetupCycleInputs hCycle; // Hind Cycle
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
@@ -266,6 +274,16 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = sBarTracker.Init(
|
||||
_inputs.symbol,
|
||||
sCycle.cycle.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
result = mCycle.Init(
|
||||
@@ -280,6 +298,16 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = mBarTracker.Init(
|
||||
_inputs.symbol,
|
||||
mCycle.cycle.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
result = lCycle.Init(
|
||||
@@ -294,6 +322,16 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = lBarTracker.Init(
|
||||
_inputs.symbol,
|
||||
lCycle.cycle.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
result = hCycle.Init(
|
||||
@@ -308,6 +346,16 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = hBarTracker.Init(
|
||||
_inputs.symbol,
|
||||
hCycle.cycle.period //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
_inputs.period = cCycle.GetPeriod();
|
||||
|
||||
@@ -403,6 +451,48 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
datetime GetNextSignalTime(
|
||||
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN //
|
||||
)
|
||||
{
|
||||
//
|
||||
datetime result = NULL;
|
||||
|
||||
//
|
||||
switch (cycle)
|
||||
{
|
||||
//
|
||||
case X_MARKET_CYCLE_SHORT:
|
||||
result = sNextValidSignal;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_MEDIUM:
|
||||
result = mNextValidSignal;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_LONG:
|
||||
result = lNextValidSignal;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_HIND:
|
||||
result = hNextValidSignal;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
case X_MARKET_CYCLE_UNKNOWN:
|
||||
result = cNextValidSignal;
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
void WaitsUntilNextBar(
|
||||
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN //
|
||||
@@ -414,24 +504,40 @@ public:
|
||||
//
|
||||
case X_MARKET_CYCLE_SHORT:
|
||||
//
|
||||
FillNextBarTime(
|
||||
sNextValidSignal,
|
||||
sBarTracker //
|
||||
);
|
||||
sBarTracker.Waits();
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_MEDIUM:
|
||||
//
|
||||
FillNextBarTime(
|
||||
mNextValidSignal,
|
||||
mBarTracker //
|
||||
);
|
||||
mBarTracker.Waits();
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_LONG:
|
||||
//
|
||||
FillNextBarTime(
|
||||
lNextValidSignal,
|
||||
lBarTracker //
|
||||
);
|
||||
lBarTracker.Waits();
|
||||
break;
|
||||
|
||||
//
|
||||
case X_MARKET_CYCLE_HIND:
|
||||
//
|
||||
FillNextBarTime(
|
||||
hNextValidSignal,
|
||||
hBarTracker //
|
||||
);
|
||||
hBarTracker.Waits();
|
||||
break;
|
||||
|
||||
@@ -439,6 +545,10 @@ public:
|
||||
default:
|
||||
case X_MARKET_CYCLE_UNKNOWN:
|
||||
//
|
||||
FillNextBarTime(
|
||||
cNextValidSignal,
|
||||
cBarTracker //
|
||||
);
|
||||
cBarTracker.Waits();
|
||||
break;
|
||||
}
|
||||
@@ -581,6 +691,79 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool ProcessMarket(
|
||||
XSignal &signal,
|
||||
X121SetupConditions &conditions,
|
||||
int &pushers,
|
||||
string &provider,
|
||||
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN,
|
||||
bool allowSupports = false, // Allow Support Signal Generating ...
|
||||
bool allowLong = false,
|
||||
bool allowShort = false,
|
||||
double volume = 0.01,
|
||||
double slPoint = 100,
|
||||
bool ignoreSL = false,
|
||||
double tpPoint = 100,
|
||||
bool ignoreTP = false,
|
||||
int barIndex = 0,
|
||||
int loopback = 5 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = CanProcessBar(
|
||||
cycle //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = GetConditions(
|
||||
conditions,
|
||||
cycle, // Current Market ...
|
||||
barIndex, // Bar Index ...
|
||||
loopback // Loop Back ...
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
result = signalGenerator.HasSignal(
|
||||
conditions,
|
||||
signal,
|
||||
pushers,
|
||||
provider,
|
||||
allowSupports,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
WaitsUntilNextBar(
|
||||
cycle //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
@@ -602,11 +785,41 @@ private:
|
||||
XBarTracker hBarTracker;
|
||||
|
||||
//
|
||||
X121SetupCycleInputs cCycle; // Current (Host) Cycle
|
||||
X121SetupCycleInputs sCycle; // Short Cycle
|
||||
X121SetupCycleInputs mCycle; // Medium Cycle
|
||||
X121SetupCycleInputs lCycle; // Long Cycle
|
||||
X121SetupCycleInputs hCycle; // Hind Cycle
|
||||
datetime cNextValidSignal;
|
||||
datetime sNextValidSignal;
|
||||
datetime mNextValidSignal;
|
||||
datetime lNextValidSignal;
|
||||
datetime hNextValidSignal;
|
||||
|
||||
//
|
||||
void FillNextBarTime(
|
||||
datetime &next,
|
||||
XBarTracker &tracker)
|
||||
{
|
||||
//
|
||||
next = iTime(
|
||||
tracker.symbol,
|
||||
tracker.period,
|
||||
0) +
|
||||
PeriodSeconds(tracker.period);
|
||||
}
|
||||
|
||||
// //
|
||||
// bool ProcessCurrentMarket(
|
||||
// XSignal &signal,
|
||||
// X121SetupConditions &conditions,
|
||||
// int &pushers,
|
||||
// string &provider,
|
||||
// int barIndex = 0,
|
||||
// int loopback = 5 //
|
||||
// )
|
||||
// {
|
||||
// //
|
||||
// bool result = false;
|
||||
|
||||
// //
|
||||
// return result;
|
||||
// }
|
||||
};
|
||||
|
||||
//
|
||||
@@ -3504,368 +3504,165 @@ public:
|
||||
|
||||
//
|
||||
int maxAllowed = MaxAllowedTrades();
|
||||
X121SignalGenerator signalGenerator;
|
||||
|
||||
//
|
||||
double volume = Volume();
|
||||
double slPoint = SLPoint();
|
||||
double tpPoint = TPPoint();
|
||||
bool ignoreSL = IgnoreSL();
|
||||
bool ignoreTP = IgnoreTP();
|
||||
bool allowLong = AllowLong();
|
||||
bool allowShort = AllowShort();
|
||||
bool allowSupport = AllowSupport();
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Current Market ...
|
||||
|
||||
//
|
||||
cPusher = 0;
|
||||
sPusher = 0;
|
||||
mPusher = 0;
|
||||
lPusher = 0;
|
||||
hPusher = 0;
|
||||
|
||||
//
|
||||
cProvider = NULL;
|
||||
sProvider = NULL;
|
||||
mProvider = NULL;
|
||||
lProvider = NULL;
|
||||
hProvider = NULL;
|
||||
|
||||
//
|
||||
cSignal.Clean();
|
||||
sSignal.Clean();
|
||||
mSignal.Clean();
|
||||
lSignal.Clean();
|
||||
hSignal.Clean();
|
||||
|
||||
//
|
||||
cProvider = NULL;
|
||||
cHasSignal = false;
|
||||
sHasSignal = false;
|
||||
mHasSignal = false;
|
||||
lHasSignal = false;
|
||||
hHasSignal = false;
|
||||
cConditions.Clean();
|
||||
|
||||
//
|
||||
cConditions.Clean();
|
||||
cHasSignal = mSetups[i].ProcessMarket(
|
||||
cSignal,
|
||||
cConditions,
|
||||
cPusher,
|
||||
cProvider,
|
||||
X_MARKET_CYCLE_UNKNOWN,
|
||||
allowSupport,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Short Market ...
|
||||
|
||||
//
|
||||
sPusher = 0;
|
||||
sSignal.Clean();
|
||||
sProvider = NULL;
|
||||
sHasSignal = false;
|
||||
sConditions.Clean();
|
||||
|
||||
//
|
||||
sHasSignal = mSetups[i].ProcessMarket(
|
||||
sSignal,
|
||||
sConditions,
|
||||
sPusher,
|
||||
sProvider,
|
||||
X_MARKET_CYCLE_SHORT,
|
||||
allowSupport,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
|
||||
//
|
||||
mPusher = 0;
|
||||
mSignal.Clean();
|
||||
mProvider = NULL;
|
||||
mHasSignal = false;
|
||||
mConditions.Clean();
|
||||
|
||||
//
|
||||
mHasSignal = mSetups[i].ProcessMarket(
|
||||
mSignal,
|
||||
mConditions,
|
||||
mPusher,
|
||||
mProvider,
|
||||
X_MARKET_CYCLE_MEDIUM,
|
||||
allowSupport,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
|
||||
//
|
||||
lPusher = 0;
|
||||
lSignal.Clean();
|
||||
lProvider = NULL;
|
||||
lHasSignal = false;
|
||||
lConditions.Clean();
|
||||
|
||||
//
|
||||
lHasSignal = mSetups[i].ProcessMarket(
|
||||
lSignal,
|
||||
lConditions,
|
||||
lPusher,
|
||||
lProvider,
|
||||
X_MARKET_CYCLE_LONG,
|
||||
allowSupport,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
// Hind Market ...
|
||||
|
||||
//
|
||||
hPusher = 0;
|
||||
hSignal.Clean();
|
||||
hProvider = NULL;
|
||||
hHasSignal = false;
|
||||
hConditions.Clean();
|
||||
|
||||
//
|
||||
// Current ...
|
||||
bool canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_UNKNOWN //
|
||||
);
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
cConditions,
|
||||
X_MARKET_CYCLE_UNKNOWN, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (!iHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
mVolumeOSC = 0;
|
||||
mBullishSigns = 0;
|
||||
mBullishScore = 0;
|
||||
mBearishSigns = 0;
|
||||
mBearishScore = 0;
|
||||
|
||||
//
|
||||
// Retrieve Scores ...
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
cConditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
mBullishScore += bullishScore;
|
||||
mBearishScore += bearishScore;
|
||||
|
||||
//
|
||||
mVolumeOSC += cConditions.vlmConditions.volume[1];
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
cHasSignal = signalGenerator.HasSignal(
|
||||
cConditions,
|
||||
cSignal,
|
||||
cPusher,
|
||||
cProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (cHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_UNKNOWN //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_SHORT //
|
||||
);
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
sConditions,
|
||||
X_MARKET_CYCLE_SHORT, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (!iHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Scores ...
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
sConditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
mBullishScore += bullishScore;
|
||||
mBearishScore += bearishScore;
|
||||
|
||||
//
|
||||
mVolumeOSC += sConditions.vlmConditions.volume[1];
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
sHasSignal = signalGenerator.HasSignal(
|
||||
sConditions,
|
||||
sSignal,
|
||||
sPusher,
|
||||
sProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (sHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_SHORT //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
mConditions,
|
||||
X_MARKET_CYCLE_MEDIUM, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (!iHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Scores ...
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
mConditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
mBullishScore += bullishScore;
|
||||
mBearishScore += bearishScore;
|
||||
|
||||
//
|
||||
mVolumeOSC += mConditions.vlmConditions.volume[1];
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
mHasSignal = signalGenerator.HasSignal(
|
||||
mConditions,
|
||||
mSignal,
|
||||
mPusher,
|
||||
mProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (mHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
lConditions,
|
||||
X_MARKET_CYCLE_LONG, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (!iHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Scores ...
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
lConditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
mBullishScore += bullishScore;
|
||||
mBearishScore += bearishScore;
|
||||
|
||||
//
|
||||
mVolumeOSC += lConditions.vlmConditions.volume[1];
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
lHasSignal = signalGenerator.HasSignal(
|
||||
lConditions,
|
||||
lSignal,
|
||||
lPusher,
|
||||
lProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (lHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
hConditions,
|
||||
X_MARKET_CYCLE_HIND, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (!iHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Scores ...
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
hConditions.GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
mBullishScore += bullishScore;
|
||||
mBearishScore += bearishScore;
|
||||
|
||||
//
|
||||
mVolumeOSC += hConditions.vlmConditions.volume[1];
|
||||
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
hHasSignal = signalGenerator.HasSignal(
|
||||
hConditions,
|
||||
hHasSignal = mSetups[i].ProcessMarket(
|
||||
hSignal,
|
||||
hConditions,
|
||||
hPusher,
|
||||
hProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
X_MARKET_CYCLE_HIND,
|
||||
allowSupport,
|
||||
allowLong,
|
||||
allowShort,
|
||||
volume,
|
||||
slPoint,
|
||||
ignoreSL,
|
||||
tpPoint,
|
||||
ignoreTP,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
|
||||
//
|
||||
if (hHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Parse Signals and Add them for Executing ...
|
||||
|
||||
@@ -3875,241 +3672,257 @@ public:
|
||||
if (hasSignal)
|
||||
{
|
||||
//
|
||||
// Handle Creating a new Signal Info ...
|
||||
XSignal signal;
|
||||
X121SetupConditions otherConditions[];
|
||||
if (cHasSignal)
|
||||
{
|
||||
//
|
||||
Print("Current Market Has Signal ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (sHasSignal)
|
||||
{
|
||||
//
|
||||
Print("Short Market Has Signal ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (mHasSignal)
|
||||
{
|
||||
//
|
||||
Print("Medium Market Has Signal ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (lHasSignal)
|
||||
{
|
||||
//
|
||||
Print("Long Market Has Signal ...");
|
||||
Print(ToString(mSetups[i].lCycle.cycle.period));
|
||||
}
|
||||
|
||||
//
|
||||
if (hHasSignal)
|
||||
{
|
||||
//
|
||||
signal = hSignal;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
cConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
sConditions,
|
||||
otherConditions //
|
||||
);
|
||||
}
|
||||
else if (lHasSignal)
|
||||
{
|
||||
//
|
||||
signal = lSignal;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
cConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
sConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
mConditions,
|
||||
otherConditions //
|
||||
);
|
||||
}
|
||||
else if (mHasSignal)
|
||||
{
|
||||
//
|
||||
signal = mSignal;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
cConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
sConditions,
|
||||
otherConditions //
|
||||
);
|
||||
}
|
||||
else if (sHasSignal)
|
||||
{
|
||||
//
|
||||
signal = sSignal;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
cConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
mConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
lConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
hConditions,
|
||||
otherConditions //
|
||||
);
|
||||
}
|
||||
else if (cHasSignal)
|
||||
{
|
||||
//
|
||||
signal = cSignal;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
sConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
mConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
lConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
hConditions,
|
||||
otherConditions //
|
||||
);
|
||||
Print("Hind Market Has Signal ...");
|
||||
}
|
||||
|
||||
//
|
||||
int pushers = cPusher + sPusher + mPusher + lPusher + hPusher;
|
||||
|
||||
//
|
||||
bool isLong = IsLong(signal.type);
|
||||
|
||||
//
|
||||
// Collecting Bullish/Bearish Signs ...
|
||||
if (isLong)
|
||||
{
|
||||
mBullishSigns += pushers;
|
||||
}
|
||||
else
|
||||
{
|
||||
mBearishSigns += pushers;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Signal ...
|
||||
bool isValid =
|
||||
//
|
||||
// Handle Pusher Validations ...
|
||||
(mReuiredSignalVerifications <= 0
|
||||
? true
|
||||
: pushers >= mReuiredSignalVerifications)
|
||||
//
|
||||
&&
|
||||
//
|
||||
// Handle Other Conditions Validations ...
|
||||
(!mGetVerificationFromOtherTimeFrames
|
||||
? true
|
||||
: isLong
|
||||
? signalGenerator.HasLongVerifications(otherConditions)
|
||||
: signalGenerator.HasShortVerifications(otherConditions))
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool forceState = ForceState();
|
||||
|
||||
//
|
||||
if (!isValid || (forceState && isValid))
|
||||
{
|
||||
//
|
||||
// Clear Other Conditions ...
|
||||
Clean(otherConditions);
|
||||
|
||||
//
|
||||
// Fill All Conditions to Other Conditions ...
|
||||
AddRef(
|
||||
cConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
sConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
mConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
lConditions,
|
||||
otherConditions //
|
||||
);
|
||||
AddRef(
|
||||
hConditions,
|
||||
otherConditions //
|
||||
);
|
||||
|
||||
//
|
||||
// If Recieved Any Unverified Signal
|
||||
// we Passed it to EQM Manager ...
|
||||
EQMHandleInvalidSignal(
|
||||
signal,
|
||||
pushers,
|
||||
mVolumeOSC,
|
||||
mBullishScore,
|
||||
mBullishSigns,
|
||||
mBearishScore,
|
||||
mBearishSigns,
|
||||
otherConditions,
|
||||
isValid //
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (!forceState)
|
||||
{
|
||||
//
|
||||
// Add Signal to Execution Result ...
|
||||
AddRef(
|
||||
signal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
// Add new Signal Info ...
|
||||
mTradeHandler.Add(
|
||||
signal,
|
||||
pushers,
|
||||
mVolumeOSC,
|
||||
mBullishSigns,
|
||||
mBearishSigns,
|
||||
mBullishScore,
|
||||
mBearishScore,
|
||||
cConditions,
|
||||
sConditions,
|
||||
mConditions,
|
||||
lConditions,
|
||||
hConditions //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handle Creating a new Signal Info ...
|
||||
// XSignal signal;
|
||||
// X121SetupConditions otherConditions[];
|
||||
// if (hHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = hSignal;
|
||||
|
||||
// //
|
||||
// // Create Score Summary for Commenting on Chart ...
|
||||
// string scoreSummary =
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (lHasSignal)
|
||||
// {
|
||||
// //
|
||||
// "----------" + separator +
|
||||
// "Bullish Score: " + ToString(mBullishScore) + separator +
|
||||
// "Bullish Signs: " + ToString(mBullishSigns) + separator +
|
||||
// "----------" + separator +
|
||||
// "Bearish Score: " + ToString(mBearishScore) + separator +
|
||||
// "Bearish Signs: " + ToString(mBearishSigns) + separator +
|
||||
// "----------" + separator +
|
||||
// "Volume: " + ToString(mVolumeOSC) + separator +
|
||||
// "DrawDown: " + ToString(GetDrawdownPercent()) + "%" +
|
||||
// ""
|
||||
// signal = lSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (mHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = mSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (sHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = sSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// lConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// hConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (cHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = cSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// lConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// hConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
|
||||
// //
|
||||
// int pushers = cPusher + sPusher + mPusher + lPusher + hPusher;
|
||||
|
||||
// //
|
||||
// bool isLong = IsLong(signal.type);
|
||||
|
||||
// //
|
||||
// // Collecting Bullish/Bearish Signs ...
|
||||
// if (isLong)
|
||||
// {
|
||||
// mBullishSigns += pushers;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mBearishSigns += pushers;
|
||||
// }
|
||||
|
||||
// //
|
||||
// // Validate Signal ...
|
||||
// bool isValid =
|
||||
// //
|
||||
// // Handle Pusher Validations ...
|
||||
// (mReuiredSignalVerifications <= 0
|
||||
// ? true
|
||||
// : pushers >= mReuiredSignalVerifications)
|
||||
// //
|
||||
// &&
|
||||
// //
|
||||
// // Handle Other Conditions Validations ...
|
||||
// (!mGetVerificationFromOtherTimeFrames
|
||||
// ? true
|
||||
// : isLong
|
||||
// ? signalGenerator.HasLongVerifications(otherConditions)
|
||||
// : signalGenerator.HasShortVerifications(otherConditions))
|
||||
// //
|
||||
// ;
|
||||
|
||||
// //
|
||||
// Comment(scoreSummary);
|
||||
// bool forceState = ForceState();
|
||||
|
||||
// //
|
||||
// if (!isValid || (forceState && isValid))
|
||||
// {
|
||||
// //
|
||||
// // Clear Other Conditions ...
|
||||
// Clean(otherConditions);
|
||||
|
||||
// //
|
||||
// // Fill All Conditions to Other Conditions ...
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// lConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// hConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // If Recieved Any Unverified Signal
|
||||
// // we Passed it to EQM Manager ...
|
||||
// EQMHandleInvalidSignal(
|
||||
// signal,
|
||||
// pushers,
|
||||
// mVolumeOSC,
|
||||
// mBullishScore,
|
||||
// mBullishSigns,
|
||||
// mBearishScore,
|
||||
// mBearishSigns,
|
||||
// otherConditions,
|
||||
// isValid //
|
||||
// );
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (!forceState)
|
||||
// {
|
||||
// //
|
||||
// // Add Signal to Execution Result ...
|
||||
// AddRef(
|
||||
// signal,
|
||||
// signals //
|
||||
// );
|
||||
|
||||
// //
|
||||
// // Add new Signal Info ...
|
||||
// mTradeHandler.Add(
|
||||
// signal,
|
||||
// pushers,
|
||||
// mVolumeOSC,
|
||||
// mBullishSigns,
|
||||
// mBearishSigns,
|
||||
// mBullishScore,
|
||||
// mBearishScore,
|
||||
// cConditions,
|
||||
// sConditions,
|
||||
// mConditions,
|
||||
// lConditions,
|
||||
// hConditions //
|
||||
// );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(signals);
|
||||
|
||||
@@ -3070,3 +3070,319 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
cPusher = 0;
|
||||
sPusher = 0;
|
||||
mPusher = 0;
|
||||
lPusher = 0;
|
||||
hPusher = 0;
|
||||
|
||||
//
|
||||
cProvider = NULL;
|
||||
sProvider = NULL;
|
||||
mProvider = NULL;
|
||||
lProvider = NULL;
|
||||
hProvider = NULL;
|
||||
|
||||
//
|
||||
cSignal.Clean();
|
||||
sSignal.Clean();
|
||||
mSignal.Clean();
|
||||
lSignal.Clean();
|
||||
hSignal.Clean();
|
||||
|
||||
//
|
||||
cHasSignal = false;
|
||||
sHasSignal = false;
|
||||
mHasSignal = false;
|
||||
lHasSignal = false;
|
||||
hHasSignal = false;
|
||||
|
||||
//
|
||||
cConditions.Clean();
|
||||
sConditions.Clean();
|
||||
mConditions.Clean();
|
||||
lConditions.Clean();
|
||||
hConditions.Clean();
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
// Current ...
|
||||
bool canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_UNKNOWN //
|
||||
);
|
||||
//
|
||||
datetime next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_UNKNOWN);
|
||||
if (IsValid(next))
|
||||
{
|
||||
canProcess = canProcess && cTime >= next;
|
||||
}
|
||||
|
||||
//
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
cConditions,
|
||||
X_MARKET_CYCLE_UNKNOWN, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (iHasConditions)
|
||||
{
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
cHasSignal = signalGenerator.HasSignal(
|
||||
cConditions,
|
||||
cSignal,
|
||||
cPusher,
|
||||
cProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (cHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_UNKNOWN //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_SHORT //
|
||||
);
|
||||
//
|
||||
next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_SHORT);
|
||||
if (IsValid(next))
|
||||
{
|
||||
sHasSignal = canProcess && cTime >= next;
|
||||
}
|
||||
|
||||
//
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
sConditions,
|
||||
X_MARKET_CYCLE_SHORT, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (iHasConditions)
|
||||
{
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
sHasSignal = signalGenerator.HasSignal(
|
||||
sConditions,
|
||||
sSignal,
|
||||
sPusher,
|
||||
sProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (sHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_SHORT //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
//
|
||||
next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_MEDIUM);
|
||||
if (IsValid(next))
|
||||
{
|
||||
mHasSignal = canProcess && cTime >= next;
|
||||
}
|
||||
|
||||
//
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
mConditions,
|
||||
X_MARKET_CYCLE_MEDIUM, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (iHasConditions)
|
||||
{
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
mHasSignal = signalGenerator.HasSignal(
|
||||
mConditions,
|
||||
mSignal,
|
||||
mPusher,
|
||||
mProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (mHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
//
|
||||
next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_LONG);
|
||||
if (IsValid(next))
|
||||
{
|
||||
lHasSignal = canProcess && cTime >= next;
|
||||
}
|
||||
|
||||
//
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
lConditions,
|
||||
X_MARKET_CYCLE_LONG, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (iHasConditions)
|
||||
{
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
lHasSignal = signalGenerator.HasSignal(
|
||||
lConditions,
|
||||
lSignal,
|
||||
lPusher,
|
||||
lProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (lHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
canProcess = mSetups[i]
|
||||
.CanProcessBar(
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
//
|
||||
next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_HIND);
|
||||
if (IsValid(next))
|
||||
{
|
||||
hHasSignal = canProcess && cTime >= next;
|
||||
}
|
||||
|
||||
//
|
||||
if (canProcess)
|
||||
{
|
||||
//
|
||||
bool iHasConditions = mSetups[i].GetConditions(
|
||||
hConditions,
|
||||
X_MARKET_CYCLE_HIND, // Current Market ...
|
||||
0, // Bar Index ...
|
||||
5 // Loop Back ...
|
||||
);
|
||||
|
||||
//
|
||||
if (iHasConditions)
|
||||
{
|
||||
//
|
||||
// Parse Conditions for Signal ...
|
||||
hHasSignal = signalGenerator.HasSignal(
|
||||
hConditions,
|
||||
hSignal,
|
||||
hPusher,
|
||||
hProvider,
|
||||
AllowSupport(),
|
||||
mAllowLong,
|
||||
mAllowShort,
|
||||
mVolume,
|
||||
mSLPoint,
|
||||
mIgnoreSL,
|
||||
mTPPoint,
|
||||
mIgnoreTP //
|
||||
);
|
||||
|
||||
//
|
||||
if (hHasSignal)
|
||||
{
|
||||
//
|
||||
mSetups[i].WaitsUntilNextBar(
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3377,7 +3377,7 @@ int FindMaxDrawdownIndex(
|
||||
|
||||
//
|
||||
if (max == 0 ||
|
||||
max < iPosition.profit)
|
||||
MathAbs(max) < MathAbs(iPosition.profit))
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
|
||||
Reference in New Issue
Block a user