last ...
This commit is contained in:
@@ -473,3 +473,672 @@
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// Long Support ...
|
||||
bool canLongSupport =
|
||||
//
|
||||
volumeOSC > 5 &&
|
||||
bullishScore > bearishScore &&
|
||||
ArraySize(longProviders) >= 2 &&
|
||||
bearishScore < bullishScore / 3.5 &&
|
||||
longVerifications > reqValidation * 3
|
||||
//
|
||||
;
|
||||
if (canLongSupport)
|
||||
{
|
||||
//
|
||||
bool isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_BUY,
|
||||
X_ORDER_MODE_MARKET,
|
||||
longEntry,
|
||||
mVolume //
|
||||
);
|
||||
|
||||
//
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_SELL,
|
||||
X_ORDER_MODE_MARKET,
|
||||
shortEntry,
|
||||
mVolume //
|
||||
);
|
||||
|
||||
//
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short Support ...
|
||||
bool canShortSupport =
|
||||
//
|
||||
volumeOSC < -5 &&
|
||||
bearishScore > bullishScore &&
|
||||
ArraySize(shortProviders) >= 2 &&
|
||||
bullishScore < bearishScore / 3.5 &&
|
||||
shortVerifications > reqValidation * 3
|
||||
//
|
||||
;
|
||||
if (canShortSupport)
|
||||
{
|
||||
//
|
||||
bool isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_SELL,
|
||||
X_ORDER_MODE_MARKET,
|
||||
shortEntry,
|
||||
mVolume //
|
||||
);
|
||||
|
||||
//
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_BUY,
|
||||
X_ORDER_MODE_MARKET,
|
||||
longEntry,
|
||||
mVolume //
|
||||
);
|
||||
|
||||
//
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If no Support Presents ...
|
||||
if (!canLongSupport && !canShortSupport)
|
||||
{
|
||||
//
|
||||
// RemoveDraws("MED");
|
||||
// RemoveDraws("LON");
|
||||
// RemoveDraws("HND");
|
||||
AddHotLevelsToZones(mZones);
|
||||
AddHotLevelsToZones(lZones);
|
||||
AddHotLevelsToZones(hZones);
|
||||
|
||||
//
|
||||
bool isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_BUY,
|
||||
X_ORDER_MODE_MARKET,
|
||||
longEntry,
|
||||
iPosition.volume //
|
||||
);
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
isPrepared = tmpSignal.Prepare(
|
||||
iPosition.symbol,
|
||||
iPosition.provider,
|
||||
iPosition.period,
|
||||
POSITION_TYPE_SELL,
|
||||
X_ORDER_MODE_MARKET,
|
||||
shortEntry,
|
||||
iPosition.volume //
|
||||
);
|
||||
if (isPrepared)
|
||||
{
|
||||
//
|
||||
tmpSignal.positionId = iPosition.ticket;
|
||||
string comment = GenerateSupportTag(iPosition.ticket);
|
||||
tmpSignal.comment = comment;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
tmpSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
//
|
||||
tmpSignal.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// bool isDrawn = mZones.DrawZones(0, "MED");
|
||||
// if (isDrawn)
|
||||
// {
|
||||
// //
|
||||
// isDrawn = false;
|
||||
// RemoveDraws("MED");
|
||||
// }
|
||||
|
||||
// //
|
||||
// isDrawn = lZones.DrawZones(0, "LON");
|
||||
// if (isDrawn)
|
||||
// {
|
||||
// //
|
||||
// isDrawn = false;
|
||||
// RemoveDraws("LON");
|
||||
// }
|
||||
|
||||
// //
|
||||
// isDrawn = hZones.DrawZones(0, "HND");
|
||||
// if (isDrawn)
|
||||
// {
|
||||
// //
|
||||
// isDrawn = false;
|
||||
// RemoveDraws("HND");
|
||||
// }
|
||||
|
||||
// //
|
||||
// isDrawn = mZones.DrawZones(0, "MED");
|
||||
// isDrawn = lZones.DrawZones(0, "LON");
|
||||
// isDrawn = hZones.DrawZones(0, "HND");
|
||||
// if (isDrawn)
|
||||
// {
|
||||
// //
|
||||
// isDrawn = false;
|
||||
// // RemoveDraws("MED");
|
||||
// // RemoveDraws("LON");
|
||||
// // RemoveDraws("HND");
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Now Check Position SUpports ...
|
||||
XPosition iSupports[];
|
||||
int iSupportsCount = mTrader.GetSupports(
|
||||
iPosition.ticket,
|
||||
iSupports //
|
||||
);
|
||||
bool isFirst = !IsValidSize(iSupportsCount);
|
||||
bool canSupport = isFirst || iSupportsCount < 3;
|
||||
if (!canSupport)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Now Check Signals For not Exists ...
|
||||
int signalsCount = ArraySize(signals);
|
||||
if (IsValidSize(signalsCount))
|
||||
{
|
||||
//
|
||||
bool isInserted = false;
|
||||
for (int j = 0; j < signalsCount; j++)
|
||||
{
|
||||
//
|
||||
isInserted = signals[j].positionId == iPosition.ticket;
|
||||
if (isInserted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (isInserted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// First Try to Get Market State ...
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
double tmpBullishScore = 0;
|
||||
double tmpBearishScore = 0;
|
||||
|
||||
//
|
||||
// Max Verifications is 11 ...
|
||||
int reqValidation = 6;
|
||||
int longVerifications = 0;
|
||||
int shortVerifications = 0;
|
||||
|
||||
//
|
||||
// Pushers ...
|
||||
int longPushers = 0;
|
||||
int shortPushers = 0;
|
||||
int tmpLongPushers = 0;
|
||||
int tmpShortPushers = 0;
|
||||
|
||||
//
|
||||
string tmpProvider;
|
||||
string longProviders[];
|
||||
string shortProviders[];
|
||||
|
||||
//
|
||||
double volumeOSC = 0;
|
||||
|
||||
//
|
||||
// Current ...
|
||||
X121SetupConditions cConditions;
|
||||
bool cHasConditions = setups[idx].GetConditions(
|
||||
cConditions,
|
||||
X_MARKET_CYCLE_UNKNOWN //
|
||||
);
|
||||
if (!cHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool isCValidForLong = signalGenerator.IsConditionsValidForLong(
|
||||
cConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isCValidForLong)
|
||||
{
|
||||
longVerifications += reqValidation;
|
||||
}
|
||||
bool isCValidForShort = signalGenerator.IsConditionsValidForShort(
|
||||
cConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isCValidForShort)
|
||||
{
|
||||
shortVerifications += reqValidation;
|
||||
}
|
||||
bool cHasLongConditions = signalGenerator.HasLongConditions(
|
||||
cConditions,
|
||||
tmpLongPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (cHasLongConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
longProviders //
|
||||
);
|
||||
|
||||
//
|
||||
longPushers += tmpLongPushers;
|
||||
}
|
||||
bool cHasShortConditions = signalGenerator.HasShortConditions(
|
||||
cConditions,
|
||||
tmpShortPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (cHasShortConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
shortProviders //
|
||||
);
|
||||
|
||||
//
|
||||
shortPushers += tmpShortPushers;
|
||||
}
|
||||
volumeOSC += cConditions.vlmConditions.volume[1];
|
||||
cConditions.GenerateScore(
|
||||
tmpBullishScore,
|
||||
tmpBearishScore //
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
//
|
||||
// Short ...
|
||||
X121SetupConditions sConditions;
|
||||
bool sHasConditions = setups[idx].GetConditions(
|
||||
sConditions,
|
||||
X_MARKET_CYCLE_SHORT //
|
||||
);
|
||||
if (!sHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool isSValidForLong = signalGenerator.IsConditionsValidForLong(
|
||||
sConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isSValidForLong)
|
||||
{
|
||||
longVerifications += reqValidation;
|
||||
}
|
||||
bool isSValidForShort = signalGenerator.IsConditionsValidForShort(
|
||||
sConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isSValidForShort)
|
||||
{
|
||||
shortVerifications += reqValidation;
|
||||
}
|
||||
bool sHasLongConditions = signalGenerator.HasLongConditions(
|
||||
sConditions,
|
||||
tmpLongPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (sHasLongConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
longProviders //
|
||||
);
|
||||
|
||||
//
|
||||
longPushers += tmpLongPushers;
|
||||
}
|
||||
bool sHasShortConditions = signalGenerator.HasShortConditions(
|
||||
sConditions,
|
||||
tmpShortPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (sHasShortConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
shortProviders //
|
||||
);
|
||||
|
||||
//
|
||||
shortPushers += tmpShortPushers;
|
||||
}
|
||||
volumeOSC += sConditions.vlmConditions.volume[1];
|
||||
sConditions.GenerateScore(
|
||||
tmpBullishScore,
|
||||
tmpBearishScore //
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
X121SetupConditions mConditions;
|
||||
bool mHasConditions = setups[idx].GetConditions(
|
||||
mConditions,
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
if (!mHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
XSCZones *mZones = setups[idx].GetZones(
|
||||
X_MARKET_CYCLE_MEDIUM //
|
||||
);
|
||||
bool isMValidForLong = signalGenerator.IsConditionsValidForLong(
|
||||
mConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isMValidForLong)
|
||||
{
|
||||
longVerifications += reqValidation;
|
||||
}
|
||||
bool isMValidForShort = signalGenerator.IsConditionsValidForShort(
|
||||
mConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isMValidForShort)
|
||||
{
|
||||
shortVerifications += reqValidation;
|
||||
}
|
||||
bool mHasLongConditions = signalGenerator.HasLongConditions(
|
||||
mConditions,
|
||||
tmpLongPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (mHasLongConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
longProviders //
|
||||
);
|
||||
|
||||
//
|
||||
longPushers += tmpLongPushers;
|
||||
}
|
||||
bool mHasShortConditions = signalGenerator.HasShortConditions(
|
||||
mConditions,
|
||||
tmpShortPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (mHasShortConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
shortProviders //
|
||||
);
|
||||
|
||||
//
|
||||
shortPushers += tmpShortPushers;
|
||||
}
|
||||
volumeOSC += mConditions.vlmConditions.volume[1];
|
||||
mConditions.GenerateScore(
|
||||
tmpBullishScore,
|
||||
tmpBearishScore //
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
//
|
||||
// Long ...
|
||||
X121SetupConditions lConditions;
|
||||
bool lHasConditions = setups[idx].GetConditions(
|
||||
lConditions,
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
if (!lHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
XSCZones *lZones = setups[idx].GetZones(
|
||||
X_MARKET_CYCLE_LONG //
|
||||
);
|
||||
bool isLValidForLong = signalGenerator.IsConditionsValidForLong(
|
||||
lConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isLValidForLong)
|
||||
{
|
||||
longVerifications += reqValidation;
|
||||
}
|
||||
bool isLValidForShort = signalGenerator.IsConditionsValidForShort(
|
||||
lConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isLValidForShort)
|
||||
{
|
||||
shortVerifications += reqValidation;
|
||||
}
|
||||
bool lHasLongConditions = signalGenerator.HasLongConditions(
|
||||
lConditions,
|
||||
tmpLongPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (lHasLongConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
longProviders //
|
||||
);
|
||||
|
||||
//
|
||||
longPushers += tmpLongPushers;
|
||||
}
|
||||
bool lHasShortConditions = signalGenerator.HasShortConditions(
|
||||
lConditions,
|
||||
tmpShortPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (lHasShortConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
shortProviders //
|
||||
);
|
||||
|
||||
//
|
||||
shortPushers += tmpShortPushers;
|
||||
}
|
||||
volumeOSC += lConditions.vlmConditions.volume[1];
|
||||
lConditions.GenerateScore(
|
||||
tmpBullishScore,
|
||||
tmpBearishScore //
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
X121SetupConditions hConditions;
|
||||
bool hHasConditions = setups[idx].GetConditions(
|
||||
hConditions,
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
if (!hHasConditions)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
XSCZones *hZones = setups[idx].GetZones(
|
||||
X_MARKET_CYCLE_HIND //
|
||||
);
|
||||
bool isHValidForLong = signalGenerator.IsConditionsValidForLong(
|
||||
hConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isHValidForLong)
|
||||
{
|
||||
longVerifications += reqValidation;
|
||||
}
|
||||
bool isHValidForShort = signalGenerator.IsConditionsValidForShort(
|
||||
hConditions,
|
||||
reqValidation //
|
||||
);
|
||||
if (isHValidForShort)
|
||||
{
|
||||
shortVerifications += reqValidation;
|
||||
}
|
||||
bool hHasLongConditions = signalGenerator.HasLongConditions(
|
||||
hConditions,
|
||||
tmpLongPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (hHasLongConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
longProviders //
|
||||
);
|
||||
|
||||
//
|
||||
longPushers += tmpLongPushers;
|
||||
}
|
||||
bool hHasShortConditions = signalGenerator.HasShortConditions(
|
||||
hConditions,
|
||||
tmpShortPushers,
|
||||
tmpProvider //
|
||||
);
|
||||
if (hHasShortConditions)
|
||||
{
|
||||
//
|
||||
AddSpecific(
|
||||
tmpProvider,
|
||||
shortProviders //
|
||||
);
|
||||
|
||||
//
|
||||
shortPushers += tmpShortPushers;
|
||||
}
|
||||
volumeOSC += hConditions.vlmConditions.volume[1];
|
||||
hConditions.GenerateScore(
|
||||
tmpBullishScore,
|
||||
tmpBearishScore //
|
||||
);
|
||||
bullishScore += tmpBullishScore;
|
||||
bearishScore += tmpBearishScore;
|
||||
|
||||
Reference in New Issue
Block a user