338 lines
10 KiB
Plaintext
338 lines
10 KiB
Plaintext
//
|
|
double cPZoneUpper = 0;
|
|
double cPZoneLower = 0;
|
|
datetime cPZoneFrom = NULL;
|
|
datetime cPZoneTo = NULL;
|
|
result = consolidationPriceZone.GetBoxData(
|
|
X_DIRECTION_ALL,
|
|
cPZoneUpper,
|
|
cPZoneLower,
|
|
cPZoneFrom,
|
|
cPZoneTo //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
double aPZoneUpper = 0;
|
|
double aPZoneLower = 0;
|
|
datetime aPZoneFrom = NULL;
|
|
datetime aPZoneTo = NULL;
|
|
result = analysePriceZone.GetBoxData(
|
|
X_DIRECTION_ALL,
|
|
aPZoneUpper,
|
|
aPZoneLower,
|
|
aPZoneFrom,
|
|
aPZoneTo //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
|
|
//
|
|
// RSI ...
|
|
double rsi = decisionConditions.x121Conditions.rsiBuffer[1];
|
|
|
|
//
|
|
bool isRSIOverBought = decisionConditions.x121Conditions.isRSIOverBought;
|
|
bool isRSICrossedOverOverBought = decisionConditions.x121Conditions.isRSICrossedOverOverBought;
|
|
bool isRSICrossedUnderOverBought = decisionConditions.x121Conditions.isRSICrossedUnderOverBought;
|
|
|
|
//
|
|
bool isRSIOverSold = decisionConditions.x121Conditions.isRSIOverSold;
|
|
bool isRSICrossedOverOverSold = decisionConditions.x121Conditions.isRSICrossedOverOverSold;
|
|
bool isRSICrossedUnderOverSold = decisionConditions.x121Conditions.isRSICrossedUnderOverSold;
|
|
|
|
//
|
|
// PV ...
|
|
double peak = decisionConditions.x121Conditions.peaksBuffer[1];
|
|
double vale = decisionConditions.x121Conditions.valesBuffer[1];
|
|
|
|
//
|
|
bool isNewPeak = decisionConditions.x121Conditions.isNewPeak;
|
|
bool isNewPeakOverLast = decisionConditions.x121Conditions.isNewPeakOverLast;
|
|
bool isNewPeakUnderLast = decisionConditions.x121Conditions.isNewPeakUnderLast;
|
|
|
|
//
|
|
bool isNewVale = decisionConditions.x121Conditions.isNewVale;
|
|
bool isNewValeOverLast = decisionConditions.x121Conditions.isNewValeOverLast;
|
|
bool isNewValeUnderLast = decisionConditions.x121Conditions.isNewValeUnderLast;
|
|
|
|
//
|
|
// STR ...
|
|
double str = decisionConditions.x121Conditions.strBuffer[1];
|
|
|
|
//
|
|
bool isStrBullish = decisionConditions.x121Conditions.isStrBullish;
|
|
bool isStrBearish = decisionConditions.x121Conditions.isStrBearish;
|
|
|
|
//
|
|
bool isStrSwitchedToBullish = decisionConditions.x121Conditions.isStrSwitchedToBullish;
|
|
bool isStrSwitchedToBearish = decisionConditions.x121Conditions.isStrSwitchedToBearish;
|
|
|
|
//
|
|
// ATR ...
|
|
double atr = decisionConditions.x121Conditions.atrBuffer[1];
|
|
double atrUpper = decisionConditions.x121Conditions.atrUpperBuffer[1];
|
|
double atrLower = decisionConditions.x121Conditions.atrLowerBuffer[1];
|
|
|
|
//
|
|
bool isCloseOverATRUpper = decisionConditions.x121Conditions.isCloseOverATRUpper;
|
|
bool isCloseOverATRLower = decisionConditions.x121Conditions.isCloseOverATRLower;
|
|
|
|
//
|
|
bool isCloseUnderATRUpper = decisionConditions.x121Conditions.isCloseUnderATRUpper;
|
|
bool isCloseUnderATRLower = decisionConditions.x121Conditions.isCloseUnderATRLower;
|
|
|
|
//
|
|
bool isRejectUpATRUpper = decisionConditions.x121Conditions.isRejectUpATRUpper;
|
|
bool isRejectDownATRUpper = decisionConditions.x121Conditions.isRejectDownATRUpper;
|
|
|
|
//
|
|
bool isRejectUpATRLower = decisionConditions.x121Conditions.isRejectUpATRLower;
|
|
bool isRejectDownATRLower = decisionConditions.x121Conditions.isRejectDownATRLower;
|
|
|
|
//
|
|
bool isBreakUpATRUpper = decisionConditions.x121Conditions.isBreakUpATRUpper;
|
|
bool isBreakDownATRUpper = decisionConditions.x121Conditions.isBreakDownATRUpper;
|
|
|
|
//
|
|
bool isBreakUpATRLower = decisionConditions.x121Conditions.isBreakUpATRLower;
|
|
bool isBreakDownATRLower = decisionConditions.x121Conditions.isBreakDownATRLower;
|
|
|
|
//
|
|
// SAR ...
|
|
double sar = decisionConditions.x121Conditions.sarBuffer[1];
|
|
|
|
//
|
|
bool isSarBullish = decisionConditions.x121Conditions.isSarBullish;
|
|
bool isSarBearish = decisionConditions.x121Conditions.isSarBearish;
|
|
|
|
//
|
|
bool isSarSwitchedToBullish = decisionConditions.x121Conditions.isSarSwitchedToBullish;
|
|
bool isSarSwitchedToBearish = decisionConditions.x121Conditions.isSarSwitchedToBearish;
|
|
|
|
//
|
|
// DON ...
|
|
|
|
//
|
|
double donOpenUpper = decisionConditions.x121Conditions.donOpenUpperBuffer[1];
|
|
double donOpenLower = decisionConditions.x121Conditions.donOpenLowerBuffer[1];
|
|
double donHighUpper = decisionConditions.x121Conditions.donHighUpperBuffer[1];
|
|
double donHighLower = decisionConditions.x121Conditions.donHighLowerBuffer[1];
|
|
double donLowUpper = decisionConditions.x121Conditions.donLowUpperBuffer[1];
|
|
double donLowLower = decisionConditions.x121Conditions.donLowLowerBuffer[1];
|
|
double donCloseUpper = decisionConditions.x121Conditions.donCloseUpperBuffer[1];
|
|
double donCloseLower = decisionConditions.x121Conditions.donCloseLowerBuffer[1];
|
|
|
|
//
|
|
bool isRejectDonOpenUpper = decisionConditions.x121Conditions.isRejectDonOpenUpper;
|
|
bool isRejectDonHighUpper = decisionConditions.x121Conditions.isRejectDonHighUpper;
|
|
bool isRejectDonLowUpper = decisionConditions.x121Conditions.isRejectDonLowUpper;
|
|
bool isRejectDonCloseUpper = decisionConditions.x121Conditions.isRejectDonCloseUpper;
|
|
|
|
//
|
|
bool isRejectDonOpenLower = decisionConditions.x121Conditions.isRejectDonOpenLower;
|
|
bool isRejectDonHighLower = decisionConditions.x121Conditions.isRejectDonHighLower;
|
|
bool isRejectDonLowLower = decisionConditions.x121Conditions.isRejectDonLowLower;
|
|
bool isRejectDonCloseLower = decisionConditions.x121Conditions.isRejectDonCloseLower;
|
|
|
|
//
|
|
bool isBreakDonOpenUpper = decisionConditions.x121Conditions.isBreakDonOpenUpper;
|
|
bool isBreakDonHighUpper = decisionConditions.x121Conditions.isBreakDonHighUpper;
|
|
bool isBreakDonLowUpper = decisionConditions.x121Conditions.isBreakDonLowUpper;
|
|
bool isBreakDonCloseUpper = decisionConditions.x121Conditions.isBreakDonCloseUpper;
|
|
|
|
//
|
|
bool isBreakDonOpenLower = decisionConditions.x121Conditions.isBreakDonOpenLower;
|
|
bool isBreakDonHighLower = decisionConditions.x121Conditions.isBreakDonHighLower;
|
|
bool isBreakDonLowLower = decisionConditions.x121Conditions.isBreakDonLowLower;
|
|
bool isBreakDonCloseLower = decisionConditions.x121Conditions.isBreakDonCloseLower;
|
|
|
|
//
|
|
// VWAP ...
|
|
|
|
//
|
|
// COMPLEX ...
|
|
// Complex Conditions ...
|
|
|
|
//
|
|
bool isNewPeakOverATRUpper =
|
|
isNewPeak &&
|
|
peak > atrUpper;
|
|
|
|
//
|
|
bool isNewValeUnderATRLower =
|
|
isNewVale &&
|
|
vale < atrLower;
|
|
|
|
//
|
|
bool isDonHighUpperEqualsToPeak =
|
|
donHighUpper == peak;
|
|
|
|
//
|
|
bool isDonLowLowerEqualsToVale =
|
|
donLowLower == vale;
|
|
|
|
//
|
|
bool isBullishSign = (
|
|
//
|
|
triggerConditions.x121Conditions.isBreakUpATRLower ||
|
|
triggerConditions.x121Conditions.isRejectUpATRLower ||
|
|
triggerConditions.x121Conditions.isBreakDonHighLower ||
|
|
triggerConditions.x121Conditions.isRejectDonHighLower ||
|
|
triggerConditions.x121Conditions.isBreakDonCloseLower ||
|
|
triggerConditions.x121Conditions.isRejectDonCloseLower
|
|
//
|
|
);
|
|
bool isBearishSign = (
|
|
//
|
|
triggerConditions.x121Conditions.isBreakDownATRUpper ||
|
|
triggerConditions.x121Conditions.isRejectDownATRUpper ||
|
|
triggerConditions.x121Conditions.isBreakDonLowUpper ||
|
|
triggerConditions.x121Conditions.isRejectDonLowUpper ||
|
|
triggerConditions.x121Conditions.isBreakDonCloseUpper ||
|
|
triggerConditions.x121Conditions.isRejectDonCloseUpper
|
|
//
|
|
);
|
|
|
|
|
|
|
|
//
|
|
// Check RSI in Over Bought or Over Sold ...
|
|
|
|
//
|
|
bool isRSICrossedOverOverSold = consolidationConditions.x121Conditions.isRSICrossedOverOverSold;
|
|
bool isRSICrossedUnderOverBought = consolidationConditions.x121Conditions.isRSICrossedUnderOverBought;
|
|
|
|
//
|
|
result = isRSICrossedOverOverSold ||
|
|
isRSICrossedUnderOverBought;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
* Draw X121 SMC Conditions ...
|
|
*
|
|
* @param conditions: X121SMCStrategyConditions instance Reference ...
|
|
* @param drawMarketStructure: Boolean ...
|
|
* @param drawPriceZones: Boolean ...
|
|
* @param drawDecisionZones: Boolean ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int DrawX121SMCStrategyConditions(
|
|
X121SMCStrategyConditions &conditions,
|
|
XCBaseObject *&drawnObjects[],
|
|
XCPOIDrawer *drawer,
|
|
bool drawMarketStructure = true,
|
|
bool drawPriceZones = true,
|
|
bool drawDecisionZones = true,
|
|
bool drawOnlyPriceZonesBoundary = true //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(drawnObjects);
|
|
|
|
//
|
|
if (drawer == NULL ||
|
|
!conditions.IsValid() ||
|
|
!HasDirection(conditions.signalDir))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish = IsBullish(conditions.signalDir);
|
|
|
|
// //
|
|
// bool hasPriceZones = conditions.priceZones.IsValid();
|
|
// if (hasPriceZones &&
|
|
// drawPriceZones)
|
|
// {
|
|
// //
|
|
// XCBaseObject *objects[];
|
|
// int objectsCount = drawer.DrawPriceZone(
|
|
// conditions.priceZones,
|
|
// objects,
|
|
// conditions.signalDir,
|
|
// drawOnlyPriceZonesBoundary //
|
|
// );
|
|
// if (IsValidSize(objectsCount))
|
|
// {
|
|
// //
|
|
// Copy(
|
|
// objects,
|
|
// drawnObjects,
|
|
// false //
|
|
// );
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// bool hasDecisionZones = conditions.decisionZones.IsValid();
|
|
// if (hasDecisionZones &&
|
|
// drawDecisionZones)
|
|
// {
|
|
// //
|
|
// XCBaseObject *objects[];
|
|
// int objectsCount = drawer.DrawPriceZone(
|
|
// conditions.decisionZones,
|
|
// objects,
|
|
// conditions.signalDir,
|
|
// drawOnlyPriceZonesBoundary //
|
|
// );
|
|
// if (IsValidSize(objectsCount))
|
|
// {
|
|
// //
|
|
// Copy(
|
|
// objects,
|
|
// drawnObjects,
|
|
// false //
|
|
// );
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// bool hasMarketStructure = conditions.marketStructure.IsValid();
|
|
// if (hasMarketStructure &&
|
|
// drawMarketStructure)
|
|
// {
|
|
// //
|
|
// XCBaseObject *objects[];
|
|
// int objectsCount = drawer.DrawMarketStructure(
|
|
// conditions.marketStructure,
|
|
// objects //
|
|
// );
|
|
// if (IsValidSize(objectsCount))
|
|
// {
|
|
// //
|
|
// Copy(
|
|
// objects,
|
|
// drawnObjects,
|
|
// false //
|
|
// );
|
|
// }
|
|
// }
|
|
|
|
//
|
|
result = ArraySize(drawnObjects);
|
|
|
|
//
|
|
return result;
|
|
}
|