434 lines
11 KiB
Plaintext
434 lines
11 KiB
Plaintext
|
|
/**
|
|
* Draw Conditions ...
|
|
*
|
|
* @param conditions: X121SMCStrategyConditions instance ...
|
|
*/
|
|
void DrawConditions(X121SMCStrategyConditions &conditions)
|
|
{
|
|
//
|
|
XC121SMCConditionsObject *iObj;
|
|
iObj = new XC121SMCConditionsObject(mPOIDrawer);
|
|
bool isCreated = iObj.CreateByConditions(
|
|
ChartIdentification(),
|
|
conditions.GetTag(true),
|
|
SubWindowIdentification(),
|
|
conditions //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Market Structure ...
|
|
*
|
|
* @param structure: X121SMCMarketStructure instance ...
|
|
*/
|
|
void DrawMarketStructure(X121SMCMarketStructure &structure)
|
|
{
|
|
//
|
|
XC121SMCMarketStructureObject *iObj;
|
|
iObj = new XC121SMCMarketStructureObject(mPOIDrawer);
|
|
bool isCreated = iObj.CreateByStructure(
|
|
ChartIdentification(),
|
|
structure.GetTag(),
|
|
SubWindowIdentification(),
|
|
structure //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
mDrawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Detect Valid Market Conditions ...
|
|
*
|
|
* @param conditions: X121SMCStrategyConditions instance ...
|
|
*
|
|
* @return ( virtual bool )
|
|
*/
|
|
virtual bool DetecConditions(X121SMCStrategyConditions &conditions)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
conditions.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Detect Market Structure based on Conditions ...
|
|
*
|
|
* @param structure: X121SMCMarketStructure instance ...
|
|
* @param conditions: X121SMCStrategyConditions instance ...
|
|
*/
|
|
virtual void DetectMarketStructure(
|
|
X121SMCMarketStructure &structure,
|
|
X121SMCStrategyConditions &conditions //
|
|
)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Remove Specific Conditions if Exists ...
|
|
*
|
|
* @param conditions: X121SMCStrategyConditions instance ...
|
|
*/
|
|
virtual void RemoveConditionsIfExists(X121SMCStrategyConditions &conditions)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Search Conditions for Find SL Candidates ...
|
|
*
|
|
* @param candidates: Double Array ...
|
|
* @param entry: Double ...
|
|
* @param structure: X121SMCStrategyConditions instance ...
|
|
* @param type: ENUM_X_POSITION_TYPES member ...
|
|
*
|
|
* @return ( virtual int )
|
|
*/
|
|
virtual int DetectSLCandidates(
|
|
double &candidates[],
|
|
double entry,
|
|
X121SMCStrategyConditions &conditions,
|
|
ENUM_X_POSITION_TYPES type //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
if (type == X_POSITION_TYPE_NONE ||
|
|
type == X_POSITION_TYPE_ALL)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool useSwings = true;
|
|
bool useMomentumBars = true;
|
|
bool useRejectionBars = true;
|
|
|
|
//
|
|
Clean(candidates);
|
|
|
|
//
|
|
XOHCL candidateBars[];
|
|
if (type == X_POSITION_TYPE_LONG)
|
|
{
|
|
//
|
|
// Search Bullish Momentum, Rejection Bars and Swing Lows ...
|
|
|
|
//
|
|
// Swing Lows ...
|
|
if (useSwings)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.swingLows,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bullish Momentum Bars ...
|
|
if (useMomentumBars)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.bullishMomentumBars,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bullish Rejection Bars ...
|
|
if (useRejectionBars)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.bullishRejectionBars,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(candidateBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = candidateBars[i];
|
|
|
|
//
|
|
if (iBar.low < entry)
|
|
{
|
|
//
|
|
Add(
|
|
iBar.low,
|
|
candidates //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (type == X_POSITION_TYPE_SHORT)
|
|
{
|
|
//
|
|
// Search Bearish Momentum, Rejection Bars and Swing Highs ...
|
|
|
|
//
|
|
// Swing Highs ...
|
|
if (useSwings)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.swingHighs,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bearish Momentum Bars ...
|
|
if (useMomentumBars)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.bearishMomentumBars,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Bearish Rejection Bars ...
|
|
if (useRejectionBars)
|
|
{
|
|
//
|
|
Copy(
|
|
conditions.bearishRejectionBars,
|
|
candidateBars,
|
|
false //
|
|
);
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(candidateBars);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XOHCL iBar = candidateBars[i];
|
|
|
|
//
|
|
if (iBar.high > entry)
|
|
{
|
|
//
|
|
Add(
|
|
iBar.low,
|
|
candidates //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(candidateBars);
|
|
result = ArraySize(candidates);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
XZone h4Supply;
|
|
XZone m15Supply;
|
|
XZone m5Supply;
|
|
|
|
//
|
|
int h4Count = ArraySize(_15MState.supplyZones);
|
|
int m15Count = ArraySize(_5MState.supplyZones);
|
|
int m5Count = ArraySize(_1MState.supplyZones);
|
|
|
|
//
|
|
bool has4HSupplyZone = false;
|
|
bool has15mSupplyZone = false;
|
|
bool has5mSupplyZone = false;
|
|
|
|
//
|
|
// for (int i = 0; i < h4Count; i++)
|
|
// {
|
|
// //
|
|
// XZone iZone = _15MState.supplyZones[i];
|
|
|
|
// //
|
|
// bool canRefineI = CanRefineZone(
|
|
// iZone,
|
|
// h4Supply,
|
|
// cBar //
|
|
// );
|
|
// if (canRefineI)
|
|
// {
|
|
// //
|
|
// h4Supply = iZone;
|
|
|
|
// //
|
|
// for (int j = 0; j < m15Count; j++)
|
|
// {
|
|
// //
|
|
// XZone jZone = _5MState.supplyZones[j];
|
|
|
|
// //
|
|
// bool canRefineJ = CanRefineZone(
|
|
// iZone,
|
|
// m15Supply,
|
|
// cBar //
|
|
// );
|
|
// if (canRefineJ)
|
|
// {
|
|
// //
|
|
// m15Supply = jZone;
|
|
|
|
// //
|
|
// for (int k = 0; k < m5Count; k++)
|
|
// {
|
|
// //
|
|
// XZone kZone = _1MState.supplyZones[k];
|
|
|
|
// //
|
|
// bool canRefineK = CanRefineZone(
|
|
// kZone,
|
|
// m5Supply,
|
|
// cBar //
|
|
// );
|
|
// if (canRefineK)
|
|
// {
|
|
// //
|
|
// m5Supply = kZone;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
for (int i = 0; i < m15Count; i++)
|
|
{
|
|
//
|
|
XZone iZone = _5MState.supplyZones[i];
|
|
|
|
//
|
|
bool canRefineI = CanRefineZone(
|
|
iZone,
|
|
m15Supply,
|
|
cBar //
|
|
);
|
|
if (canRefineI)
|
|
{
|
|
//
|
|
m15Supply = iZone;
|
|
|
|
//
|
|
for (int j = 0; j < m5Count; j++)
|
|
{
|
|
//
|
|
XZone jZone = _1MState.supplyZones[j];
|
|
|
|
//
|
|
bool canRefineJ = CanRefineZone(
|
|
iZone,
|
|
m5Supply,
|
|
cBar //
|
|
);
|
|
if (canRefineJ)
|
|
{
|
|
m5Supply = jZone;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// has4HSupplyZone = h4Supply.IsValid();
|
|
has15mSupplyZone = m15Supply.IsValid();
|
|
has5mSupplyZone = m5Supply.IsValid();
|
|
|
|
//
|
|
bool hasSupply =
|
|
// has4HSupplyZone &&
|
|
has15mSupplyZone &&
|
|
has5mSupplyZone;
|
|
|
|
//
|
|
if (hasSupply)
|
|
{
|
|
//
|
|
m15Supply.to = cTime;
|
|
m5Supply.to = cTime;
|
|
|
|
//
|
|
mConditions.supplyZone = m5Supply;
|
|
|
|
//
|
|
XCSupplyZoneObject *i5Obj;
|
|
bool isCreated = mPOIDrawer.CreateSupplyZone(
|
|
m5Supply,
|
|
i5Obj //
|
|
);
|
|
|
|
//
|
|
XCSupplyZoneObject *i15Obj;
|
|
isCreated = mPOIDrawer.CreateSupplyZone(
|
|
m15Supply,
|
|
i15Obj //
|
|
);
|
|
|
|
// //
|
|
// XCSupplyZoneObject *i4Obj;
|
|
// isCreated = mPOIDrawer.CreateSupplyZone(
|
|
// h4Supply,
|
|
// i4Obj //
|
|
// );
|
|
|
|
//
|
|
Print("Supply Detected ...");
|
|
}
|