Fix all Refactors issues on X121SMC for start Implementing Strategy ...
This commit is contained in:
@@ -449,6 +449,348 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Bullish Trend or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param forceAll: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishTrend(
|
||||
XOHCL &bar,
|
||||
bool forceAll = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
bool trend1 = bar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
bool trend2 = bar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
if (!forceAll)
|
||||
{
|
||||
//
|
||||
result = trend1;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
trend1 ||
|
||||
trend2;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Bearish Trend or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param forceAll: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishTrend(
|
||||
XOHCL &bar,
|
||||
bool forceAll = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
bool trend1 = bar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
bool trend2 = bar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
if (!forceAll)
|
||||
{
|
||||
//
|
||||
result = trend1;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
trend1 ||
|
||||
trend2;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar Has Bullish Pattern or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Specified Bar ...
|
||||
* @param loopback: Integer, Loopback Length for Patterns ...
|
||||
* @param verifications: Integer, Number of Given Verifications ...
|
||||
* @param checkHammer: Boolean, Specified Check Hammer Pattern ...
|
||||
* @param checkMorningStar: Boolean, Specified Check Morning Star Pattern ...
|
||||
* @param checkBullishMarubozu: Boolean, Specified Check Marubozu Pattern ...
|
||||
* @param checkBullishEngulfing: Boolean, Specified Check Engulfing Pattern ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishPattern(
|
||||
XOHCL &bar,
|
||||
int loopback = 0,
|
||||
int verifications = 1,
|
||||
bool checkHammer = true,
|
||||
bool checkMorningStar = true,
|
||||
bool checkBullishMarubozu = true,
|
||||
bool checkBullishEngulfing = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (verifications <= 0)
|
||||
{
|
||||
verifications = 1;
|
||||
}
|
||||
|
||||
//
|
||||
int founded = 0;
|
||||
|
||||
//
|
||||
int idx = bar.Index();
|
||||
for (int i = idx; i <= idx + loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bool isHammer =
|
||||
!checkHammer
|
||||
? false
|
||||
: iBar.IsHammer();
|
||||
if (isHammer)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isMorningStar =
|
||||
!checkMorningStar
|
||||
? false
|
||||
: iBar.IsMorningStar();
|
||||
if (isMorningStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullishMarubozu =
|
||||
!checkBullishMarubozu
|
||||
? false
|
||||
: iBar.IsBullishMarubozu();
|
||||
if (isBullishMarubozu)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullishEngulfing =
|
||||
!checkBullishEngulfing
|
||||
? false
|
||||
: iBar.IsBullishEngulfing();
|
||||
if (isBullishEngulfing)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
founded >= verifications;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar Has Bearish Pattern or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Specified Bar ...
|
||||
* @param loopback: Integer, Loopback Length for Patterns ...
|
||||
* @param verifications: Integer, Number of Given Verifications ...
|
||||
* @param checkShootingStar: Boolean, Specified Check Shooting Star Pattern ...
|
||||
* @param checkEveningStar: Boolean, Specified Check Evening Star Pattern ...
|
||||
* @param checkBearishMarubozu: Boolean, Specified Check Marubozu Pattern ...
|
||||
* @param checkBearishEngulfing: Boolean, Specified Check Engulfing Pattern ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishPattern(
|
||||
XOHCL &bar,
|
||||
int loopback = 0,
|
||||
int verifications = 1,
|
||||
bool checkShootingStar = true,
|
||||
bool checkEveningStar = true,
|
||||
bool checkBearishMarubozu = true,
|
||||
bool checkBearishEngulfing = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (verifications <= 0)
|
||||
{
|
||||
verifications = 1;
|
||||
}
|
||||
|
||||
//
|
||||
int founded = 0;
|
||||
|
||||
//
|
||||
int idx = bar.Index();
|
||||
for (int i = idx - 1; i <= idx + loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bool isShootingStar =
|
||||
!checkShootingStar
|
||||
? false
|
||||
: iBar.IsShootingStar();
|
||||
if (isShootingStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isEveningStar =
|
||||
!checkEveningStar
|
||||
? false
|
||||
: iBar.IsEveningStar();
|
||||
if (isEveningStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBearishMarubozu =
|
||||
!checkBearishMarubozu
|
||||
? false
|
||||
: iBar.IsBearishMarubozu();
|
||||
if (isBearishMarubozu)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBearishEngulfing =
|
||||
!checkBearishEngulfing
|
||||
? false
|
||||
: iBar.IsBearishEngulfing();
|
||||
if (isBearishEngulfing)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
founded >= verifications;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Commons ...
|
||||
|
||||
|
||||
@@ -1534,6 +1534,269 @@ class XCBearishFairValueGapObject : public XCZoneObject
|
||||
return X_BEARISH_FVG_OBJ;
|
||||
}
|
||||
};
|
||||
//
|
||||
// Signal ...
|
||||
class XCSignalObject : public XCBaseObject
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
void XCSignalObject()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCSignalObject()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Signal Object on Chart ...
|
||||
*
|
||||
* @param chart_id: Long ...
|
||||
* @param name: String ...
|
||||
* @param window: Integer ...
|
||||
* @param signal: XSignal instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
const string name,
|
||||
const int window,
|
||||
XSignal &signal //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(name) &&
|
||||
signal
|
||||
.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
int delay = (PeriodSeconds(signal.period) * 2);
|
||||
datetime time1 = (datetime)((int)signal.time - delay);
|
||||
datetime time2 = (datetime)((int)signal.time + delay);
|
||||
|
||||
//
|
||||
// TP ...
|
||||
string tpName = ToString(X_TP) + "_" + nameMD5;
|
||||
result = mTPTrend.Create(
|
||||
chart_id,
|
||||
tpName,
|
||||
window,
|
||||
time1,
|
||||
signal.tp,
|
||||
time2,
|
||||
signal.tp //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// SL ...
|
||||
string slName = ToString(X_SL) + "_" + nameMD5;
|
||||
result = mSLTrend.Create(
|
||||
chart_id,
|
||||
slName,
|
||||
window,
|
||||
time1,
|
||||
signal.sl,
|
||||
time2,
|
||||
signal.sl //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mTPTrend.Delete();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// ENTRY ...
|
||||
string entrName = ToString(X_ENTRY) + "_" + nameMD5;
|
||||
result = mEntryTrend.Create(
|
||||
chart_id,
|
||||
entrName,
|
||||
window,
|
||||
time1,
|
||||
signal.entry,
|
||||
time2,
|
||||
signal.entry //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mTPTrend.Delete();
|
||||
mSLTrend.Delete();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Object Name ...
|
||||
ObjName(name);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Setter(s) ...
|
||||
|
||||
//
|
||||
// TP ...
|
||||
|
||||
/**
|
||||
* Set TP Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void TPWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mTPTrend.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TP Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void TPColor(color value)
|
||||
{
|
||||
mTPTrend.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set TP Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE ...
|
||||
*/
|
||||
void TPStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mTPTrend.Style(value);
|
||||
}
|
||||
|
||||
//
|
||||
// SL ...
|
||||
|
||||
/**
|
||||
* Set SL Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void SLWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mSLTrend.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SL Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void SLColor(color value)
|
||||
{
|
||||
mSLTrend.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set SL Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE ...
|
||||
*/
|
||||
void SLStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mSLTrend.Style(value);
|
||||
}
|
||||
|
||||
//
|
||||
// ENTRY ...
|
||||
|
||||
/**
|
||||
* Set Entry Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void EntryWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mEntryTrend.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Entry Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void EntryColor(color value)
|
||||
{
|
||||
mEntryTrend.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Entry Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE ...
|
||||
*/
|
||||
void EntryStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mEntryTrend.Style(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Object Type ...
|
||||
*
|
||||
* @return ( ENUM_XCHARTOBJECTS )
|
||||
*/
|
||||
virtual ENUM_XCHARTOBJECTS Type()
|
||||
{
|
||||
return X_SIGNAL_OBJ;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
CChartObjectTrend mTPTrend;
|
||||
CChartObjectTrend mSLTrend;
|
||||
CChartObjectTrend mEntryTrend;
|
||||
};
|
||||
|
||||
//
|
||||
// Zone Ticks ...
|
||||
@@ -1844,8 +2107,9 @@ class XCTicksZoneObject : public XCBaseObject
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
void Destroy() {
|
||||
|
||||
void Destroy()
|
||||
{
|
||||
mZones.Clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -1068,10 +1068,95 @@ class XCPOIDetector : public XCBaseAlert
|
||||
//
|
||||
state.symbol = mSymbol;
|
||||
state.period = mPeriod;
|
||||
state.reportedAt = TimeCurrent();
|
||||
state.time = TimeCurrent();
|
||||
|
||||
//
|
||||
// TODO: Fill State ...
|
||||
Copy(
|
||||
mSwingHighs,
|
||||
state.swingHighs //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mSwingLows,
|
||||
state.swingLows //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBullishMomentumBars,
|
||||
state.bullishMomentumBars //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBearishMomentumBars,
|
||||
state.bearishMomentumBars //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBullishRejectionBars,
|
||||
state.bullishRejectionBars //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBearishRejectionBars,
|
||||
state.bearishRejectionBars //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mSupportZones,
|
||||
state.supportZones //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mResistanceZones,
|
||||
state.resistanceZones //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mSupplyZones,
|
||||
state.supplyZones //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mDemandZones,
|
||||
state.demandZones //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBullishOrderBlocks,
|
||||
state.bullishOrderBlocks //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBearishOrderBlocks,
|
||||
state.bearishOrderBlocks //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBullishFairValueGaps,
|
||||
state.bullishFairValueGaps //
|
||||
);
|
||||
|
||||
//
|
||||
Copy(
|
||||
mBearishFairValueGaps,
|
||||
state.bearishFairValueGaps //
|
||||
);
|
||||
|
||||
//
|
||||
state.ticksZone = mTicksZone;
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2993,7 +3078,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Supply Zone(s) ...
|
||||
XCSupplyZone *mSupplyZones[];
|
||||
XCSupplyZone *mSupplyZones[]; // Holds Founded Supply Zones ...
|
||||
|
||||
/**
|
||||
* Detect Supply Zone ...
|
||||
@@ -3162,7 +3247,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Demand Zone(s) ...
|
||||
XCDemandZone *mDemandZones[];
|
||||
XCDemandZone *mDemandZones[]; // Holds Founded Demand Zones ...
|
||||
|
||||
/**
|
||||
* Detect Demand Zone ...
|
||||
@@ -3335,7 +3420,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Bullish OB ...
|
||||
XCOrderBlock *mBullishOrderBlocks[];
|
||||
XCOrderBlock *mBullishOrderBlocks[]; // Holds Founded Bullish Order Blocks ...
|
||||
|
||||
/**
|
||||
* Detect Bullish Order Block ...
|
||||
@@ -3493,7 +3578,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Bearish OB ...
|
||||
XCOrderBlock *mBearishOrderBlocks[];
|
||||
XCOrderBlock *mBearishOrderBlocks[]; // Holds Founded Bearish Order Blocks ...
|
||||
|
||||
/**
|
||||
* Detect Bearish Order Block ...
|
||||
@@ -3655,7 +3740,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Bullish FVG ...
|
||||
XCFVG *mBullishFairValueGaps[];
|
||||
XCFVG *mBullishFairValueGaps[]; // Holds Founded Bullish Fair Value Gaps ...
|
||||
|
||||
/**
|
||||
* Detect Bullish Fair Value Gap ...
|
||||
@@ -3816,7 +3901,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Bearish FVG ...
|
||||
XCFVG *mBearishFairValueGaps[];
|
||||
XCFVG *mBearishFairValueGaps[]; // Holds Founded Bearish Fair Value Gaps ...
|
||||
|
||||
/**
|
||||
* Detect Bearish Fair Value Gap ...
|
||||
@@ -3981,7 +4066,7 @@ class XCPOIDetector : public XCBaseAlert
|
||||
int mTicksRangeZoneRange; // Ticks Range Zone Loopback Period ...
|
||||
|
||||
//
|
||||
XCTicksZone *mTicksZone; // Ticks Zone ...
|
||||
XCTicksZone *mTicksZone; // Ticks Zone ...
|
||||
// XCTicksZoneObject *mTicksZoneObject; // Ticks Zone Object ...
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user