last works ...

This commit is contained in:
2024-12-02 03:11:52 +03:30
parent 4d472bf7e8
commit de90f2d5fb
10 changed files with 5360 additions and 1374 deletions
File diff suppressed because it is too large Load Diff
+214
View File
@@ -0,0 +1,214 @@
//
// Draw Last Sar Change ...
string iVLineName = sarChangeBar.GetTag("XSAR");
CChartObjectVLine *iVLineObj;
iVLineObj = new CChartObjectVLine();
result = iVLineObj.Create(
ChartID(),
iVLineName,
0,
sarChangeBar.time //
);
if (result)
{
iVLineObj.Color(clrYellow);
}
//
// Draw Last Decision Bar ...
string iVLineNameDecision = decisionBar.GetTag("XDECISION");
CChartObjectVLine *iVLineDecisionObj;
iVLineDecisionObj = new CChartObjectVLine();
result = iVLineDecisionObj.Create(
ChartID(),
iVLineNameDecision,
0,
decisionBar.time //
);
if (result)
{
iVLineDecisionObj.Color(clrYellow);
}
//
// Draw Breaker Bar ...
string iVLineNameBreaker = breakerBar.GetTag("XBREAKER");
CChartObjectVLine *iVLineBreakerObj;
iVLineBreakerObj = new CChartObjectVLine();
result = iVLineBreakerObj.Create(
ChartID(),
iVLineNameBreaker,
0,
breakerBar.time //
);
if (result)
{
iVLineBreakerObj.Color(clrMagenta);
}
//
// TODO: Remove This ...
bool ignoreSwingHighs = true;
bool ignoreSwingLows = true;
bool ignoreSupportZones = true;
bool ignoreResistanceZones = true;
bool ignoreSupplyZones = true;
bool ignoreDemandZones = true;
bool ignoreBullishOrderBlocks = true;
bool ignoreBearishOrderBlocks = true;
bool ignoreBullishFairValueGaps = true;
bool ignoreBearishFairValueGaps = true;
bool ignoreBullishRejectionBars = true;
bool ignoreBearishRejectionBars = true;
bool ignoreBullishMomentumBars = true;
bool ignoreBearishMomentumBars = true;
//
if (IsBullish(marketStructureDir))
{
//
ignoreSwingLows = true;
ignoreSupportZones = true;
ignoreDemandZones = true;
ignoreBullishOrderBlocks = true;
ignoreBullishFairValueGaps = false;
ignoreBullishRejectionBars = false;
ignoreBullishMomentumBars = false;
//
ignoreSwingHighs = true;
ignoreResistanceZones = true;
ignoreSupplyZones = true;
ignoreBearishOrderBlocks = true;
ignoreBearishFairValueGaps = true;
ignoreBearishRejectionBars = true;
ignoreBearishMomentumBars = true;
}
else
{
//
ignoreSwingLows = true;
ignoreSupportZones = true;
ignoreDemandZones = true;
ignoreBullishOrderBlocks = true;
ignoreBullishFairValueGaps = true;
ignoreBullishRejectionBars = true;
ignoreBullishMomentumBars = true;
//
ignoreSwingHighs = true;
ignoreResistanceZones = true;
ignoreSupplyZones = true;
ignoreBearishOrderBlocks = true;
ignoreBearishFairValueGaps = false;
ignoreBearishRejectionBars = false;
ignoreBearishMomentumBars = false;
}
//
RedrawOrderFlow(
true, // Force Clean ...
false, // Same Period ...
true, // Order Flow ...
true, // Order Flow State ...
false, // Only Last Order Flow ...
true, // Only Last Order Flow State ...
//
marketStructureDir, // Direction Force ...
ignoreSwingHighs,
ignoreSwingLows,
ignoreSupportZones,
ignoreResistanceZones,
ignoreSupplyZones,
ignoreDemandZones,
ignoreBullishOrderBlocks,
ignoreBearishOrderBlocks,
ignoreBullishFairValueGaps,
ignoreBearishFairValueGaps,
ignoreBullishRejectionBars,
ignoreBearishRejectionBars,
ignoreBullishMomentumBars,
ignoreBearishMomentumBars //
);
/////////////////////////////////////////////////////
/**
* Validate an Order Block is Not Touched ...
*
* @param bar: XOHCL instance, start bar ...
*
* @return ( bool )
*/
bool ValidateOrderBlock(
XCOrderBlock *ob,
XOHCL &bar //
)
{
//
bool result = false;
//
result =
bar.IsValid() &&
ob.IsValid();
if (!result)
{
return result;
}
//
bool isBullish = ob.IsBullish();
//
XOHCL mBar;
result = bar.BarIn(ob.GetPeriod(), mBar);
if (!result) {
return result;
}
//
int start = mBar.Index();
int end = mBar.Index(ob.From());
result = IsValidIndex(start) &&
IsValidIndex(end);
if (!result)
{
return result;
}
//
for (int i = start; i < end; i++)
{
//
XOHCL iBar;
result = mBar.BarAt(
i,
iBar //
);
if (!result)
{
break;
}
//
result =
isBullish
? iBar.low > ob.Upper()
: iBar.high < ob.Lower();
if (!result)
{
break;
}
}
//
return result;
}
+113
View File
@@ -2148,3 +2148,116 @@
// //
} }
////////////////////////////////////////
bool canContinue = true;
while (canContinue)
{
//
XOHCL iBar;
bool isBarInited = iBar.Init(
mBar.symbol,
mBar.period,
barIndex //
);
if (!isBarInited)
{
break;
}
//
if (bullOB == NULL)
{
//
XCOrderBlock *ob;
bool isBullOB = cycleHelper
.mPOIDetector
.DetectBullishOrderBlock(
mBar,
ob //
);
if (isBullOB)
{
//
bool isPricePassed = bar.low > ob.Upper();
if (isPricePassed)
{
//
if (mBullOB == NULL)
{
//
mBullOB = ob;
}
else
{
//
bool isRefined = mBullOB.Upper() < ob.Upper();
if (isRefined)
{
mBullOB = ob;
}
}
}
}
}
//
if (bearOB == NULL)
{
//
XCOrderBlock *ob;
bool isBearOB = cycleHelper
.mPOIDetector
.DetectBearishOrderBlock(
mBar,
ob //
);
if (isBearOB)
{
//
bool isPricePassed = bar.high < ob.Lower();
if (isPricePassed)
{
//
if (mBearOB == NULL)
{
//
mBearOB = ob;
}
else
{
//
bool isRefined = mBearOB.Lower() > ob.Lower();
if (isRefined)
{
mBearOB = ob;
}
}
}
}
}
//
canContinue =
(bullOB == NULL && mBullOB == NULL) ||
(bearOB == NULL && mBearOB == NULL);
if (canContinue)
{
barIndex++;
}
}
//
if (mBullOB != NULL)
{
bullOB = mBullOB;
}
//
if (mBearOB != NULL)
{
bearOB = mBearOB;
}
File diff suppressed because it is too large Load Diff
+120
View File
@@ -1345,6 +1345,74 @@ struct XOHCL
return result; return result;
} }
//
bool BarAt(
int index,
XOHCL &bar //
)
{
//
bool result = false;
//
bar.Clean();
//
result = IsValid();
if (!result)
{
return result;
}
//
if (index < 0)
{
index = 0;
}
//
result = bar.Init(
symbol,
period,
index //
);
//
return result;
}
//
bool BarIn(
ENUM_TIMEFRAMES _period,
XOHCL &bar //
)
{
//
bool result = false;
//
bar.Clean();
//
result = IsValid() &&
IsSpecifiedValid(_period);
if (!result)
{
return result;
}
//
int index = Index(_period);
result = bar.Init(
symbol,
_period,
index //
);
//
return result;
}
// //
// Find Current Bar Index on Chart ... // Find Current Bar Index on Chart ...
int Index() int Index()
@@ -1370,6 +1438,58 @@ struct XOHCL
return result; return result;
} }
//
int Index(datetime value)
{
//
int result = -1;
//
value = NormalizeTime(value);
//
result = IsValid();
if (!result)
{
return result;
}
//
result = iBarShift(
symbol,
period,
value //
);
//
return result;
}
//
int Index(ENUM_TIMEFRAMES value)
{
//
int result = -1;
//
result = IsValid() &&
IsSpecifiedValid(value);
if (!result)
{
return result;
}
//
result = iBarShift(
symbol,
value,
time //
);
//
return result;
}
// //
bool GetNextBar(XOHCL &bar) bool GetNextBar(XOHCL &bar)
{ {
+54
View File
@@ -683,6 +683,24 @@ class XCBarZone : public XCZone
return result; return result;
} }
ENUM_TIMEFRAMES GetPeriod() {
//
ENUM_TIMEFRAMES result = NULL;
//
XOHCL bar;
bool isFilled = FillBar(bar);
if (!isFilled) {
return result;
}
//
result = bar.period;
//
return result;
}
/** /**
* Set From Date ... * Set From Date ...
* *
@@ -1003,6 +1021,24 @@ class XCTwoBarZone : public XCZone
return result; return result;
} }
ENUM_TIMEFRAMES GetPeriod() {
//
ENUM_TIMEFRAMES result = NULL;
//
XOHCL bar;
bool isFilled = FillStartBar(bar);
if (!isFilled) {
return result;
}
//
result = bar.period;
//
return result;
}
// //
// Overrides ... // Overrides ...
@@ -1203,6 +1239,24 @@ class XCSwing : public XCBasePOI
return result; return result;
} }
ENUM_TIMEFRAMES GetPeriod() {
//
ENUM_TIMEFRAMES result = NULL;
//
XOHCL bar;
bool isFilled = FillBar(bar);
if (!isFilled) {
return result;
}
//
result = bar.period;
//
return result;
}
/** /**
* Check Swing High or not ... * Check Swing High or not ...
* *
@@ -1542,7 +1542,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
// Initialize POIs ... // Initialize POIs ...
// //
int poiRequired = 10; int poiRequired = 40;
// //
// Trigger ... // Trigger ...
@@ -53,6 +53,10 @@ class XC121SMCCycleHelper : public XCBase
// XCHSAR ... // XCHSAR ...
XCXCHSARHelper *mXCHSARHelper; XCXCHSARHelper *mXCHSARHelper;
//
// POI Detector ...
XCPOIDetector *mPOIDetector;
// //
// Constructor(s) ... // Constructor(s) ...
XC121SMCCycleHelper() XC121SMCCycleHelper()
@@ -192,6 +196,14 @@ class XC121SMCCycleHelper : public XCBase
return result; return result;
} }
//
mPOIDetector = new XCPOIDetector(
symbol,
period //
);
mPOIDetector.MaxNumberOfRequiredPOIs(0);
mPOIDetector.Init();
// //
// Initialize Bar Analyser Class Instance ... // Initialize Bar Analyser Class Instance ...
mBarAnalyser = new XCBarAnalyser(); mBarAnalyser = new XCBarAnalyser();
@@ -204,6 +216,61 @@ class XC121SMCCycleHelper : public XCBase
return result; return result;
} }
/**
* Get Specified Bar ...
*
* @param source: XOHCL instance, Source Bar ...
* @param bar: XOHCL instance, Dest Bar ...
*
* @return ( bool )
*/
bool GetBar(
XOHCL &source,
XOHCL &bar //
)
{
//
bool result = false;
//
bar.Clean();
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
result =
IsValid(symbol) &&
IsValid(period) &&
source.IsValid();
if (!result)
{
return result;
}
//
int index = iBarShift(
symbol,
period,
source.time //
);
result = bar.Init(
symbol,
period,
index //
);
if (!result)
{
//
bar.Clean();
return result;
}
//
return result;
}
/** /**
* Retrieve Cycle Conditions ... * Retrieve Cycle Conditions ...
* *
@@ -620,59 +687,4 @@ class XC121SMCCycleHelper : public XCBase
// //
return result; return result;
} }
/**
* Get Specified Bar ...
*
* @param source: XOHCL instance, Source Bar ...
* @param bar: XOHCL instance, Dest Bar ...
*
* @return ( bool )
*/
bool GetBar(
XOHCL &source,
XOHCL &bar //
)
{
//
bool result = false;
//
bar.Clean();
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
result =
IsValid(symbol) &&
IsValid(period) &&
source.IsValid();
if (!result)
{
return result;
}
//
int index = iBarShift(
symbol,
period,
source.time //
);
result = bar.Init(
symbol,
period,
index //
);
if (!result)
{
//
bar.Clean();
return result;
}
//
return result;
}
}; };
+26
View File
@@ -748,6 +748,15 @@ struct X121SMCStrategyConditions
X121SMCCycleConditions consolidationConditions; X121SMCCycleConditions consolidationConditions;
X121SMCCycleConditions visionConditions; X121SMCCycleConditions visionConditions;
//
double sl;
string provider;
XCOrderBlock *visionBullOB;
XCOrderBlock *visionBearOB;
XCOrderBlock *consolidationBullOB;
XCOrderBlock *consolidationBearOB;
ENUM_X_DIRECTION marketStructureDir;
// //
void X121SMCStrategyConditions() void X121SMCStrategyConditions()
{ {
@@ -767,6 +776,15 @@ struct X121SMCStrategyConditions
period = NULL; period = NULL;
time = NULL; time = NULL;
//
sl = 0;
provider = NULL;
visionBullOB = NULL;
visionBearOB = NULL;
consolidationBullOB = NULL;
consolidationBearOB = NULL;
marketStructureDir = X_DIRECTION_NONE;
// //
triggerConditions.Clean(); triggerConditions.Clean();
decisionConditions.Clean(); decisionConditions.Clean();
@@ -795,6 +813,14 @@ struct X121SMCStrategyConditions
return result; return result;
} }
/**
* Check Conditions has Ddirection or not ...
*
* @param dir: ENUM_X_DIRECTIOn member ...
* @param bar: XOHCL instance ...
*
* @return ( bool )
*/
bool HasDirection( bool HasDirection(
ENUM_X_DIRECTION &dir, ENUM_X_DIRECTION &dir,
XOHCL &bar // XOHCL &bar //
@@ -115,69 +115,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// Start Calculations ... // Start Calculations ...
// //
string _symbol = GetSymbol(); string symbol = GetSymbol();
ENUM_TIMEFRAMES _period = GetPeriod(); ENUM_TIMEFRAMES period = GetPeriod();
// //
double points = GetPoints(_symbol); double points = GetPoints(symbol);
double pip = GetPipPrice(_symbol); double pip = GetPipPrice(symbol);
double pip2 = 2 * pip; double pip2 = 2 * pip;
//
datetime cTime = TimeCurrent();
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
//
// Retrieve Bars ...
//
// Zero Bar ...
XOHCL zBar;
result = zBar.Init(
_symbol,
_period,
zIndex //
);
if (!result)
{
return result;
}
//
// Last Bar ...
XOHCL cBar;
result = cBar.Init(
_symbol,
_period,
cIndex //
);
if (!result)
{
return result;
}
//
// Previous Bar ...
XOHCL pBar;
result = pBar.Init(
_symbol,
_period,
pIndex //
);
if (!result)
{
return result;
}
//
// Prepare Areas ...
double bid = GetBid(_symbol);
// //
// Check Spread ... // Check Spread ...
bool isSpreadPassed = IsSpreadPass(); bool isSpreadPassed = IsSpreadPass();
@@ -197,23 +142,26 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
result = DetectConditions(conditions); result = DetectConditions(conditions);
if (!result) if (!result)
{ {
conditions.Clean();
return result; return result;
} }
// //
// Combine all Signals Conditions ... // Combine all Signals Conditions ...
selectedSL = conditions.sl;
provider = conditions.provider;
// //
hasLong = hasLong =
// //
false IsBullish(conditions.marketStructureDir)
// //
; ;
// //
hasShort = hasShort =
// //
false IsBearish(conditions.marketStructureDir)
// //
; ;
@@ -267,8 +215,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
signal.mode = mode; signal.mode = mode;
signal.entry = entry; signal.entry = entry;
signal.volume = volume; signal.volume = volume;
signal.symbol = _symbol; signal.symbol = symbol;
signal.period = _period; signal.period = period;
signal.pushers = pushers; signal.pushers = pushers;
signal.provider = provider; signal.provider = provider;
signal.time = TimeCurrent(); signal.time = TimeCurrent();
@@ -439,9 +387,16 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
// //
string msg = NULL;
//
double bid = GetBid(symbol);
datetime cTime = TimeCurrent();
//
conditions.time = cTime;
conditions.symbol = symbol; conditions.symbol = symbol;
conditions.period = period; conditions.period = period;
conditions.time = TimeCurrent();
// //
int conditionsLoopback = 7; int conditionsLoopback = 7;
@@ -504,12 +459,18 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
conditions.visionConditions.state = mVisionState; conditions.visionConditions.state = mVisionState;
// //
// Check Market Conditions for // Detect an Order Block in Vision ...
// Specified Structure ... if (conditions.visionBullOB == NULL ||
ENUM_X_DIRECTION marketStructureDir = X_DIRECTION_NONE; conditions.visionBearOB == NULL)
result = conditions.HasDirection( {
marketStructureDir, //
cBar // result = DetectOrderBlocks(
NULL,
NULL,
conditions.visionBullOB,
conditions.visionBearOB,
cBar,
mVisionState //
); );
if (!result) if (!result)
{ {
@@ -518,10 +479,84 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
return result; return result;
} }
//
XCBullishOrderBlockObject *iBullOBObj;
conditions.visionBullOB.To(cTime);
result = mPOIDrawer.CreateBullishOrderBlock(
conditions.visionBullOB,
iBullOBObj //
);
if (result)
{
AddObjectIfNotExists(iBullOBObj);
}
//
XCBearishOrderBlockObject *iBearOBObj;
conditions.visionBearOB.To(cTime);
result = mPOIDrawer.CreateBearishOrderBlock(
conditions.visionBearOB,
iBearOBObj //
);
if (result)
{
AddObjectIfNotExists(iBearOBObj);
}
}
//
// Consolidation Order Blocks ...
if (conditions.consolidationBullOB == NULL ||
conditions.consolidationBearOB == NULL)
{
//
result = DetectOrderBlocks(
conditions.visionBullOB,
conditions.visionBearOB,
conditions.consolidationBullOB,
conditions.consolidationBearOB,
cBar,
mConsolidationState //
);
if (!result)
{
//
conditions.Clean();
return result;
}
//
XCBullishOrderBlockObject *iBullOBObj;
conditions.consolidationBullOB.To(cTime);
result = mPOIDrawer.CreateBullishOrderBlock(
conditions.consolidationBullOB,
iBullOBObj //
);
if (result)
{
AddObjectIfNotExists(iBullOBObj);
}
//
XCBearishOrderBlockObject *iBearOBObj;
conditions.consolidationBearOB.To(cTime);
result = mPOIDrawer.CreateBearishOrderBlock(
conditions.consolidationBearOB,
iBearOBObj //
);
if (result)
{
AddObjectIfNotExists(iBearOBObj);
}
}
//
msg = "OrderBlocks Detected ...";
Alert(msg);
// //
// Detect Trigger Order Flow ... // Detect Trigger Order Flow ...
if (ArraySize(mOrderFlow) == 0 || if (!HasValidOrderFlow())
mOrderFlowDir == X_DIRECTION_NONE)
{ {
// //
int samePivots = 40; int samePivots = 40;
@@ -554,14 +589,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
); );
// //
result = IsValidSize(ArraySize(mOrderFlow)); result = HasValidOrderFlow();
if (!result)
{
return result;
}
}
result = HasValidOrderFlow() &&
mOrderFlowDir == marketStructureDir;
if (!result) if (!result)
{ {
// //
@@ -570,66 +598,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
// //
// Detect Nearest Sar Change ...
XOHCL sarChangeBar;
result = mTriggerCycleHelper.DetectNearestCSARChange(
sarChangeBar,
cBar //
);
if (!result)
{
//
conditions.Clean();
return result;
}
//
// Draw Last Sar Change ...
string iVLineName = sarChangeBar.GetTag("XSAR");
CChartObjectVLine *iVLineObj;
iVLineObj = new CChartObjectVLine();
result = iVLineObj.Create(
ChartID(),
iVLineName,
0,
sarChangeBar.time //
);
if (result)
{
iVLineObj.Color(clrYellow);
}
//
// Detect Nearest Momentum or Rejection Bar ...
XOHCL decisionBar;
result = mDecisionCycleHelper.DetectNearestDecisionBar(
decisionBar,
marketStructureDir,
cBar //
);
if (!result)
{
return result;
}
//
// Draw Last Decision Bar ...
string iVLineNameDecision = decisionBar.GetTag("XDECISION");
CChartObjectVLine *iVLineDecisionObj;
iVLineDecisionObj = new CChartObjectVLine();
result = iVLineDecisionObj.Create(
ChartID(),
iVLineNameDecision,
0,
decisionBar.time //
);
if (result)
{
iVLineDecisionObj.Color(clrYellow);
}
//
// TODO: Remove This ...
bool ignoreSwingHighs = true; bool ignoreSwingHighs = true;
bool ignoreSwingLows = true; bool ignoreSwingLows = true;
bool ignoreSupportZones = true; bool ignoreSupportZones = true;
@@ -645,58 +613,16 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
bool ignoreBullishMomentumBars = true; bool ignoreBullishMomentumBars = true;
bool ignoreBearishMomentumBars = true; bool ignoreBearishMomentumBars = true;
//
if (IsBullish(marketStructureDir))
{
//
ignoreSwingLows = true;
ignoreSupportZones = true;
ignoreDemandZones = true;
ignoreBullishOrderBlocks = true;
ignoreBullishFairValueGaps = false;
ignoreBullishRejectionBars = false;
ignoreBullishMomentumBars = false;
//
ignoreSwingHighs = true;
ignoreResistanceZones = true;
ignoreSupplyZones = true;
ignoreBearishOrderBlocks = true;
ignoreBearishFairValueGaps = true;
ignoreBearishRejectionBars = true;
ignoreBearishMomentumBars = true;
}
else
{
//
ignoreSwingLows = true;
ignoreSupportZones = true;
ignoreDemandZones = true;
ignoreBullishOrderBlocks = true;
ignoreBullishFairValueGaps = true;
ignoreBullishRejectionBars = true;
ignoreBullishMomentumBars = true;
//
ignoreSwingHighs = true;
ignoreResistanceZones = true;
ignoreSupplyZones = true;
ignoreBearishOrderBlocks = true;
ignoreBearishFairValueGaps = false;
ignoreBearishRejectionBars = false;
ignoreBearishMomentumBars = false;
}
// //
RedrawOrderFlow( RedrawOrderFlow(
true, // Force Clean ... false, // Force Clean ...
false, // Same Period ... false, // Same Period ...
true, // Order Flow ... true, // Order Flow ...
true, // Order Flow State ... true, // Order Flow State ...
false, // Only Last Order Flow ... false, // Only Last Order Flow ...
true, // Only Last Order Flow State ... true, // Only Last Order Flow State ...
// //
marketStructureDir, // Direction Force ... mOrderFlowDir, // Direction Force ...
ignoreSwingHighs, ignoreSwingHighs,
ignoreSwingLows, ignoreSwingLows,
ignoreSupportZones, ignoreSupportZones,
@@ -712,10 +638,150 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
ignoreBullishMomentumBars, ignoreBullishMomentumBars,
ignoreBearishMomentumBars // ignoreBearishMomentumBars //
); );
}
// //
// Here we Have to Detect Entry Conditions ... msg = "Found OrderFlow : " + (IsBullish(mOrderFlowDir) ? "Bullish" : "Berish");
// TODO: Implement this ... Alert(msg);
//
// Check Market Conditions for
// Specified Structure ...
// ENUM_X_DIRECTION marketStructureDir = X_DIRECTION_NONE;
// result = conditions.HasDirection(
// marketStructureDir,
// cBar //
// );
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
// msg = "Found Market Strucutre : " + (IsBullish(marketStructureDir) ? "Bullish" : "Berish");
// Alert(msg);
//
// conditions.marketStructureDir = marketStructureDir;
// //
// XPVPivot lastPivot;
// result = GetLastItem(
// lastPivot,
// mOrderFlow //
// );
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
//
// Detect Last FVG ...
// XOHCL breakerBar;
// result = DetectLastBreakerBar(
// cBar,
// breakerBar,
// lastPivot,
// marketStructureDir //
// );
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
// msg = "Found Breaker Bar: " + breakerBar.GetTag();
// Alert(msg);
// //
// // Detect Nearest Momentum or Rejection Bar ...
// XOHCL decisionBar;
// result = mDecisionCycleHelper.DetectNearestDecisionBar(
// decisionBar,
// marketStructureDir,
// cBar //
// );
// if (!result)
// {
// return result;
// }
// msg = "Found Decision Bar: " + decisionBar.GetTag();
// Alert(msg);
// //
// // Detect Nearest Sar Change ...
// XOHCL sarChangeBar;
// result = mTriggerCycleHelper.DetectNearestCSARChange(
// sarChangeBar,
// cBar //
// );
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
// msg = "Found Sar Change Bar: " + sarChangeBar.GetTag();
// Alert(msg);
// //
// // Now we Hvae to Check Other Conditions ...
// result =
// // breakerBar.time > sarChangeBar.time &&
// // decisionBar.time > breakerBar.time;
// decisionBar.time > sarChangeBar.time;
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
// //
// // Now we Have Check Direction Related Conditions ...
// if (IsBullish(marketStructureDir))
// {
// //
// result =
// // bid > decisionBar.high &&
// // bid > breakerBar.high &&
// bid > sarChangeBar.high &&
// bid > conditions.triggerConditions.xchsarConditions.cSars[0];
// }
// else
// {
// //
// result =
// // bid < decisionBar.low &&
// // bid < breakerBar.low &&
// bid < sarChangeBar.high &&
// bid < conditions.triggerConditions.xchsarConditions.cSars[0];
// }
// if (!result)
// {
// //
// conditions.Clean();
// return result;
// }
// //
// conditions.provider = "X121SMC";
// if (IsBullish(marketStructureDir))
// {
// //
// // conditions.sl = decisionBar.low;
// // conditions.sl = breakerBar.low;
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
// }
// else
// {
// //
// // conditions.sl = decisionBar.high;
// // conditions.sl = breakerBar.high;
// conditions.sl = conditions.triggerConditions.xchsarConditions.cSars[0];
// }
// //
if (!result) if (!result)
@@ -1430,6 +1496,425 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
ClearDraws(); ClearDraws();
} }
/**
* Detect Breaker Bar ...
*
* @param bar: XOHCL instance ...
* @param breakerBar: XOHCL instance, Breaker Bar ...
* @param pivot: XPVPivot instance ...
* @param forDir: ENUM_X_DIRECTION member, Market Structure Direction ...
*
* @return ( bool )
*/
bool DetectLastBreakerBar(
XOHCL &bar,
XOHCL &breakerBar,
XPVPivot &pivot,
ENUM_X_DIRECTION forDir //
)
{
//
bool result = false;
//
result =
bar.IsValid() &&
pivot.IsValid() &&
forDir != X_DIRECTION_ALL &&
forDir != X_DIRECTION_NONE;
if (!result)
{
return result;
}
//
// FVG ...
result = DetectLastFVGBreakerBar(
bar,
breakerBar,
pivot,
forDir //
);
if (result)
{
return result;
}
//
// Order Block ...
// result = DetectLastOBBreakerBar(
// bar,
// breakerBar,
// pivot,
// forDir //
// );
// if (result)
// {
// return result;
// }
//
return result;
}
bool DetectLastFVGBreakerBar(
XOHCL &bar,
XOHCL &breakerBar,
XPVPivot &pivot,
ENUM_X_DIRECTION forDir //
)
{
//
bool result = false;
//
result =
bar.IsValid() &&
pivot.IsValid() &&
forDir != X_DIRECTION_ALL &&
forDir != X_DIRECTION_NONE;
if (!result)
{
return result;
}
//
bool isBullishDir = IsBullish(forDir);
//
int fvgsCount =
isBullishDir
? pivot.state.CountBullishFairValueGaps()
: pivot.state.CountBearishFairValueGaps();
result = IsValidSize(fvgsCount);
if (!result)
{
return result;
}
//
int idx = -1;
XCFVG *zone = NULL;
for (int i = 0; i < fvgsCount; i++)
{
//
if (isBullishDir)
{
//
// Bullish FVG ...
if (zone == NULL)
{
//
zone = pivot.state.bullishFairValueGaps[i];
//
bool isBreaked = CheckZoneBreak(
forDir,
bar,
breakerBar,
zone //
);
if (isBreaked)
{
idx = i;
}
}
else
{
//
bool isNewer = ((int)zone.From() - (int)bar.time) > ((int)pivot.state.bullishFairValueGaps[i].From() - (int)bar.time);
if (isNewer)
{
//
zone = pivot.state.bullishFairValueGaps[i];
//
bool isBreaked = CheckZoneBreak(
forDir,
bar,
breakerBar,
zone //
);
if (isBreaked)
{
idx = i;
}
}
}
}
else
{
//
// Bearish FVG ...
if (zone == NULL)
{
//
zone = pivot.state.bearishFairValueGaps[i];
//
bool isBreaked = CheckZoneBreak(
forDir,
bar,
breakerBar,
zone //
);
if (isBreaked)
{
idx = i;
}
}
else
{
//
bool isNewer = ((int)zone.From() - (int)bar.time) > ((int)pivot.state.bearishFairValueGaps[i].From() - (int)bar.time);
if (isNewer)
{
//
zone = pivot.state.bearishFairValueGaps[i];
//
bool isBreaked = CheckZoneBreak(
forDir,
bar,
breakerBar,
zone //
);
if (isBreaked)
{
idx = i;
}
}
}
}
}
//
result =
breakerBar.IsValid() &&
IsValidIndex(idx) &&
zone.IsValid();
if (!result)
{
return result;
}
//
return result;
}
/**
* Check an FVG is Breaked or not ...
*
* @param forDir: ENUM_X_DIRECTION member, Market Structure Direction ...
* @param bar: XOHCL instance ...
* @param breakerBar: XOHCL instance, Breaker Bar ...
*
* @return ( bool )
*/
bool CheckZoneBreak(
ENUM_X_DIRECTION forDir,
XOHCL &bar,
XOHCL &breakerBar,
XCFVG *&zone //
)
{
//
bool result = false;
//
breakerBar.Clean();
//
result = bar.IsValid() &&
zone.IsValid() &&
forDir != X_DIRECTION_ALL &&
forDir != X_DIRECTION_NONE;
if (!result)
{
return result;
}
//
int start = bar.Index();
int end = iBarShift(
bar.symbol,
bar.period,
zone.From());
for (int i = start; i < end; i++)
{
//
XOHCL iBar;
result = iBar.Init(
bar.symbol,
bar.period,
i //
);
if (!result)
{
break;
}
//
if (IsBullish(forDir))
{
//
// Bullish Break ...
result = iBar.low < zone.Upper() &&
iBar.high > zone.Upper() &&
iBar.GetDown() < zone.Upper() &&
iBar.GetUp() > zone.Upper() &&
iBar.IsBullish();
}
else
{
//
// Bearish Break ...
result = iBar.low < zone.Lower() &&
iBar.high > zone.Lower() &&
iBar.GetDown() < zone.Lower() &&
iBar.GetUp() > zone.Lower() &&
iBar.IsBearish();
}
//
if (result)
{
//
breakerBar = iBar;
break;
}
}
//
result = breakerBar.IsValid();
//
return result;
}
/**
* Detect most Upper and Lower Order Blocks ...
*
* @return ( bool )
*/
bool DetectOrderBlocks(
XCOrderBlock *bullOBBoundary,
XCOrderBlock *bearOBBoundary,
XCOrderBlock *&bullOB,
XCOrderBlock *&bearOB,
XOHCL &bar,
XPOIState &state //
)
{
//
bool result = false;
//
result = bar.IsValid() &&
state.IsValid();
if (!result)
{
return result;
}
//
XCOrderBlock *mBullOB = NULL;
if (bullOB == NULL)
{
//
for (int i = 0; i < state.CountBullishOrderBlocks(); i++)
{
//
XCOrderBlock *ob = state.bullishOrderBlocks[i];
bool isPricePassed = bar.low > ob.Upper();
if (isPricePassed)
{
//
bool isBoundaryPassed =
bullOBBoundary == NULL
? true
: ob.Lower() < bullOBBoundary.Upper();
if (isBoundaryPassed)
{
//
if (mBullOB == NULL)
{
mBullOB = ob;
}
else
{
//
bool isRefined =
mBullOB.Upper() < ob.Upper();
if (isRefined)
{
mBullOB = ob;
}
}
}
}
}
//
if (mBullOB != NULL)
{
bullOB = mBullOB;
}
}
//
XCOrderBlock *mBearOB = NULL;
if (bearOB == NULL)
{
//
for (int i = 0; i < state.CountBearishOrderBlocks(); i++)
{
//
XCOrderBlock *ob = state.bearishOrderBlocks[i];
bool isPricePassed = bar.high < ob.Lower();
if (isPricePassed)
{
//
bool isBoundaryPassed =
bearOBBoundary == NULL
? true
: ob.Upper() > bearOBBoundary.Lower();
if (isBoundaryPassed)
{
//
if (mBearOB == NULL)
{
mBearOB = ob;
}
else
{
//
bool isRefined =
mBearOB.Lower() > ob.Lower();
if (isRefined)
{
mBearOB = ob;
}
}
}
}
}
//
if (mBearOB != NULL)
{
bearOB = mBearOB;
}
}
//
result = bullOB != NULL &&
bearOB != NULL;
//
return result;
}
// //
// Drawings ... // Drawings ...
@@ -2452,6 +2937,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
x3maInputs.Default(); x3maInputs.Default();
//
// x3maInputs.fastLength = 10;
// x3maInputs.midLength = 25;
// x3maInputs.slowLength = 50;
// //
x3maInputs.showFast = true; x3maInputs.showFast = true;
x3maInputs.showMid = false; x3maInputs.showMid = false;
@@ -2464,6 +2954,11 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
x3vwapInputs.Default(); x3vwapInputs.Default();
//
// x3vwapInputs.fastLength = 10;
// x3vwapInputs.midLength = 25;
// x3vwapInputs.slowLength = 50;
// //
x3vwapInputs.showFast = true; x3vwapInputs.showFast = true;
x3vwapInputs.showMid = true; x3vwapInputs.showMid = true;