cleanup unused collections and also disable drawings for memory improvement ...
This commit is contained in:
@@ -317,38 +317,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Trigger Order Flow ...
|
||||
XPVPivot mOrderFlow[];
|
||||
ENUM_X_DIRECTION mOrderFlowDir;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mTriggerPOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mTriggerCycleEvents[];
|
||||
XC121SMCCycleHelper *mTriggerCycleHelper;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mDecisionPOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mDecisionCycleEvents[];
|
||||
XC121SMCCycleHelper *mDecisionCycleHelper;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mAnalysePOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mAnalyseCycleEvents[];
|
||||
XC121SMCCycleHelper *mAnalyseCycleHelper;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mVerificationPOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mVerificationCycleEvents[];
|
||||
XC121SMCCycleHelper *mVerificationCycleHelper;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mConsolidationPOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mConsolidationCycleEvents[];
|
||||
XC121SMCCycleHelper *mConsolidationCycleHelper;
|
||||
|
||||
//
|
||||
ENUM_XPOI_EVENTS mVisionPOIEvents[];
|
||||
ENUM_X_CYCLE_EVENTS mVisionCycleEvents[];
|
||||
XC121SMCCycleHelper *mVisionCycleHelper;
|
||||
|
||||
//
|
||||
@@ -386,114 +359,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
conditions.symbol = symbol;
|
||||
conditions.period = period;
|
||||
|
||||
//
|
||||
int conditionsLoopback = 7;
|
||||
|
||||
//
|
||||
// Fill Cycles Conditions ...
|
||||
|
||||
//
|
||||
// Trigger ...
|
||||
result = mTriggerCycleHelper.GetConditions(
|
||||
mTriggerCycleEvents,
|
||||
mTriggerPOIEvents,
|
||||
conditions.triggerConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.triggerConditions.state = mTriggerState;
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
result = mDecisionCycleHelper.GetConditions(
|
||||
mDecisionCycleEvents,
|
||||
mDecisionPOIEvents,
|
||||
conditions.decisionConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.decisionConditions.state = mDecisionState;
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
result = mAnalyseCycleHelper.GetConditions(
|
||||
mAnalyseCycleEvents,
|
||||
mAnalysePOIEvents,
|
||||
conditions.analyseConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.analyseConditions.state = mAnalyseState;
|
||||
|
||||
//
|
||||
// Verification ...
|
||||
result = mVerificationCycleHelper.GetConditions(
|
||||
mVerificationCycleEvents,
|
||||
mVerificationPOIEvents,
|
||||
conditions.verificationConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.verificationConditions.state = mVerificationState;
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
result = mConsolidationCycleHelper.GetConditions(
|
||||
mConsolidationCycleEvents,
|
||||
mConsolidationPOIEvents,
|
||||
conditions.consolidationConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.consolidationConditions.state = mConsolidationState;
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
result = mVisionCycleHelper.GetConditions(
|
||||
mVisionCycleEvents,
|
||||
mVisionPOIEvents,
|
||||
conditions.visionConditions,
|
||||
zIndex,
|
||||
conditionsLoopback //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
conditions.Clean();
|
||||
return result;
|
||||
}
|
||||
conditions.visionConditions.state = mVisionState;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -552,56 +417,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
setupTime = mTestConditions.setupTime;
|
||||
}
|
||||
|
||||
// ClearDraws();
|
||||
// ENUM_X_DIRECTION activeZoneDir;
|
||||
// bool hasTicksZone = mTestConditions.HasTicksZone();
|
||||
// bool hasActiveZone = mTestConditions.HasActiveZone(activeZoneDir);
|
||||
// if (hasActiveZone)
|
||||
// {
|
||||
// //
|
||||
// if (IsBullish(activeZoneDir))
|
||||
// {
|
||||
// //
|
||||
// mTestConditions.activeDemandZone.To(cTime);
|
||||
// XCDemandZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateDemandZone(
|
||||
// mTestConditions.activeDemandZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// mTestConditions.activeSupplyZone.To(cTime);
|
||||
// XCSupplyZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateSupplyZone(
|
||||
// mTestConditions.activeSupplyZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (hasTicksZone)
|
||||
// {
|
||||
// //
|
||||
// XCTicksZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateTicksZone(
|
||||
// mTestConditions.ticksZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
result = isSetuped;
|
||||
if (!result)
|
||||
@@ -720,77 +535,77 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// Handle Required Drawings ...
|
||||
bool hasPivot = mXTWPVConditions.HasPivot();
|
||||
bool hasPriceInsideZone = mXTWPVConditions.HasPriceInsideZones();
|
||||
bool hasConsolidationZone = mXTWPVConditions.HasConsolidationZone();
|
||||
bool canDraw = hasPivot ||
|
||||
hasPriceInsideZone ||
|
||||
hasConsolidationZone;
|
||||
if (canDraw)
|
||||
{
|
||||
//
|
||||
ClearDraws();
|
||||
// bool hasPivot = mXTWPVConditions.HasPivot();
|
||||
// bool hasPriceInsideZone = mXTWPVConditions.HasPriceInsideZones();
|
||||
// bool hasConsolidationZone = mXTWPVConditions.HasConsolidationZone();
|
||||
// bool canDraw = hasPivot ||
|
||||
// hasPriceInsideZone ||
|
||||
// hasConsolidationZone;
|
||||
// if (canDraw)
|
||||
// {
|
||||
// //
|
||||
// ClearDraws();
|
||||
|
||||
//
|
||||
// Draw Consolidation Zone ...
|
||||
if (hasConsolidationZone)
|
||||
{
|
||||
//
|
||||
XCConsolidationZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateConsolidationZone(
|
||||
mXTWPVConditions.consolidationZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// // Draw Consolidation Zone ...
|
||||
// if (hasConsolidationZone)
|
||||
// {
|
||||
// //
|
||||
// XCConsolidationZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateConsolidationZone(
|
||||
// mXTWPVConditions.consolidationZone,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Draw Pivot Zone ...
|
||||
if (hasPivot)
|
||||
{
|
||||
//
|
||||
XCBaseObject *drawnObjects[];
|
||||
int drawnObjectsCount = DrawXTWPVPivotZone(
|
||||
mXTWPVConditions,
|
||||
mPOIDrawer,
|
||||
drawnObjects,
|
||||
false, // Draw State ...
|
||||
false, // Draw Ticks Zone ...
|
||||
true, // Ignore SwingHighs ...
|
||||
true, // Ignore SwingLows ...
|
||||
true, // Ignore SupportZones ...
|
||||
true, // Ignore ResistanceZones ...
|
||||
true, // Ignore SupplyZones ...
|
||||
true, // Ignore DemandZones ...
|
||||
true, // Ignore BullishOrderBlocks ...
|
||||
true, // Ignore BearishOrderBlocks ...
|
||||
true, // Ignore BullishFairValueGaps ...
|
||||
true, // Ignore BearishFairValueGaps ...
|
||||
true, // Ignore BullishRejectionBars ...
|
||||
true, // Ignore BearishRejectionBars ...
|
||||
true, // Ignore BullishMomentumBars ...
|
||||
true // Ignore BearishMomentumBars ...
|
||||
);
|
||||
AddObjectsIfNotExists(drawnObjects);
|
||||
}
|
||||
// //
|
||||
// // Draw Pivot Zone ...
|
||||
// if (hasPivot)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
// int drawnObjectsCount = DrawXTWPVPivotZone(
|
||||
// mXTWPVConditions,
|
||||
// mPOIDrawer,
|
||||
// drawnObjects,
|
||||
// false, // Draw State ...
|
||||
// false, // Draw Ticks Zone ...
|
||||
// true, // Ignore SwingHighs ...
|
||||
// true, // Ignore SwingLows ...
|
||||
// true, // Ignore SupportZones ...
|
||||
// true, // Ignore ResistanceZones ...
|
||||
// true, // Ignore SupplyZones ...
|
||||
// true, // Ignore DemandZones ...
|
||||
// true, // Ignore BullishOrderBlocks ...
|
||||
// true, // Ignore BearishOrderBlocks ...
|
||||
// true, // Ignore BullishFairValueGaps ...
|
||||
// true, // Ignore BearishFairValueGaps ...
|
||||
// true, // Ignore BullishRejectionBars ...
|
||||
// true, // Ignore BearishRejectionBars ...
|
||||
// true, // Ignore BullishMomentumBars ...
|
||||
// true // Ignore BearishMomentumBars ...
|
||||
// );
|
||||
// AddObjectsIfNotExists(drawnObjects);
|
||||
// }
|
||||
|
||||
//
|
||||
// Draw Price Inside Zones ...
|
||||
if (hasPriceInsideZone)
|
||||
{
|
||||
//
|
||||
XCBaseObject *drawnObjects[];
|
||||
int drawnObjectsCount = DrawTWPVPriceInsideZones(
|
||||
mXTWPVConditions,
|
||||
mPOIDrawer,
|
||||
drawnObjects //
|
||||
);
|
||||
AddObjectsIfNotExists(drawnObjects);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// // Draw Price Inside Zones ...
|
||||
// if (hasPriceInsideZone)
|
||||
// {
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
// int drawnObjectsCount = DrawTWPVPriceInsideZones(
|
||||
// mXTWPVConditions,
|
||||
// mPOIDrawer,
|
||||
// drawnObjects //
|
||||
// );
|
||||
// AddObjectsIfNotExists(drawnObjects);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
result = isSetuped;
|
||||
@@ -982,225 +797,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// SL Selector Methods ...
|
||||
|
||||
/**
|
||||
* Select Specified Type of Stop Loss ...
|
||||
*
|
||||
* @param conditions: X121SMCStrategyConditions instance Reference ...
|
||||
* @param forDir: ENUM_X_DIRECTION member, Signal Direction ...
|
||||
* @param type: ENUM_X_121_SMC_SL_TYPES member, Specified Required SL Type ...
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double SelectSL(
|
||||
X121SMCStrategyConditions &conditions,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
ENUM_X_121_SMC_SL_TYPES type //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
HasDirection(forDir) &&
|
||||
conditions.IsValid() &&
|
||||
type != X_121_SMC_SL_TYPE_NONE
|
||||
//
|
||||
;
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
bool isInited = zBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
0 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = IsBullish(forDir);
|
||||
|
||||
//
|
||||
if (type == X_121_SMC_SL_TYPE_FIBO_LEVEL_3)
|
||||
{
|
||||
result = conditions.triggerConditions.x121Conditions.fl3Buffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_FIBO_LEVEL_1_5)
|
||||
{
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? conditions.triggerConditions.x121Conditions.fl1Buffer[0]
|
||||
: conditions.triggerConditions.x121Conditions.fl5Buffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_DON_CLOSE_BOX)
|
||||
{
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? conditions.triggerConditions.x121Conditions.donCloseLowerBuffer[0]
|
||||
: conditions.triggerConditions.x121Conditions.donCloseUpperBuffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_SWING)
|
||||
{
|
||||
//
|
||||
int swingLowsCount = conditions.triggerConditions.state.CountSwingLows();
|
||||
int swingHighsCount = conditions.triggerConditions.state.CountSwingHighs();
|
||||
result =
|
||||
isBullish
|
||||
? conditions.triggerConditions.state.swingLows[swingLowsCount - 1].GetValue()
|
||||
: conditions.triggerConditions.state.swingHighs[swingHighsCount - 1].GetValue();
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_REJECTION)
|
||||
{
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? conditions.triggerConditions.state.bullishRejectionBars[conditions.triggerConditions.state.CountBullishRejectionBars() - 1].Lower()
|
||||
: conditions.triggerConditions.state.bearishRejectionBars[conditions.triggerConditions.state.CountBearishRejectionBars() - 1].Upper();
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_MOMENTUM)
|
||||
{
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? conditions.triggerConditions.state.bullishMomentumBars[conditions.triggerConditions.state.CountBullishMomentumBars() - 1].Lower()
|
||||
: conditions.triggerConditions.state.bearishMomentumBars[conditions.triggerConditions.state.CountBearishMomentumBars() - 1].Upper();
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_VWAP_FAST)
|
||||
{
|
||||
result = conditions.triggerConditions.x121Conditions.vwapFastBuffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_VWAP_MID)
|
||||
{
|
||||
result = conditions.triggerConditions.x121Conditions.vwapMidBuffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_VWAP_SLOW)
|
||||
{
|
||||
result = conditions.triggerConditions.x121Conditions.vwapSlowBuffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR)
|
||||
{
|
||||
result = conditions.triggerConditions.x121Conditions.sarBuffer[0];
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_TENKAN_SEN)
|
||||
{
|
||||
//
|
||||
double hh = zBar.FindHighest(
|
||||
9,
|
||||
MODE_HIGH //
|
||||
);
|
||||
double ll = zBar.FindLowest(
|
||||
9,
|
||||
MODE_LOW //
|
||||
);
|
||||
double mid = (hh - ll) / 2;
|
||||
result = isBullish
|
||||
? ll - mid
|
||||
: hh + mid;
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR_BOX ||
|
||||
type == X_121_SMC_SL_TYPE_LAST_SAR_CHANGED_BAR ||
|
||||
type == X_121_SMC_SL_TYPE_LAST_DIRECTIONAL_SAR)
|
||||
{
|
||||
//
|
||||
XOHCL cSarChangeBar;
|
||||
XOHCL pSarChangeBar;
|
||||
XValueChange cSarChange; // Current Sar Change (IsDirect) ...
|
||||
XValueChange pSarChange; // Prev Sar Change (Direct) ...
|
||||
XValueChange sarChanges[];
|
||||
int sarChangesCount = mTriggerCycleHelper
|
||||
.FillSarChanges(sarChanges);
|
||||
if (!IsValidSize(sarChangesCount) || sarChangesCount < 2)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
cSarChange = sarChanges[sarChangesCount - 1];
|
||||
pSarChange = sarChanges[sarChangesCount - 2];
|
||||
|
||||
//
|
||||
bool isFilled = cSarChange.FillBar(
|
||||
cSarChangeBar,
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
if (!isFilled)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
isFilled = pSarChange.FillBar(
|
||||
pSarChangeBar,
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
if (!isFilled)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (type == X_121_SMC_SL_TYPE_LAST_SAR_CHANGED_BAR)
|
||||
{
|
||||
//
|
||||
result = isBullish
|
||||
? pSarChangeBar.low
|
||||
: pSarChangeBar.high;
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_CURRENT_SAR_BOX)
|
||||
{
|
||||
//
|
||||
result =
|
||||
isBullish
|
||||
? zBar.FindLowest(
|
||||
MathAbs(cSarChangeBar.Index() - 1),
|
||||
MODE_LOW //
|
||||
)
|
||||
: zBar.FindHighest(
|
||||
MathAbs(cSarChangeBar.Index() - 1),
|
||||
MODE_HIGH //
|
||||
);
|
||||
}
|
||||
else if (type == X_121_SMC_SL_TYPE_LAST_DIRECTIONAL_SAR)
|
||||
{
|
||||
//
|
||||
XOHCL prevBar;
|
||||
bool isInited = cSarChangeBar.GetPreviousBar(prevBar);
|
||||
if (!isInited)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = isBullish
|
||||
? prevBar.low
|
||||
: prevBar.high;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user