apply fix for multi signaller signal generating issue ...

This commit is contained in:
2024-06-05 20:21:44 +03:30
parent b1b2ef36ec
commit b6323751cd
3 changed files with 424 additions and 384 deletions
+414 -376
View File
@@ -1204,7 +1204,7 @@ struct X121ProviderDescriptor
XSCX121Provider *provider;
//
XSignal signal;
XSignal signals[];
X121MarketConditions conditions;
//
@@ -1273,7 +1273,7 @@ struct X121ProviderDescriptor
void Clean()
{
//
signal.Clean();
Clean(signals);
conditions.Clear();
}
@@ -1302,22 +1302,20 @@ struct X121ProviderDescriptor
//
// Check Signal ...
bool HasSignal(int barIndex = 0)
int HasSignal(int barIndex = 0)
{
//
bool result = false;
int result = 0;
//
result = inputs.IsValid();
if (!result)
if (!inputs.IsValid())
{
return result;
}
//
int signallersCount = ArraySize(this.signallers);
result = IsValidSize(signallersCount);
if (!result)
if (!IsValidSize(signallersCount))
{
return result;
}
@@ -1328,8 +1326,7 @@ struct X121ProviderDescriptor
//
// Check Waits Until New Bar ...
result = !this.provider.CanIgnoreProcess();
if (!result)
if (!this.provider.CanIgnoreProcess())
{
return result;
}
@@ -1662,392 +1659,433 @@ struct X121ProviderDescriptor
mProvider = this.signallers[i].GetName();
mVolume = this.signallers[i].staticVolumeShort;
}
}
//
bool hasLong =
//
cHasLong
//
||
//
sHasLong
//
||
//
mHasLong
//
||
//
lHasLong
//
||
//
hHasLong
//
;
//
bool hasShort =
//
cHasShort
//
||
//
sHasShort
//
||
//
mHasShort
//
||
//
lHasShort
//
||
//
hHasShort
//
;
//
result = hasLong || hasShort;
if (!result)
{
return result;
}
//
bool isScorePassed = hasLong
? bullishScore > bearishScore * 2
: bearishScore > bullishScore * 2;
//
result =
//
isScorePassed &&
(hasLong
? longVerifiers > 1
: shortVerifiers > 1)
//
;
if (!result)
{
return result;
}
//
// Try to Normalize SL and TP ...
//
// For Longs ...
if (hasLong) {
//
// Collect all Verifications SLs ...
//
double sls[];
double tps[];
//
// Current Market ...
//
if (cLNSL > 0) {
bool hasLong =
//
Add(
cLNSL,
sls //
);
}
//
if (cLNTP > 0) {
cHasLong
//
Add(
cLNTP,
tps //
);
}
//
// Short Market ...
//
if (sLNSL > 0) {
||
//
Add(
sLNSL,
sls //
);
}
//
if (sLNTP > 0) {
sHasLong
//
Add(
sLNTP,
tps //
);
}
//
// Medium Market ...
//
if (mLNSL > 0) {
||
//
Add(
mLNSL,
sls //
);
}
//
if (mLNTP > 0) {
mHasLong
//
Add(
mLNTP,
tps //
);
}
//
// Long Market ...
//
if (lLNSL > 0) {
||
//
Add(
lLNSL,
sls //
);
}
//
if (lLNTP > 0) {
lHasLong
//
Add(
lLNTP,
tps //
);
}
//
// Hind Market ...
//
if (hLNSL > 0) {
||
//
Add(
hLNSL,
sls //
);
}
//
if (hLNTP > 0) {
hHasLong
//
Add(
hLNTP,
tps //
;
//
bool hasShort =
//
cHasShort
//
||
//
sHasShort
//
||
//
mHasShort
//
||
//
lHasShort
//
||
//
hHasShort
//
;
//
if (!(hasLong || hasShort))
{
continue;
}
//
bool isScorePassed = hasLong
? bullishScore > bearishScore * 2
: bearishScore > bullishScore * 2;
//
bool hasSignal =
//
isScorePassed &&
(hasLong
? longVerifiers > 1
: shortVerifiers > 1)
//
;
if (!hasSignal)
{
continue;
}
//
// Try to Normalize SL and TP ...
//
// For Longs ...
if (hasLong)
{
//
// Collect all Verifications SLs ...
//
double sls[];
double tps[];
//
// Current Market ...
//
if (cLNSL > 0)
{
//
Add(
cLNSL,
sls //
);
}
//
if (cLNTP > 0)
{
//
Add(
cLNTP,
tps //
);
}
//
// Short Market ...
//
if (sLNSL > 0)
{
//
Add(
sLNSL,
sls //
);
}
//
if (sLNTP > 0)
{
//
Add(
sLNTP,
tps //
);
}
//
// Medium Market ...
//
if (mLNSL > 0)
{
//
Add(
mLNSL,
sls //
);
}
//
if (mLNTP > 0)
{
//
Add(
mLNTP,
tps //
);
}
//
// Long Market ...
//
if (lLNSL > 0)
{
//
Add(
lLNSL,
sls //
);
}
//
if (lLNTP > 0)
{
//
Add(
lLNTP,
tps //
);
}
//
// Hind Market ...
//
if (hLNSL > 0)
{
//
Add(
hLNSL,
sls //
);
}
//
if (hLNTP > 0)
{
//
Add(
hLNTP,
tps //
);
}
//
// Now Select Minimum SL ...
if (IsValidSize(ArraySize(sls)))
{
slPrice = GetMin(sls);
}
//
// Average TP ...
if (IsValidSize(ArraySize(tps)))
{
tpPrice = GetAverage(tps);
}
}
//
// For Shorts ...
if (hasShort)
{
//
// Collect all Verifications SLs ...
//
double sls[];
double tps[];
//
// Current Market ...
//
if (cSHSL > 0)
{
//
Add(
cSHSL,
sls //
);
}
//
if (cSHTP > 0)
{
//
Add(
cSHTP,
tps //
);
}
//
// Short Market ...
//
if (sSHSL > 0)
{
//
Add(
sSHSL,
sls //
);
}
//
if (sSHTP > 0)
{
//
Add(
sSHTP,
tps //
);
}
//
// Medium Market ...
//
if (mSHSL > 0)
{
//
Add(
mSHSL,
sls //
);
}
//
if (mSHTP > 0)
{
//
Add(
mSHTP,
tps //
);
}
//
// Long Market ...
//
if (lSHSL > 0)
{
//
Add(
lSHSL,
sls //
);
}
//
if (lSHTP > 0)
{
//
Add(
lSHTP,
tps //
);
}
//
// Hind Market ...
//
if (hSHSL > 0)
{
//
Add(
hSHSL,
sls //
);
}
//
if (hSHTP > 0)
{
//
Add(
hSHTP,
tps //
);
}
//
// Now Select Minimum SL ...
if (IsValidSize(ArraySize(sls)))
{
slPrice = GetMin(sls);
}
//
// Average TP ...
if (IsValidSize(ArraySize(tps)))
{
tpPrice = GetAverage(tps);
}
}
//
// Generate Signal ...
XSignal iSignal;
//
ENUM_POSITION_TYPE mType =
hasLong
? POSITION_TYPE_BUY
: POSITION_TYPE_SELL;
//
double mEntry = GetEntry(
this.symbol,
mType //
);
//
double mTP = 0;
double mSL = 0;
CalculateTPSL(
mSL,
mTP,
mType,
mEntry,
mR2R,
slPrice,
tpPrice //
);
if (mSL == 0 && mTP == 0)
{
Print("Zero TP/SL ...");
}
//
bool isPrepared = iSignal.Prepare(
this.symbol,
mProvider,
this.period,
mType,
X_ORDER_MODE_MARKET,
mEntry,
mVolume,
mSL,
mTP //
);
if (!isPrepared)
{
iSignal.Clean();
}
//
if (iSignal.IsValid() && isPrepared && hasSignal)
{
//
AddRef(
iSignal,
this.signals //
);
}
//
// Now Select Minimum SL ...
if (IsValidSize(ArraySize(sls))) {
slPrice = GetMin(sls);
}
//
// Average TP ...
if (IsValidSize(ArraySize(tps))) {
tpPrice = GetAverage(tps);
}
}
//
// For Shorts ...
if (hasShort) {
//
// Collect all Verifications SLs ...
//
double sls[];
double tps[];
//
// Current Market ...
//
if (cSHSL > 0) {
//
Add(
cSHSL,
sls //
);
}
//
if (cSHTP > 0) {
//
Add(
cSHTP,
tps //
);
}
//
// Short Market ...
//
if (sSHSL > 0) {
//
Add(
sSHSL,
sls //
);
}
//
if (sSHTP > 0) {
//
Add(
sSHTP,
tps //
);
}
//
// Medium Market ...
//
if (mSHSL > 0) {
//
Add(
mSHSL,
sls //
);
}
//
if (mSHTP > 0) {
//
Add(
mSHTP,
tps //
);
}
//
// Long Market ...
//
if (lSHSL > 0) {
//
Add(
lSHSL,
sls //
);
}
//
if (lSHTP > 0) {
//
Add(
lSHTP,
tps //
);
}
//
// Hind Market ...
//
if (hSHSL > 0) {
//
Add(
hSHSL,
sls //
);
}
//
if (hSHTP > 0) {
//
Add(
hSHTP,
tps //
);
}
//
// Now Select Minimum SL ...
if (IsValidSize(ArraySize(sls))) {
slPrice = GetMin(sls);
}
//
// Average TP ...
if (IsValidSize(ArraySize(tps))) {
tpPrice = GetAverage(tps);
}
}
//
// Generate Signal ...
this.signal.Clean();
//
ENUM_POSITION_TYPE mType =
hasLong
? POSITION_TYPE_BUY
: POSITION_TYPE_SELL;
//
double mEntry = GetEntry(
this.symbol,
mType //
);
//
double mTP = 0;
double mSL = 0;
CalculateTPSL(
mSL,
mTP,
mType,
mEntry,
mR2R,
slPrice,
tpPrice //
);
if (mSL == 0 && mTP == 0)
{
Print("Zero TP/SL ...");
}
//
result = this.signal.Prepare(
this.symbol,
mProvider,
this.period,
mType,
X_ORDER_MODE_MARKET,
mEntry,
mVolume,
mSL,
mTP //
);
if (!result)
{
this.signal.Clean();
}
result = ArraySize(this.signals);
//
// Set Wait Until New Bar ...
this.provider.SetWaitsUntilNewBar(true);
if (IsValidSize(result))
{
this.provider.SetWaitsUntilNewBar(true);
}
//
return result;
+7 -5
View File
@@ -231,17 +231,19 @@ public:
X121ProviderDescriptor iDescriptor = mDescriptors[i];
//
bool iHasSignal = iDescriptor.HasSignal();
if (iHasSignal)
int iSignalsCount = iDescriptor.HasSignal();
if (IsValidSize(iSignalsCount))
{
//
// Here we Can double check Signals by Conditions
// for Score Base Filtering ...
iDescriptor.provider.SetWaitsUntilNewBar(true);
//
AddRef(
iDescriptor.signal,
signals
Copy(
iDescriptor.signals,
signals,
false
//
);