337 lines
7.3 KiB
Plaintext
337 lines
7.3 KiB
Plaintext
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
//
|
|
to = NormalizeTime(to);
|
|
|
|
//
|
|
string prefix = Prefix();
|
|
long chartID = ChartIdentification();
|
|
int window = SubWindowIdentification();
|
|
|
|
//
|
|
int width = BarWidth();
|
|
|
|
//
|
|
color mBullishColor = BarBullishColor();
|
|
color mBearishColor = 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(mBullishColor);
|
|
object.LowShadowColor(mBullishColor);
|
|
object.HighShadowColor(mBullishColor);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
object.BodyColor(mBearishColor);
|
|
object.LowShadowColor(mBearishColor);
|
|
object.HighShadowColor(mBearishColor);
|
|
}
|
|
|
|
//
|
|
object.BodyFill(fillBody);
|
|
object.HighShadowFill(fillHighShadow);
|
|
object.LowShadowFill(fillLowShadow);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Create Bar Arrow Object ...
|
|
*
|
|
* @param bar: XOHCL instance Reference ...
|
|
* @param priceType: ENUM_X_PRICE member ...
|
|
* @param arrow: int, Arrow Code ...
|
|
* @param clr: color, Arro Color ...
|
|
* @param width: int, Arrow Width ...
|
|
* @param anchor: ENUM_ARROW_ANCHOR, anchor of Arrow ...
|
|
* @param name: string, name of Arrow ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool CreateBarArrow(
|
|
XOHCL &bar,
|
|
XCBarArrowObject *&object,
|
|
ENUM_X_PRICE priceType,
|
|
int arrow = 159,
|
|
color clr = clrYellow,
|
|
int width = 3,
|
|
ENUM_ARROW_ANCHOR anchor = ANCHOR_BOTTOM,
|
|
string name = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
object = NULL;
|
|
|
|
//
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string barTag = bar.GetTag(name);
|
|
|
|
//
|
|
string prefix = Prefix();
|
|
long chartID = ChartIdentification();
|
|
int window = SubWindowIdentification();
|
|
|
|
//
|
|
color mBullishColor = BarBullishColor();
|
|
color mBearishColor = BarBearishColor();
|
|
|
|
//
|
|
prefix =
|
|
(IsValid(prefix)
|
|
? prefix + "_"
|
|
: prefix) +
|
|
barTag;
|
|
|
|
//
|
|
object = new XCBarArrowObject();
|
|
result = object
|
|
.CreateByBar(
|
|
chartID,
|
|
prefix,
|
|
window,
|
|
arrow,
|
|
bar,
|
|
priceType //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
object.ArrowColor(clr);
|
|
object.ArrowWidth(width);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Create Specific Box on Chart ...
|
|
*
|
|
* @param upper: Double ...
|
|
* @param lower: Double ...
|
|
* @param from: Datetime ...
|
|
* @param to: Datetime ...
|
|
* @param clr: Color ...
|
|
* @param width: Integer ...
|
|
* @param fill: Boolean ...
|
|
* @param style: ENUM_LINE_STYLE member ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool CreateBox(
|
|
XCBoxObject *&object,
|
|
string name,
|
|
double upper,
|
|
double lower,
|
|
datetime from,
|
|
datetime to,
|
|
datetime at,
|
|
color clr = clrYellowGreen,
|
|
int width = 1,
|
|
bool fill = false,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
object = NULL;
|
|
|
|
//
|
|
to = NormalizeTime(to);
|
|
|
|
//
|
|
string dateStr = ToFormatString(from) + "|" + ToFormatString(to);
|
|
string dateMD5 = ToMD5(dateStr);
|
|
if (!IsValid(name))
|
|
{
|
|
//
|
|
name = "XBox_" +
|
|
ToXString(upper) + "_" +
|
|
ToXString(lower) + "_" +
|
|
dateMD5;
|
|
}
|
|
|
|
//
|
|
result =
|
|
upper > 0 &&
|
|
lower > 0 &&
|
|
to > from &&
|
|
IsValid(to) &&
|
|
IsValid(name) &&
|
|
IsValid(from) &&
|
|
upper > lower;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string prefix = Prefix();
|
|
long chartID = ChartIdentification();
|
|
int window = SubWindowIdentification();
|
|
|
|
//
|
|
object = new XCBoxObject();
|
|
result = object.Create(
|
|
chartID,
|
|
window,
|
|
name,
|
|
upper,
|
|
lower,
|
|
from,
|
|
to,
|
|
at,
|
|
prefix //
|
|
);
|
|
|
|
//
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
object.BoxColor(clr);
|
|
object.BoxFill(fill);
|
|
object.BoxWidth(width);
|
|
object.BoxStyle(style);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
/**
|
|
* Create Specific Box on Chart ...
|
|
*
|
|
* @param box: XBoxZone instance Reference ...
|
|
* @param clr: Color ...
|
|
* @param width: Integer ...
|
|
* @param fill: Boolean ...
|
|
* @param style: ENUM_LINE_STYLE member ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool CreateBox(
|
|
XBoxZone &box,
|
|
XCBoxObject *&object,
|
|
color clr = clrYellowGreen,
|
|
int width = 1,
|
|
bool fill = false,
|
|
ENUM_LINE_STYLE style = STYLE_SOLID //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
object = NULL;
|
|
|
|
//
|
|
result = box.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string name = box.GetTag();
|
|
|
|
//
|
|
result = CreateBox(
|
|
object,
|
|
name,
|
|
box.upper,
|
|
box.lower,
|
|
box.from,
|
|
box.to,
|
|
box.at,
|
|
clr,
|
|
width,
|
|
fill,
|
|
style //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|