This commit is contained in:
2024-11-02 05:52:16 +03:30
parent cc57a5eca8
commit 4362b1aeaf
9 changed files with 1893 additions and 16 deletions
+6 -3
View File
@@ -799,6 +799,9 @@ class XCSignalObject : public XCBaseObject
return result; return result;
} }
//
string nameMD5 = ToMD5(name);
// //
int delay = (PeriodSeconds(signal.period) * 2); int delay = (PeriodSeconds(signal.period) * 2);
datetime time1 = (datetime)((int)signal.time - delay); datetime time1 = (datetime)((int)signal.time - delay);
@@ -806,7 +809,7 @@ class XCSignalObject : public XCBaseObject
// //
// TP ... // TP ...
string tpName = ToString(X_TP) + "_" + name; string tpName = ToString(X_TP) + "_" + nameMD5;
result = mTPTrend.Create( result = mTPTrend.Create(
chart_id, chart_id,
tpName, tpName,
@@ -823,7 +826,7 @@ class XCSignalObject : public XCBaseObject
// //
// SL ... // SL ...
string slName = ToString(X_SL) + "_" + name; string slName = ToString(X_SL) + "_" + nameMD5;
result = mSLTrend.Create( result = mSLTrend.Create(
chart_id, chart_id,
slName, slName,
@@ -842,7 +845,7 @@ class XCSignalObject : public XCBaseObject
// //
// ENTRY ... // ENTRY ...
string entrName = ToString(X_ENTRY) + "_" + name; string entrName = ToString(X_ENTRY) + "_" + nameMD5;
result = mEntryTrend.Create( result = mEntryTrend.Create(
chart_id, chart_id,
entrName, entrName,
+6 -2
View File
@@ -1738,7 +1738,8 @@ class XCPOIDrawer : public XSCBase
*/ */
bool CreateResistanceZone( bool CreateResistanceZone(
XOHCL &bar, XOHCL &bar,
XCResistanceZoneObject *&object // XCResistanceZoneObject *&object,
datetime destTime = NULL //
) )
{ {
// //
@@ -1762,7 +1763,10 @@ class XCPOIDrawer : public XSCBase
string name = bar.GetTag(ToString(X_POI_RESISTANCE_ZONE)); string name = bar.GetTag(ToString(X_POI_RESISTANCE_ZONE));
// //
datetime time2 = (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5)); datetime time2 =
IsValid(destTime)
? destTime
: (datetime)((int)bar.time + (PeriodSeconds(bar.period) * 5));
// //
bool fill = ResistanceZoneFill(); bool fill = ResistanceZoneFill();
File diff suppressed because it is too large Load Diff
+13
View File
@@ -276,6 +276,13 @@ void OnSignalRecieved(
{ {
// //
// TODO: Implement this ... // TODO: Implement this ...
//
ENUM_X_SIGNAL_EXECUTION_RESULT state;
eaTrader.ExecuteSignal(
signal,
state //
);
} }
// //
@@ -446,6 +453,9 @@ bool InitEA()
_Period // _Period //
); );
//
iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved);
// //
ConfigureStrategy(iX121SMCStrategy); ConfigureStrategy(iX121SMCStrategy);
RegisterStrategy(iX121SMCStrategy); RegisterStrategy(iX121SMCStrategy);
@@ -508,6 +518,9 @@ bool InitEA()
_Period // _Period //
); );
//
iX121SMCStrategy.AddXSignalEventHandler(OnSignalRecieved);
// //
// Register Strategy ... // Register Strategy ...
ConfigureStrategy(iX121SMCStrategy); ConfigureStrategy(iX121SMCStrategy);
+10 -9
View File
@@ -538,39 +538,40 @@ struct XOHCL
time = iTime( time = iTime(
mSymbol, mSymbol,
mPeriod, mPeriod,
barIndex barIndex //
//
); );
// //
open = iOpen( open = iOpen(
mSymbol, mSymbol,
mPeriod, mPeriod,
barIndex barIndex //
//
); );
open = NormalizePrice(open, mSymbol);
// //
close = iClose( close = iClose(
mSymbol, mSymbol,
mPeriod, mPeriod,
barIndex barIndex //
//
); );
close = NormalizePrice(close, mSymbol);
// //
high = iHigh( high = iHigh(
mSymbol, mSymbol,
mPeriod, mPeriod,
barIndex); barIndex //
);
high = NormalizePrice(high, mSymbol);
// //
low = iLow( low = iLow(
mSymbol, mSymbol,
mPeriod, mPeriod,
barIndex barIndex //
//
); );
low = NormalizePrice(low, mSymbol);
// //
bool result = IsValid(); bool result = IsValid();
+361 -2
View File
@@ -436,6 +436,45 @@ struct XZone
return result; return result;
} }
//
double GetRange()
{
//
double result = 0;
//
if (!IsValid())
{
return result;
}
//
result = upper - lower;
//
return result;
}
//
double GetMiddle()
{
//
double result = 0;
//
double range = GetRange();
if (range <= 0)
{
return result;
}
//
result = lower + (range / 2);
//
return result;
}
// //
string GetTag() string GetTag()
{ {
@@ -1730,11 +1769,12 @@ bool IsInside(
double upper = double upper =
edge == X_ZONE_UPPER_EDGE edge == X_ZONE_UPPER_EDGE
? source.high ? source.high
: source.GetDown(); : source.GetUp();
double lower = double lower =
edge == X_ZONE_UPPER_EDGE edge == X_ZONE_UPPER_EDGE
? source.GetUp() ? source.GetDown()
: source.low; : source.low;
result = iSource.Init( result = iSource.Init(
upper, upper,
lower, lower,
@@ -1759,9 +1799,328 @@ bool IsInside(
return result; return result;
} }
/**
* Check a Zone is Between to other Zones ...
*
* @param source: XZone instance ...
* @param upper: XZone instance ...
* @param lower: XZone instance ...
*
* @return ( bool )
*/
bool IsBetween(
XZone &source,
XZone &upper,
XZone &lower //
)
{
//
bool result = false;
//
result = source.IsValid();
if (!result)
{
return result;
}
//
bool isUpperValid = upper.IsValid();
bool isLowerValid = lower.IsValid();
//
result = isUpperValid ||
isLowerValid;
if (!result)
{
return result;
}
//
if (isUpperValid)
{
//
result = source.upper < upper.lower;
if (!result)
{
return result;
}
}
//
if (isLowerValid)
{
//
result = source.lower > lower.upper;
if (!result)
{
return result;
}
}
//
return result;
}
bool IsBetween(
XOHCL &source,
XZone &upper,
XZone &lower //
)
{
//
bool result = false;
//
result = source.IsValid();
if (!result)
{
return result;
}
//
bool isUpperValid = upper.IsValid();
bool isLowerValid = lower.IsValid();
//
result = isUpperValid ||
isLowerValid;
if (!result)
{
return result;
}
//
if (isUpperValid)
{
//
result = source.high < upper.lower;
if (!result)
{
return result;
}
}
//
if (isLowerValid)
{
//
result = source.low > lower.upper;
if (!result)
{
return result;
}
}
//
return result;
}
// //
// State Extensions ... // State Extensions ...
/**
* Normalize and Combine States ...
*
* @param dest: XPOIState instance ...ّ
* @param states: XPOIState instance ...ّ
*/
void CombineStates(
XPOIState &dest,
XPOIState &states[] //
)
{
//
dest.Clean();
//
int count = ArraySize(states);
if (!IsValidSize(count))
{
return;
}
//
for (int i = 0; i < count; i++)
{
//
XPOIState iState = states[i];
//
dest.symbol = iState.symbol;
dest.period =
!IsValid(dest.period) ||
PeriodSeconds(dest.period) < PeriodSeconds(iState.period)
? iState.period
: dest.period;
dest.reportedAt =
!IsValid(dest.reportedAt) ||
dest.reportedAt > iState.reportedAt
? iState.reportedAt
: dest.reportedAt;
//
// Demand ...
int iCount = ArraySize(iState.demandZones);
if (IsValidSize(iCount))
{
//
Copy(
iState.demandZones,
dest.demandZones,
false //
);
}
//
// Supply ...
iCount = ArraySize(iState.supplyZones);
if (IsValidSize(iCount))
{
//
Copy(
iState.supplyZones,
dest.supplyZones,
false //
);
}
//
// Order Blocks ...
//
iCount = ArraySize(iState.bullishOrderBlocks);
if (IsValidSize(iCount))
{
//
Copy(
iState.bullishOrderBlocks,
dest.bullishOrderBlocks,
false //
);
}
//
iCount = ArraySize(iState.bearishOrderBlocks);
if (IsValidSize(iCount))
{
//
Copy(
iState.bearishOrderBlocks,
dest.bearishOrderBlocks,
false //
);
}
//
// Fair Value Gaps ...
//
iCount = ArraySize(iState.bullishFVGs);
if (IsValidSize(iCount))
{
//
Copy(
iState.bullishFVGs,
dest.bullishFVGs,
false //
);
}
//
iCount = ArraySize(iState.bearishFVGs);
if (IsValidSize(iCount))
{
//
Copy(
iState.bearishFVGs,
dest.bearishFVGs,
false //
);
}
//
// Supports ...
iCount = ArraySize(iState.supportZones);
if (IsValidSize(iCount))
{
//
Copy(
iState.supportZones,
dest.supportZones,
false //
);
}
//
// Resistances ...
iCount = ArraySize(iState.resistanceZones);
if (IsValidSize(iCount))
{
//
Copy(
iState.resistanceZones,
dest.resistanceZones,
false //
);
}
//
// Swings ...
//
// Swing Highs ...
iCount = ArraySize(iState.swingHighs);
if (IsValidSize(iCount))
{
//
Copy(
iState.swingHighs,
dest.swingHighs,
false //
);
}
//
// Swing Lows ...
iCount = ArraySize(iState.swingLows);
if (IsValidSize(iCount))
{
//
Copy(
iState.swingLows,
dest.swingLows,
false //
);
}
//
// Momentum Bars ...
iCount = ArraySize(iState.momentumBars);
if (IsValidSize(iCount))
{
//
Copy(
iState.momentumBars,
dest.momentumBars,
false //
);
}
//
// Rejection Bars ...
iCount = ArraySize(iState.rejectionBars);
if (IsValidSize(iCount))
{
//
Copy(
iState.rejectionBars,
dest.rejectionBars,
false //
);
}
}
}
/** /**
* Check State has Bullish Trend or not ... * Check State has Bullish Trend or not ...
* *
@@ -0,0 +1 @@
// Complete this ...
+85
View File
@@ -121,6 +121,34 @@ struct X121SMCStrategyConditions
Clean(bullishRejectionBars); Clean(bullishRejectionBars);
} }
void CleanDemand()
{
//
demandZone.Clean();
//
Clean(supports);
Clean(swingLows);
Clean(bullishFVGs);
Clean(bullishOrderBlocks);
Clean(bullishMomentumBars);
Clean(bullishRejectionBars);
}
void CleanSupply()
{
//
supplyZone.Clean();
//
Clean(swingHighs);
Clean(resistances);
Clean(bearishFVGs);
Clean(bearishOrderBlocks);
Clean(bearishMomentumBars);
Clean(bearishRejectionBars);
}
// //
// Validate ... // Validate ...
bool IsValid() bool IsValid()
@@ -263,6 +291,63 @@ struct X121SMCStrategyConditions
// //
}; };
//
// Market Structure Models ...
struct X121SMCMarketStructure
{
//
XZone demandZone;
XZone supplyZone;
//
XZone demandZones[];
XZone supplyZones[];
//
XZone bearishOrderBlocks[];
XZone bearishFVGs[];
//
XOHCL swingHighs[];
XOHCL resistances[];
XOHCL bearishMomentumBars[];
XOHCL bearishRejectionBars[];
//
XZone bullishOrderBlocks[];
XZone bullishFVGs[];
//
XOHCL supports[];
XOHCL swingLows[];
XOHCL bullishMomentumBars[];
XOHCL bullishRejectionBars[];
//
void Clean()
{
//
demandZone.Clean();
supplyZone.Clean();
//
Clean(supports);
Clean(swingLows);
Clean(swingHighs);
Clean(demandZones);
Clean(supplyZones);
Clean(bearishFVGs);
Clean(resistances);
Clean(bullishFVGs);
Clean(bearishOrderBlocks);
Clean(bullishOrderBlocks);
Clean(bearishMomentumBars);
Clean(bearishRejectionBars);
Clean(bullishMomentumBars);
Clean(bullishRejectionBars);
}
};
// //
// On Signal Event Handler ... // On Signal Event Handler ...
typedef void (*TOnX121SMCSignal)( typedef void (*TOnX121SMCSignal)(
Binary file not shown.