This commit is contained in:
2024-06-22 21:55:55 +03:30
parent b88d74e57d
commit de8143585b
4 changed files with 913 additions and 571 deletions
+218 -5
View File
@@ -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;
// }
};
//
File diff suppressed because it is too large Load Diff
+316
View File
@@ -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 //
);
}
}
}
+1 -1
View File
@@ -3377,7 +3377,7 @@ int FindMaxDrawdownIndex(
//
if (max == 0 ||
max < iPosition.profit)
MathAbs(max) < MathAbs(iPosition.profit))
{
//
result = i;