last ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -44,6 +44,7 @@ enum ENUM_XCHARTOBJECTS
|
||||
X_SIGNAL_OBJ = 8860,
|
||||
X_TREND_OBJ = 8861,
|
||||
X_XPVPIVOT_OBJ = 8862,
|
||||
X_OHCL_OBJ = 8863,
|
||||
//
|
||||
// Structured ...
|
||||
X_TRADE_DAY_OBJ = 9860,
|
||||
@@ -76,7 +77,10 @@ enum ENUM_X_CHART_IDS
|
||||
X_ENTRY,
|
||||
X_TARGET,
|
||||
X_SL,
|
||||
X_TP
|
||||
X_TP,
|
||||
X_BAR_H_SHW,
|
||||
X_BAR_BDY,
|
||||
X_BAR_L_SHW,
|
||||
};
|
||||
|
||||
string ToString(ENUM_X_CHART_IDS value)
|
||||
@@ -126,6 +130,23 @@ string ToString(ENUM_X_CHART_IDS value)
|
||||
case X_TP:
|
||||
result = "TP";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BAR_H_SHW:
|
||||
result = "HSHW";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BAR_BDY:
|
||||
result = "BODY";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_BAR_L_SHW:
|
||||
result = "LSHW";
|
||||
break;
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2216,6 +2237,292 @@ class XCXPVPivotObject : public XCBaseObject
|
||||
CChartObjectTrend mTrend;
|
||||
};
|
||||
|
||||
class XCOHCLObject : public XCBaseObject
|
||||
{
|
||||
//
|
||||
public:
|
||||
//
|
||||
|
||||
/**
|
||||
* Creator ...
|
||||
*
|
||||
* @param chart_id: Long, Specified Chart ID ...
|
||||
* @param window: Integer, Specified Chart Window ID ...
|
||||
* @param pivot: XPVPivot instance ...
|
||||
* @param prefix: String ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Create(
|
||||
long chart_id,
|
||||
int window,
|
||||
XOHCL &bar,
|
||||
datetime to,
|
||||
string prefix = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
IsValid(to);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string name = bar.GetTag();
|
||||
if (IsValid(prefix))
|
||||
{
|
||||
name = prefix + "_" + name;
|
||||
}
|
||||
string nameMD5 = ToMD5(name);
|
||||
|
||||
//
|
||||
// High Shadow ...
|
||||
string hShadowName = ToString(X_BAR_H_SHW) + "_" + nameMD5;
|
||||
|
||||
//
|
||||
result = mHighShadowRect.Create(
|
||||
chart_id,
|
||||
hShadowName,
|
||||
window,
|
||||
bar.time,
|
||||
bar.high,
|
||||
to,
|
||||
bar.GetUp() //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Body ...
|
||||
string bodyName = ToString(X_BAR_BDY) + "_" + nameMD5;
|
||||
|
||||
//
|
||||
result = mBodyRect.Create(
|
||||
chart_id,
|
||||
bodyName,
|
||||
window,
|
||||
bar.time,
|
||||
bar.GetUp(),
|
||||
to,
|
||||
bar.GetDown() //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mHighShadowRect.Delete();
|
||||
mHighShadowRect.Detach();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Low Shadow ...
|
||||
string lShadowName = ToString(X_BAR_L_SHW) + "_" + nameMD5;
|
||||
|
||||
//
|
||||
result = mLowShadowRect.Create(
|
||||
chart_id,
|
||||
lShadowName,
|
||||
window,
|
||||
bar.time,
|
||||
bar.GetDown(),
|
||||
to,
|
||||
bar.low //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mBodyRect.Delete();
|
||||
mBodyRect.Detach();
|
||||
mHighShadowRect.Delete();
|
||||
mHighShadowRect.Detach();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
ObjName(name);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Pivot Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void HighShadowWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mHighShadowRect.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void HighShadowColor(color value)
|
||||
{
|
||||
mHighShadowRect.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void HighShadowStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mHighShadowRect.Style(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Fill ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void HighShadowFill(bool value)
|
||||
{
|
||||
mHighShadowRect.Fill(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void BodyWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mBodyRect.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void BodyColor(color value)
|
||||
{
|
||||
mBodyRect.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void BodyStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mBodyRect.Style(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Fill ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void BodyFill(bool value)
|
||||
{
|
||||
mBodyRect.Fill(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void LowShadowWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 1)
|
||||
{
|
||||
value = 1;
|
||||
}
|
||||
|
||||
//
|
||||
mLowShadowRect.Width(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void LowShadowColor(color value)
|
||||
{
|
||||
mLowShadowRect.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void LowShadowStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mLowShadowRect.Style(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Pivot Fill ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void LowShadowFill(bool value)
|
||||
{
|
||||
mLowShadowRect.Fill(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Virtual ...
|
||||
|
||||
/**
|
||||
* Retrieve Object Type ...
|
||||
*
|
||||
* @return ( ENUM_XCHARTOBJECTS )
|
||||
*/
|
||||
virtual ENUM_XCHARTOBJECTS Type()
|
||||
{
|
||||
return X_OHCL_OBJ;
|
||||
}
|
||||
|
||||
//
|
||||
private:
|
||||
//
|
||||
|
||||
//
|
||||
// Props ...
|
||||
CChartObjectRectangle mHighShadowRect;
|
||||
CChartObjectRectangle mBodyRect;
|
||||
CChartObjectRectangle mLowShadowRect;
|
||||
};
|
||||
|
||||
//
|
||||
// Zone Ticks ...
|
||||
|
||||
@@ -2455,7 +2762,7 @@ class XCTickZoneObject : public XCBaseObject
|
||||
}
|
||||
|
||||
//
|
||||
int fromToDiff = ((int) to - (int) from);
|
||||
int fromToDiff = ((int)to - (int)from);
|
||||
datetime labelsDate = (datetime)((int)to - (fromToDiff / 5));
|
||||
|
||||
//
|
||||
|
||||
@@ -123,6 +123,196 @@ class XCPOIDrawer : public XCBase
|
||||
mSubWindowIdentification = value;
|
||||
}
|
||||
|
||||
//
|
||||
// XOHCL ...
|
||||
|
||||
/**
|
||||
* Get Bar Width ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int BarWidth()
|
||||
{
|
||||
return mBarWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar Width ...
|
||||
*
|
||||
* @param value: Integer ...
|
||||
*/
|
||||
void BarWidth(int value)
|
||||
{
|
||||
//
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
//
|
||||
mBarWidth = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bar Bullish Color ...
|
||||
*
|
||||
* @return ( color )
|
||||
*/
|
||||
color BarBullishColor()
|
||||
{
|
||||
return mBarBullishColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar Bullish Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void BarBullishColor(color value)
|
||||
{
|
||||
mBarBullishColor = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bar Bearish Color ...
|
||||
*
|
||||
* @return ( color )
|
||||
*/
|
||||
color BarBearishColor()
|
||||
{
|
||||
return mBarBearishColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar Bearish Color ...
|
||||
*
|
||||
* @param value: Color ...
|
||||
*/
|
||||
void BarBearishColor(color value)
|
||||
{
|
||||
mBarBearishColor = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Bar High Shadow State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool BarFillHighShadow()
|
||||
{
|
||||
return mBarFillHighShadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Bar High Shadow State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void BarFillHighShadow(bool value)
|
||||
{
|
||||
mBarFillHighShadow = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bar High Shadow Style ...
|
||||
*
|
||||
* @return ( ENUM_LINE_STYLE )
|
||||
*/
|
||||
ENUM_LINE_STYLE BarHighShadowStyle()
|
||||
{
|
||||
return mBarHighShadowStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar High Shadow Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void BarHighShadowStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mBarHighShadowStyle = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Bar Body State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool BarFillBody()
|
||||
{
|
||||
return mBarFillBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Bar Body State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void BarFillBody(bool value)
|
||||
{
|
||||
mBarFillBody = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bar Body Style ...
|
||||
*
|
||||
* @return ( ENUM_LINE_STYLE )
|
||||
*/
|
||||
ENUM_LINE_STYLE BarBodyStyle()
|
||||
{
|
||||
return mBarBodyStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar Body Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void BarBodyStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mBarBodyStyle = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Fill Bar Low Show State ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool BarFillLowShadow()
|
||||
{
|
||||
return mBarFillLowShadow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Fill Bar Low Show State ...
|
||||
*
|
||||
* @param value: Boolean ...
|
||||
*/
|
||||
void BarFillLowShadow(bool value)
|
||||
{
|
||||
mBarFillLowShadow = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bar Low Shadow Style ...
|
||||
*
|
||||
* @return ( ENUM_LINE_STYLE )
|
||||
*/
|
||||
ENUM_LINE_STYLE BarLowShadowStyle()
|
||||
{
|
||||
return mBarLowShadowStyle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Bar Low Shadow Style ...
|
||||
*
|
||||
* @param value: ENUM_LINE_STYLE member ...
|
||||
*/
|
||||
void BarLowShadowStyle(ENUM_LINE_STYLE value)
|
||||
{
|
||||
mBarLowShadowStyle = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Swing Low ...
|
||||
|
||||
@@ -1285,6 +1475,17 @@ class XCPOIDrawer : public XCBase
|
||||
ChartIdentification(0);
|
||||
SubWindowIdentification(0);
|
||||
|
||||
//
|
||||
BarWidth(1);
|
||||
BarBearishColor(clrRed);
|
||||
BarBullishColor(clrLime);
|
||||
BarFillBody(false);
|
||||
BarFillHighShadow(false);
|
||||
BarFillLowShadow(false);
|
||||
BarBodyStyle(STYLE_DOT);
|
||||
BarLowShadowStyle(STYLE_DOT);
|
||||
BarHighShadowStyle(STYLE_DOT);
|
||||
|
||||
//
|
||||
int arrowWidth = 1;
|
||||
|
||||
@@ -2550,6 +2751,113 @@ class XCPOIDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Bar Object ...
|
||||
*
|
||||
* @param bar: XOHCL instance Reference ..
|
||||
* @param object: XCOHCLObject pointer Reference ..
|
||||
* @param to: Datetime ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CreateBar(
|
||||
XOHCL &bar,
|
||||
XCOHCLObject *&object,
|
||||
datetime to = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
object = NULL;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsValid(to))
|
||||
{
|
||||
to = bar.time + PeriodSeconds(bar.period);
|
||||
}
|
||||
|
||||
//
|
||||
string prefix = Prefix();
|
||||
long chartID = ChartIdentification();
|
||||
int window = SubWindowIdentification();
|
||||
|
||||
//
|
||||
int width = BarWidth();
|
||||
|
||||
//
|
||||
color bullishColor = BarBullishColor();
|
||||
color bearishColor = BarBearishColor();
|
||||
|
||||
//
|
||||
bool fillBody = BarFillBody();
|
||||
bool fillHighShadow = BarFillHighShadow();
|
||||
bool fillLowShadow = BarFillLowShadow();
|
||||
|
||||
//
|
||||
ENUM_LINE_STYLE bodyStyle = BarBodyStyle();
|
||||
ENUM_LINE_STYLE highShadowStyle = BarHighShadowStyle();
|
||||
ENUM_LINE_STYLE lowShadowStyle = BarLowShadowStyle();
|
||||
|
||||
//
|
||||
object = new XCOHCLObject();
|
||||
result = object.Create(
|
||||
chartID,
|
||||
window,
|
||||
bar,
|
||||
to,
|
||||
prefix //
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Apply Styling ...
|
||||
|
||||
//
|
||||
object.BodyWidth(width);
|
||||
object.LowShadowWidth(width);
|
||||
object.HighShadowWidth(width);
|
||||
|
||||
//
|
||||
object.BodyStyle(bodyStyle);
|
||||
object.LowShadowStyle(lowShadowStyle);
|
||||
object.HighShadowStyle(highShadowStyle);
|
||||
|
||||
//
|
||||
bool isBullish = bar.IsBullish();
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
object.BodyColor(bullishColor);
|
||||
object.LowShadowColor(bullishColor);
|
||||
object.HighShadowColor(bullishColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
object.BodyColor(bearishColor);
|
||||
object.LowShadowColor(bearishColor);
|
||||
object.HighShadowColor(bearishColor);
|
||||
}
|
||||
|
||||
//
|
||||
object.BodyFill(fillBody);
|
||||
object.HighShadowFill(fillHighShadow);
|
||||
object.LowShadowFill(fillLowShadow);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Signal ...
|
||||
*
|
||||
@@ -3300,6 +3608,18 @@ class XCPOIDrawer : public XCBase
|
||||
long mChartIdentification; // Chart Id ...
|
||||
int mSubWindowIdentification; // Sub Window ...
|
||||
|
||||
//
|
||||
// XOHCL ...
|
||||
int mBarWidth; // Bar Width ...
|
||||
color mBarBullishColor; // Bar Bullish Color ...
|
||||
color mBarBearishColor; // Bar Bearish Color ...
|
||||
bool mBarFillHighShadow; // Fill Bar High Shadow ...
|
||||
ENUM_LINE_STYLE mBarHighShadowStyle; // Bar High Shadow Style ...
|
||||
bool mBarFillBody; // Fill Bar Body ...
|
||||
ENUM_LINE_STYLE mBarBodyStyle; // Bar Body Style ...
|
||||
bool mBarFillLowShadow; // Fill Bar Low Show ...
|
||||
ENUM_LINE_STYLE mBarLowShadowStyle; // Bar Low Shadow Style ...
|
||||
|
||||
//
|
||||
// Swing Low ...
|
||||
int mSwingLowWidth; // Swing Low Width ...
|
||||
|
||||
@@ -1747,6 +1747,202 @@ class XCX121Helper : public XCBaseHelper
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLowestPeak(
|
||||
int barIndex,
|
||||
int &index,
|
||||
double &vale,
|
||||
int loopback = 576 //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
vale = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
for (int i = 0; i < barIndex + loopback; i++)
|
||||
{
|
||||
//
|
||||
double iPeak = GetPeak(i);
|
||||
if (iPeak == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (iPeak > 0 && (result == 0 ||
|
||||
result >= iPeak))
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
result = iPeak;
|
||||
vale = GetVale(index);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double GetHighestPeak(
|
||||
int barIndex,
|
||||
int &index,
|
||||
double &vale,
|
||||
int loopback = 576 //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
vale = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
for (int i = 0; i < barIndex + loopback; i++)
|
||||
{
|
||||
//
|
||||
double iPeak = GetPeak(i);
|
||||
if (iPeak == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (iPeak > 0 && (result == 0 ||
|
||||
result <= iPeak))
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
result = iPeak;
|
||||
vale = GetVale(index);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double GetLowestVale(
|
||||
int barIndex,
|
||||
int &index,
|
||||
double &peak,
|
||||
int loopback = 576 //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
peak = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
for (int i = 0; i < barIndex + loopback; i++)
|
||||
{
|
||||
//
|
||||
double iPeak = GetVale(i);
|
||||
if (iPeak == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (iPeak > 0 && (result == 0 ||
|
||||
result >= iPeak))
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
result = iPeak;
|
||||
peak = GetPeak(index);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double GetHighestVale(
|
||||
int barIndex,
|
||||
int &index,
|
||||
double &peak,
|
||||
int loopback = 576 //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
index = -1;
|
||||
peak = 0;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
for (int i = 0; i < barIndex + loopback; i++)
|
||||
{
|
||||
//
|
||||
double iPeak = GetVale(i);
|
||||
if (iPeak == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
if (iPeak > 0 && (result == 0 ||
|
||||
result <= iPeak))
|
||||
{
|
||||
//
|
||||
index = i;
|
||||
result = iPeak;
|
||||
peak = GetPeak(index);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// CURRENT ...
|
||||
|
||||
|
||||
+30
-3606
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -519,6 +519,656 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DetectMarketStructure(
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
int barIndex = 0;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
int highestPeakIndex = -1;
|
||||
double highestPeakVale = 0;
|
||||
double highestPeak = mX121Helper
|
||||
.GetHighestPeak(
|
||||
barIndex,
|
||||
highestPeakIndex,
|
||||
highestPeakVale //
|
||||
);
|
||||
|
||||
//
|
||||
int lowestValeIndex = -1;
|
||||
double lowestValePeak = 0;
|
||||
double lowestVale = mX121Helper
|
||||
.GetLowestVale(
|
||||
barIndex,
|
||||
lowestValeIndex,
|
||||
lowestValePeak //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidIndex(highestPeakIndex) &&
|
||||
IsValidIndex(lowestValeIndex);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
dir =
|
||||
highestPeakIndex < lowestValeIndex
|
||||
? X_DIRECTION_BEARISH
|
||||
: highestPeakIndex > lowestValeIndex
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = IsBullish(dir);
|
||||
|
||||
//
|
||||
// Looking for Change Of Character Proved ...
|
||||
|
||||
//
|
||||
// Bullish Bias:
|
||||
// - Price Must Break Up Lowst Vale's Peak;
|
||||
// - Create a Vale Above Lowest Vale's Peak;
|
||||
|
||||
//
|
||||
// Bearish Bias:
|
||||
// - Price Must Breake Down HighestPeak's Vale;
|
||||
// - Create a Peak Under Highest Peak's Vale;
|
||||
|
||||
//
|
||||
// Checking Peak Breake Up ...
|
||||
int lowestValePeakBreakeUpIndex = -1;
|
||||
for (int i = lowestValeIndex; i >= barIndex; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = GetBar(iBar, i);
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBreake = iBar.IsBreakeUp(lowestValePeak);
|
||||
if (isBreake)
|
||||
{
|
||||
//
|
||||
lowestValePeakBreakeUpIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isValidBreakeUpLowestValePeak = IsValidIndex(lowestValePeakBreakeUpIndex) &&
|
||||
lowestValePeakBreakeUpIndex <= lowestValeIndex;
|
||||
|
||||
//
|
||||
// Checking Vale Breake Down ...
|
||||
int highestPeakValeBreakeDownIndex = -1;
|
||||
for (int i = highestPeakIndex; i >= barIndex; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = GetBar(iBar, i);
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBreake = iBar.IsBreakeDown(highestPeakVale);
|
||||
if (isBreake)
|
||||
{
|
||||
//
|
||||
highestPeakValeBreakeDownIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isValidBreakeDownHighestPeakVale = IsValidIndex(highestPeakValeBreakeDownIndex) &&
|
||||
highestPeakValeBreakeDownIndex <= highestPeakIndex;
|
||||
//
|
||||
result = isBullish
|
||||
? isValidBreakeUpLowestValePeak
|
||||
: isValidBreakeDownHighestPeakVale;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Create a Vale above Peak ...
|
||||
int valeAboveLowestValePeakIndex = -1;
|
||||
double valeAboveLowestValePeakPeak = 0;
|
||||
for (int i = lowestValePeakBreakeUpIndex; i >= barIndex; i--)
|
||||
{
|
||||
//
|
||||
double iVale = mX121Helper.GetVale(i);
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
iVale > 0 &&
|
||||
iVale > lowestValePeak;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
valeAboveLowestValePeakIndex = i;
|
||||
valeAboveLowestValePeakPeak = mX121Helper.GetPeak(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isValidValeAboveLowestValePeak = IsValidIndex(valeAboveLowestValePeakIndex) &&
|
||||
valeAboveLowestValePeakIndex < lowestValePeakBreakeUpIndex;
|
||||
|
||||
//
|
||||
// Checking Create a Peak below Vale ...
|
||||
int peakBelowHighestPeakValeIndex = -1;
|
||||
double peakBelowHighestPeakValeVale = 0;
|
||||
for (int i = highestPeakValeBreakeDownIndex; i >= barIndex; i--)
|
||||
{
|
||||
//
|
||||
double iPeak = mX121Helper.GetPeak(i);
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
iPeak > 0 &&
|
||||
iPeak < highestPeakVale;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
peakBelowHighestPeakValeIndex = i;
|
||||
peakBelowHighestPeakValeVale = mX121Helper.GetVale(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool isValidPeakBelowHighestPeakVale = IsValidIndex(peakBelowHighestPeakValeIndex) &&
|
||||
peakBelowHighestPeakValeIndex < highestPeakValeBreakeDownIndex;
|
||||
|
||||
//
|
||||
result = isBullish ? isValidValeAboveLowestValePeak
|
||||
: isValidPeakBelowHighestPeakVale;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Now we Have to Detect Valid Peaks and Valid Vales Here ...
|
||||
// based on Detected Range ...
|
||||
|
||||
//
|
||||
XPVPivotPoint vales[];
|
||||
XPVPivotPoint peaks[];
|
||||
XPVPivotPoint iPeakPoint;
|
||||
XPVPivotPoint iValePoint;
|
||||
XPriceZones peakPriceZone;
|
||||
XPriceZones valePriceZone;
|
||||
XPriceZones peakPriceZones[];
|
||||
XPriceZones valePriceZones[];
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(
|
||||
state //
|
||||
);
|
||||
|
||||
//
|
||||
int minRepetition = 5; // ValidPivotRepetition();
|
||||
|
||||
//
|
||||
int from =
|
||||
isBullish
|
||||
? valeAboveLowestValePeakIndex
|
||||
: peakBelowHighestPeakValeIndex;
|
||||
for (int i = from; i >= barIndex; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = GetBar(iBar, i);
|
||||
|
||||
//
|
||||
double iPeak = mX121Helper.GetPeak(i);
|
||||
double iVale = mX121Helper.GetVale(i);
|
||||
|
||||
//
|
||||
bool hasPeakPriceInsideZone = CalculatePriceInsideZones(
|
||||
peakPriceZone,
|
||||
state,
|
||||
iPeak //
|
||||
);
|
||||
bool hasValePriceInsideZone = CalculatePriceInsideZones(
|
||||
valePriceZone,
|
||||
state,
|
||||
iVale //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasPeakPriceInsideZone)
|
||||
{
|
||||
//
|
||||
// Peak ...
|
||||
if (!iPeakPoint.IsValid())
|
||||
{
|
||||
//
|
||||
// Initialization ...
|
||||
iPeakPoint.value = iPeak;
|
||||
iPeakPoint.repetition = 1;
|
||||
iPeakPoint.type = XPV_PEAK;
|
||||
iPeakPoint.time = iBar.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (iPeakPoint.value == iPeak)
|
||||
{
|
||||
iPeakPoint.repetition++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (iPeakPoint.repetition > minRepetition)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iPeakPoint,
|
||||
peaks //
|
||||
);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
peakPriceZone,
|
||||
peakPriceZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iPeakPoint.Clean();
|
||||
peakPriceZone.Clean();
|
||||
iPeakPoint.value = iPeak;
|
||||
iPeakPoint.repetition = 1;
|
||||
iPeakPoint.type = XPV_PEAK;
|
||||
iPeakPoint.time = iBar.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasValePriceInsideZone)
|
||||
{
|
||||
//
|
||||
// Vale ...
|
||||
if (!iValePoint.IsValid())
|
||||
{
|
||||
//
|
||||
// Initialization ...
|
||||
iValePoint.value = iVale;
|
||||
iValePoint.repetition = 1;
|
||||
iValePoint.type = XPV_VALE;
|
||||
iValePoint.time = iBar.time;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (iValePoint.value == iVale)
|
||||
{
|
||||
iValePoint.repetition++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
if (iValePoint.repetition > minRepetition)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iValePoint,
|
||||
vales //
|
||||
);
|
||||
|
||||
//
|
||||
AddRef(
|
||||
valePriceZone,
|
||||
valePriceZones //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iValePoint.Clean();
|
||||
valePriceZone.Clean();
|
||||
iValePoint.value = iVale;
|
||||
iValePoint.repetition = 1;
|
||||
iValePoint.type = XPV_VALE;
|
||||
iValePoint.time = iBar.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// in Bullish Bias we Looking for Vales Oder ...
|
||||
// in Bearish Bias we Looking for Peaks Oder ...
|
||||
|
||||
//
|
||||
// Draw ...
|
||||
XCBaseObject *drawnObjects[];
|
||||
|
||||
//
|
||||
// Bearish Bias ...
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
// Draw Lowest Vale Bar ...
|
||||
XOHCL lowestValeBar;
|
||||
result = GetBar(
|
||||
lowestValeBar,
|
||||
lowestValeIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
XCOHCLObject *iLowestValeBarObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
lowestValeBar,
|
||||
iLowestValeBarObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iLowestValeBarObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Lowest Vale Peak Breaker Bar ...
|
||||
XOHCL lowestValePeakBreakeUpBar;
|
||||
if (isValidBreakeUpLowestValePeak)
|
||||
{
|
||||
//
|
||||
result = GetBar(
|
||||
lowestValePeakBreakeUpBar,
|
||||
lowestValePeakBreakeUpIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCOHCLObject *iObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
lowestValePeakBreakeUpBar,
|
||||
iObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Vale Above Lowest Vale Peak ...
|
||||
XOHCL valeAboveLowestValePeakBar;
|
||||
if (isValidValeAboveLowestValePeak)
|
||||
{
|
||||
//
|
||||
result = GetBar(valeAboveLowestValePeakBar,
|
||||
valeAboveLowestValePeakIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCOHCLObject *iObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
valeAboveLowestValePeakBar,
|
||||
iObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Vales ...
|
||||
int valesCount = ArraySize(vales);
|
||||
if (IsValidSize(valesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < valesCount; i++)
|
||||
{
|
||||
//
|
||||
iValePoint = vales[i];
|
||||
|
||||
//
|
||||
CChartObjectTrend *iValeObj;
|
||||
iValeObj = new CChartObjectTrend();
|
||||
|
||||
//
|
||||
string iValeName = "XVALE_" + ToString(iValePoint.value);
|
||||
|
||||
//
|
||||
long chartID = mPOIDetector.mDrawer.ChartIdentification();
|
||||
int window = mPOIDetector.mDrawer.SubWindowIdentification();
|
||||
|
||||
//
|
||||
bool isCreate = iValeObj.Create(
|
||||
chartID,
|
||||
iValeName,
|
||||
window,
|
||||
iValePoint.time,
|
||||
iValePoint.value,
|
||||
TimeCurrent(),
|
||||
iValePoint.value //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Price Zone ...
|
||||
valesCount = ArraySize(valePriceZones);
|
||||
if (IsValidSize(valesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < valesCount; i++)
|
||||
{
|
||||
//
|
||||
XPriceZones iZone = valePriceZones[i];
|
||||
|
||||
//
|
||||
bool hasSupport = iZone.HasSupportZone();
|
||||
if (hasSupport)
|
||||
{
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateSupportZone(
|
||||
iZone.supportZone,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bullish Bias Drawn ...
|
||||
if (!isBullish)
|
||||
{
|
||||
//
|
||||
// Draw Highest Peak Bar ...
|
||||
XOHCL highestPeakBar;
|
||||
result = GetBar(
|
||||
highestPeakBar,
|
||||
highestPeakIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
XCOHCLObject *iHighestPeakBarObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
highestPeakBar,
|
||||
iHighestPeakBarObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iHighestPeakBarObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Highest Peak Vale Breaker Bar ...
|
||||
XOHCL highestPeakValeBreakeDownBar;
|
||||
if (isValidBreakeDownHighestPeakVale)
|
||||
{
|
||||
//
|
||||
result = GetBar(
|
||||
highestPeakValeBreakeDownBar,
|
||||
highestPeakValeBreakeDownIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCOHCLObject *iObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
highestPeakValeBreakeDownBar,
|
||||
iObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Peak Below Highest Peak Vale ...
|
||||
XOHCL peakBelowHighestPeakValeBar;
|
||||
if (isValidPeakBelowHighestPeakVale)
|
||||
{
|
||||
//
|
||||
result = GetBar(peakBelowHighestPeakValeBar,
|
||||
peakBelowHighestPeakValeIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCOHCLObject *iObj;
|
||||
bool isCreated = mPOIDetector.mDrawer.CreateBar(
|
||||
peakBelowHighestPeakValeBar,
|
||||
iObj,
|
||||
TimeCurrent() //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Peaks ...
|
||||
int peaksCount = ArraySize(peaks);
|
||||
if (IsValidSize(peaksCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < peaksCount; i++)
|
||||
{
|
||||
//
|
||||
iPeakPoint = peaks[i];
|
||||
|
||||
//
|
||||
CChartObjectTrend *iPeakObj;
|
||||
iPeakObj = new CChartObjectTrend();
|
||||
|
||||
//
|
||||
string iPeakName = "XPEAK_" + ToString(iPeakPoint.value);
|
||||
|
||||
//
|
||||
long chartID = mPOIDetector.mDrawer.ChartIdentification();
|
||||
int window = mPOIDetector.mDrawer.SubWindowIdentification();
|
||||
|
||||
//
|
||||
bool isCreate = iPeakObj.Create(
|
||||
chartID,
|
||||
iPeakName,
|
||||
window,
|
||||
iPeakPoint.time,
|
||||
iPeakPoint.value,
|
||||
TimeCurrent(),
|
||||
iPeakPoint.value //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
@@ -3143,8 +3793,8 @@ class XC121SMCCycleHelper : public XCBase
|
||||
XValueChange mVWapStateChanges[]; // Holds Vales Changes ...
|
||||
|
||||
//
|
||||
int mConsolidationLoopback; // Consolidation Loopback Length ...
|
||||
XConsolidationZone mConsolidationZones[]; // Holds Consolidation Zones ...
|
||||
int mConsolidationLoopback; // Consolidation Loopback Length ...
|
||||
XConsolidationZone mConsolidationZones[]; // Holds Consolidation Zones ...
|
||||
XConsolidationZone mActiveConsolidationZone; // Holds Actiove Consolidation Zone ...
|
||||
// XCConsolidationZoneObject *mActiveConsolidationZoneObj;
|
||||
|
||||
|
||||
@@ -646,6 +646,12 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
||||
//
|
||||
// Setup Conditions ...
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION biasDir;
|
||||
bool hasMarketStructure =
|
||||
analyseCycleHelper
|
||||
.DetectMarketStructure(biasDir);
|
||||
|
||||
//
|
||||
XOHCL analyseCBar;
|
||||
result = analyseCycleHelper.GetBar(
|
||||
|
||||
Reference in New Issue
Block a user