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;
}
//
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 ...
int Index()
@@ -1370,6 +1438,58 @@ struct XOHCL
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)
{
+54
View File
@@ -683,6 +683,24 @@ class XCBarZone : public XCZone
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 ...
*
@@ -1003,6 +1021,24 @@ class XCTwoBarZone : public XCZone
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 ...
@@ -1203,6 +1239,24 @@ class XCSwing : public XCBasePOI
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 ...
*
@@ -1542,7 +1542,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
// Initialize POIs ...
//
int poiRequired = 10;
int poiRequired = 40;
//
// Trigger ...
@@ -53,6 +53,10 @@ class XC121SMCCycleHelper : public XCBase
// XCHSAR ...
XCXCHSARHelper *mXCHSARHelper;
//
// POI Detector ...
XCPOIDetector *mPOIDetector;
//
// Constructor(s) ...
XC121SMCCycleHelper()
@@ -192,6 +196,14 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
mPOIDetector = new XCPOIDetector(
symbol,
period //
);
mPOIDetector.MaxNumberOfRequiredPOIs(0);
mPOIDetector.Init();
//
// Initialize Bar Analyser Class Instance ...
mBarAnalyser = new XCBarAnalyser();
@@ -204,6 +216,61 @@ class XC121SMCCycleHelper : public XCBase
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 ...
*
@@ -620,59 +687,4 @@ class XC121SMCCycleHelper : public XCBase
//
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 visionConditions;
//
double sl;
string provider;
XCOrderBlock *visionBullOB;
XCOrderBlock *visionBearOB;
XCOrderBlock *consolidationBullOB;
XCOrderBlock *consolidationBearOB;
ENUM_X_DIRECTION marketStructureDir;
//
void X121SMCStrategyConditions()
{
@@ -767,6 +776,15 @@ struct X121SMCStrategyConditions
period = NULL;
time = NULL;
//
sl = 0;
provider = NULL;
visionBullOB = NULL;
visionBearOB = NULL;
consolidationBullOB = NULL;
consolidationBearOB = NULL;
marketStructureDir = X_DIRECTION_NONE;
//
triggerConditions.Clean();
decisionConditions.Clean();
@@ -795,6 +813,14 @@ struct X121SMCStrategyConditions
return result;
}
/**
* Check Conditions has Ddirection or not ...
*
* @param dir: ENUM_X_DIRECTIOn member ...
* @param bar: XOHCL instance ...
*
* @return ( bool )
*/
bool HasDirection(
ENUM_X_DIRECTION &dir,
XOHCL &bar //
File diff suppressed because it is too large Load Diff