last ...
This commit is contained in:
@@ -0,0 +1,531 @@
|
||||
|
||||
//
|
||||
// Find Max InDD Position ...
|
||||
XPosition positions[];
|
||||
int positionsCount = mTrader.GetInDrawdownPositions(
|
||||
positions,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
X_POSITION_SELECT_MAX //
|
||||
);
|
||||
if (positionsCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
XPosition maxInDP = positions[0];
|
||||
string symbol = maxInDP.symbol;
|
||||
ENUM_TIMEFRAMES period = maxInDP.period;
|
||||
|
||||
//
|
||||
X121ProviderDescriptor maxInDPDescriptor;
|
||||
int descriptorsCount = CountDescriptors();
|
||||
if (descriptorsCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Find Provider ...
|
||||
for (int i = 0; i < descriptorsCount; i++)
|
||||
{
|
||||
//
|
||||
X121ProviderDescriptor iDescriptor = mDescriptors[i];
|
||||
|
||||
//
|
||||
if (iDescriptor.symbol == symbol &&
|
||||
iDescriptor.period == period)
|
||||
{
|
||||
//
|
||||
maxInDPDescriptor = iDescriptor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
double longEntry = GetEntry(symbol, POSITION_TYPE_BUY);
|
||||
double shortEntry = GetEntry(symbol, POSITION_TYPE_SELL);
|
||||
|
||||
//
|
||||
XOHCLSupRes longSupRes;
|
||||
maxInDPDescriptor
|
||||
.provider
|
||||
.GenerateLongSupRes(
|
||||
longSupRes //
|
||||
);
|
||||
|
||||
//
|
||||
XOHCLSupRes shortSupRes;
|
||||
maxInDPDescriptor
|
||||
.provider
|
||||
.GenerateShortSupRes(
|
||||
shortSupRes //
|
||||
);
|
||||
|
||||
//
|
||||
XProfitTrack track;
|
||||
GetProfitTrack(
|
||||
track //
|
||||
);
|
||||
|
||||
//
|
||||
bool isLongIncreasing = IsProfitTrackFieldIncreasing(
|
||||
X_PROFIT_TRACK_LONGS_PROFIT,
|
||||
0,
|
||||
30 //
|
||||
);
|
||||
|
||||
//
|
||||
bool isLongDecresing = IsProfitTrackFieldDecreasing(
|
||||
X_PROFIT_TRACK_LONGS_PROFIT,
|
||||
0,
|
||||
30 //
|
||||
);
|
||||
|
||||
//
|
||||
bool isShortIncreasing = IsProfitTrackFieldIncreasing(
|
||||
X_PROFIT_TRACK_SHORTS_PROFIT,
|
||||
0,
|
||||
30 //
|
||||
);
|
||||
|
||||
//
|
||||
bool isShortDecresing = IsProfitTrackFieldDecreasing(
|
||||
X_PROFIT_TRACK_SHORTS_PROFIT,
|
||||
0,
|
||||
30 //
|
||||
);
|
||||
|
||||
//
|
||||
XSignal sSignal;
|
||||
bool isValidSignal = false;
|
||||
if (track.shortsProfit < track.longsProfit)
|
||||
{
|
||||
//
|
||||
// Find Long ...
|
||||
isValidSignal = sSignal.PrepareMarketLong(
|
||||
symbol,
|
||||
"EQM",
|
||||
period,
|
||||
longEntry,
|
||||
track.shortsVolume,
|
||||
X_SIGNAL_USE_NOTHING,
|
||||
0, //; longSupRes.sup[0],
|
||||
0 //; longSupRes.res[0] //
|
||||
);
|
||||
}
|
||||
else if (track.longsProfit < track.shortsProfit)
|
||||
{
|
||||
//
|
||||
// Find Short ...
|
||||
isValidSignal = sSignal.PrepareMarketShort(
|
||||
symbol,
|
||||
"EQM",
|
||||
period,
|
||||
shortEntry,
|
||||
track.shortsVolume,
|
||||
X_SIGNAL_USE_NOTHING,
|
||||
0, // shortSupRes.res[0],
|
||||
0 // shortSupRes.sup[0] //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (isValidSignal)
|
||||
{
|
||||
//
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT sState;
|
||||
bool isExecuted = mTrader.ExecuteSignal(
|
||||
sSignal,
|
||||
sState,
|
||||
ORDER_TIME_GTC,
|
||||
NULL,
|
||||
false // Ignore Policy Checking ...
|
||||
);
|
||||
|
||||
//
|
||||
if (isExecuted)
|
||||
{
|
||||
//
|
||||
string message = "EQM Executed Support Signal for: " + symbol + ", On: " + ToString(period);
|
||||
|
||||
//
|
||||
mAlert.Alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
||||
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// // not First Signal ...
|
||||
|
||||
// //
|
||||
// // Calculate Provider Specified Open Positions Profit ...
|
||||
// double profits = CalculatePositionsProfit(positions);
|
||||
// if (profits > 0)
|
||||
// {
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// iSignal,
|
||||
// signals //
|
||||
// );
|
||||
|
||||
// // //
|
||||
// // // Find Max In Profit of Same Position ...
|
||||
// // Clean(positions);
|
||||
// // positionsCount = mTrader.GetInProfitPositions(
|
||||
// // positions,
|
||||
// // iSignal.symbol,
|
||||
// // iSignal.provider,
|
||||
// // NULL, // All Periods ...
|
||||
// // iSignal.type,
|
||||
// // X_POSITION_SELECT_MAX // Max In Profit ...
|
||||
// // );
|
||||
// // if (positionsCount <= 0)
|
||||
// // {
|
||||
// // continue;
|
||||
// // }
|
||||
|
||||
// // //
|
||||
// // string comment = "EQM Close Max Profit ...";
|
||||
// // bool isClosed = mTrader.Close(
|
||||
// // positions[0].ticket,
|
||||
// // comment //
|
||||
// // );
|
||||
// // if (isClosed)
|
||||
// // {
|
||||
// // //
|
||||
// // RemoveTrail(positions[0].ticket);
|
||||
|
||||
// // //
|
||||
// // string message = "EQM Close Max In Profit (" + ToString(positions[0].ticket) + ") for new Signal ...";
|
||||
|
||||
// // //
|
||||
// // mAlert.Alert(message);
|
||||
|
||||
// // //
|
||||
// // AddRef(
|
||||
// // iSignal,
|
||||
// // signals //
|
||||
// // );
|
||||
|
||||
// // //
|
||||
// // continue;
|
||||
// // }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // //
|
||||
// // // Find Max In Profit of Same Position ...
|
||||
// // Clean(positions);
|
||||
// // positionsCount = mTrader.GetInProfitPositions(
|
||||
// // positions,
|
||||
// // iSignal.symbol,
|
||||
// // iSignal.provider,
|
||||
// // NULL, // All Periods ...
|
||||
// // iSignal.type,
|
||||
// // X_POSITION_SELECT_MAX // Max In Profit ...
|
||||
// // );
|
||||
// // if (positionsCount <= 0)
|
||||
// // {
|
||||
// // continue;
|
||||
// // }
|
||||
|
||||
// // //
|
||||
// // string comment = "EQM Close Max Profit ...";
|
||||
// // bool isClosed = mTrader.Close(
|
||||
// // positions[0].ticket,
|
||||
// // comment //
|
||||
// // );
|
||||
// // if (isClosed)
|
||||
// // {
|
||||
// // //
|
||||
// // RemoveTrail(positions[0].ticket);
|
||||
|
||||
// // //
|
||||
// // string message = "EQM Close Max In Profit (" + ToString(positions[0].ticket) + ") for new Signal ...";
|
||||
|
||||
// // //
|
||||
// // mAlert.Alert(message);
|
||||
|
||||
// // //
|
||||
// // AddRef(
|
||||
// // iSignal,
|
||||
// // signals //
|
||||
// // );
|
||||
|
||||
// // //
|
||||
// // continue;
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
double bullishScore = mBullishScore[0];
|
||||
double bullishMin100 = GetBullishScoreMin(0, 100);
|
||||
double bullishMax100 = GetBullishScoreMax(0, 100);
|
||||
double bullish9AVG = GetBullishScoreAverage(0, 9);
|
||||
double bullish17AVG = GetBullishScoreAverage(0, 17);
|
||||
double bullish26AVG = GetBullishScoreAverage(0, 26);
|
||||
|
||||
//
|
||||
double bearishScore = mBearishScore[0];
|
||||
|
||||
//
|
||||
bool isScorePassed = IsScorePassedForLong();
|
||||
|
||||
//
|
||||
bool isRSIinOverSell =
|
||||
//
|
||||
mConditions.cMarketConditions.isRSIUnder30 &&
|
||||
mConditions.cMarketConditions.isRVILongStart &&
|
||||
mConditions.cMarketConditions.isCCIUnderNegativeHundred
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isBullishOverAVGs =
|
||||
//
|
||||
ArraySize(mBullishScore) > 100 &&
|
||||
bullishScore > mBullishScore[1] &&
|
||||
bullishScore > bearishScore &&
|
||||
bullishScore > bullish9AVG &&
|
||||
bullishScore > bullish17AVG &&
|
||||
bullishScore > bullish26AVG
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
isRSIinOverSell
|
||||
// &&
|
||||
// isBullishOverAVGs
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// result = result && isScorePassed;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
sl = GetMinVales();
|
||||
}
|
||||
|
||||
//
|
||||
double bearishScore = mBearishScore[0];
|
||||
double bearishMin100 = GetBearishScoreMin(0, 100);
|
||||
double bearishMax100 = GetBearishScoreMax(0, 100);
|
||||
double bearish9AVG = GetBearishScoreAverage(0, 9);
|
||||
double bearish17AVG = GetBearishScoreAverage(0, 17);
|
||||
double bearish26AVG = GetBearishScoreAverage(0, 26);
|
||||
|
||||
//
|
||||
double bullishScore = mBullishScore[0];
|
||||
|
||||
//
|
||||
bool isBearishOverAVGs =
|
||||
//
|
||||
ArraySize(mBearishScore) > 100 &&
|
||||
bearishScore > mBearishScore[1] &&
|
||||
bearishScore > bullishScore &&
|
||||
bearishScore > bearish9AVG &&
|
||||
bearishScore > bearish17AVG &&
|
||||
bearishScore > bearish26AVG
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isScorePassed = IsScorePassedForShort();
|
||||
|
||||
//
|
||||
bool isRSIOverBaought =
|
||||
mConditions.cMarketConditions.isRSIOver70 &&
|
||||
mConditions.cMarketConditions.isRVIShortStart &&
|
||||
mConditions.cMarketConditions.isCCIOverPositiveHundred;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
isRSIOverBaought
|
||||
// &&
|
||||
// isBearishOverAVGs
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// result = result && isScorePassed;
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
sl = GetMaxPeaks();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
bool isCICHLong =
|
||||
//
|
||||
(mConditions.cMarketConditions.isSenkouSpanAOverB &&
|
||||
mConditions.cMarketConditions.isCloseOverKijunSen &&
|
||||
mConditions.cMarketConditions.isSenkouSpanAOverLast &&
|
||||
mConditions.cMarketConditions.isTenkanSenCrossedOverKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSICHLong =
|
||||
//
|
||||
(mConditions.sMarketConditions.isSenkouSpanAOverB &&
|
||||
mConditions.sMarketConditions.isCloseOverKijunSen &&
|
||||
mConditions.sMarketConditions.isSenkouSpanAOverLast &&
|
||||
mConditions.sMarketConditions.isTenkanSenCrossedOverKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isMICHLong =
|
||||
//
|
||||
(mConditions.mMarketConditions.isSenkouSpanAOverB &&
|
||||
mConditions.mMarketConditions.isCloseOverKijunSen &&
|
||||
mConditions.mMarketConditions.isSenkouSpanAOverLast &&
|
||||
mConditions.mMarketConditions.isTenkanSenCrossedOverKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isLICHLong =
|
||||
//
|
||||
(mConditions.lMarketConditions.isSenkouSpanAOverB &&
|
||||
mConditions.lMarketConditions.isCloseOverKijunSen &&
|
||||
mConditions.lMarketConditions.isSenkouSpanAOverLast &&
|
||||
mConditions.lMarketConditions.isTenkanSenCrossedOverKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isHICHLong =
|
||||
//
|
||||
(mConditions.hMarketConditions.isSenkouSpanAOverB &&
|
||||
mConditions.hMarketConditions.isCloseOverKijunSen &&
|
||||
mConditions.hMarketConditions.isSenkouSpanAOverLast &&
|
||||
mConditions.hMarketConditions.isTenkanSenCrossedOverKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
// //
|
||||
// isCICHLong
|
||||
// //
|
||||
// ||
|
||||
//
|
||||
isSICHLong
|
||||
//
|
||||
||
|
||||
//
|
||||
isMICHLong
|
||||
//
|
||||
||
|
||||
//
|
||||
isLICHLong
|
||||
//
|
||||
||
|
||||
//
|
||||
isHICHLong
|
||||
//
|
||||
;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
bool isCICHShort =
|
||||
//
|
||||
(mConditions.cMarketConditions.isSenkouSpanAUnderB &&
|
||||
mConditions.cMarketConditions.isCloseUnderKijunSen &&
|
||||
mConditions.cMarketConditions.isSenkouSpanAUnderLast &&
|
||||
mConditions.cMarketConditions.isTenkanSenCrossedUnderKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSICHShort =
|
||||
//
|
||||
(mConditions.sMarketConditions.isSenkouSpanAUnderB &&
|
||||
mConditions.sMarketConditions.isCloseUnderKijunSen &&
|
||||
mConditions.sMarketConditions.isSenkouSpanAUnderLast &&
|
||||
mConditions.sMarketConditions.isTenkanSenCrossedUnderKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isMICHShort =
|
||||
//
|
||||
(mConditions.mMarketConditions.isSenkouSpanAUnderB &&
|
||||
mConditions.mMarketConditions.isCloseUnderKijunSen &&
|
||||
mConditions.mMarketConditions.isSenkouSpanAUnderLast &&
|
||||
mConditions.mMarketConditions.isTenkanSenCrossedUnderKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isLICHShort =
|
||||
//
|
||||
(mConditions.lMarketConditions.isSenkouSpanAUnderB &&
|
||||
mConditions.lMarketConditions.isCloseUnderKijunSen &&
|
||||
mConditions.lMarketConditions.isSenkouSpanAUnderLast &&
|
||||
mConditions.lMarketConditions.isTenkanSenCrossedUnderKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isHICHShort =
|
||||
//
|
||||
(mConditions.hMarketConditions.isSenkouSpanAUnderB &&
|
||||
mConditions.hMarketConditions.isCloseUnderKijunSen &&
|
||||
mConditions.hMarketConditions.isSenkouSpanAUnderLast &&
|
||||
mConditions.hMarketConditions.isTenkanSenCrossedUnderKijunSen)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
// //
|
||||
// isCICHShort
|
||||
// //
|
||||
// ||
|
||||
//
|
||||
isSICHShort
|
||||
//
|
||||
||
|
||||
//
|
||||
isMICHShort
|
||||
//
|
||||
||
|
||||
//
|
||||
isLICHShort
|
||||
//
|
||||
||
|
||||
//
|
||||
isHICHShort
|
||||
//
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user