2790 lines
68 KiB
Plaintext
2790 lines
68 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Class Library
|
|
// --------------------------------------
|
|
// Name: XPOIDrawer
|
|
// Description: Provides Point of Interests
|
|
// Drawing Tools ...
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
// Imports ...
|
|
#include "../Classes/x-saherelm.base.class.mq5"
|
|
#include "../Classes/x-saherelm.x-cobject.class.mq5"
|
|
#include "../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
|
#include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
|
|
|
|
//
|
|
// Definitions ...
|
|
|
|
//
|
|
// Implementations ...
|
|
class XCPOIDrawer : public XCBase
|
|
{
|
|
//
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
XPOIStyle defaultBullishStyle;
|
|
XPOIStyle defaultBearishStyle;
|
|
|
|
//
|
|
XPOIStyle boxBullishStyle;
|
|
XPOIStyle boxBearishStyle;
|
|
|
|
//
|
|
CArrayObj drawnObjects;
|
|
|
|
//
|
|
// Constructor ...
|
|
XCPOIDrawer()
|
|
{
|
|
//
|
|
Default();
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XCPOIDrawer()
|
|
{
|
|
//
|
|
boxBullishStyle.Clean();
|
|
boxBearishStyle.Clean();
|
|
defaultBullishStyle.Clean();
|
|
defaultBearishStyle.Clean();
|
|
}
|
|
|
|
//
|
|
// Setter Getter (s) ...
|
|
|
|
/**
|
|
* Get Prefix ...
|
|
*
|
|
* @return ( string )
|
|
*/
|
|
string Prefix()
|
|
{
|
|
return mPrefix;
|
|
}
|
|
|
|
/**
|
|
* Set Prifx ...
|
|
*
|
|
* @param value: String ...
|
|
*/
|
|
void Prefix(string value)
|
|
{
|
|
mPrefix = value;
|
|
}
|
|
|
|
/**
|
|
* Get Chart ID ...
|
|
*
|
|
* @return ( long )
|
|
*/
|
|
long ChartIdentification()
|
|
{
|
|
return mChartIdentification;
|
|
}
|
|
|
|
/**
|
|
* Set Chart ID ...
|
|
*
|
|
* @param value: Long ...
|
|
*/
|
|
void ChartIdentification(long value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mChartIdentification = value;
|
|
}
|
|
|
|
/**
|
|
* Get SubWindow Id ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int SubWindowIdentification()
|
|
{
|
|
return mSubWindowIdentification;
|
|
}
|
|
|
|
/**
|
|
* Set SubWindow Id ...
|
|
*
|
|
* @param value: Integer ...
|
|
*/
|
|
void SubWindowIdentification(int value)
|
|
{
|
|
//
|
|
if (value < 0)
|
|
{
|
|
value = 0;
|
|
}
|
|
|
|
//
|
|
mSubWindowIdentification = value;
|
|
}
|
|
|
|
//
|
|
// Virtuals ...
|
|
|
|
/**
|
|
* Apply Default Configurations ...
|
|
*/
|
|
virtual void Default()
|
|
{
|
|
//
|
|
// Apply Default Props ...
|
|
|
|
//
|
|
Prefix(NULL);
|
|
ChartIdentification(0);
|
|
SubWindowIdentification(0);
|
|
|
|
//
|
|
defaultBullishStyle.width = 1;
|
|
defaultBullishStyle.clr = clrLime;
|
|
defaultBullishStyle.style = STYLE_SOLID;
|
|
|
|
//
|
|
defaultBearishStyle.width = 1;
|
|
defaultBearishStyle.clr = clrRed;
|
|
defaultBearishStyle.style = STYLE_SOLID;
|
|
|
|
//
|
|
boxBullishStyle = defaultBullishStyle;
|
|
boxBearishStyle = defaultBearishStyle;
|
|
}
|
|
|
|
//
|
|
// Drawers ...
|
|
|
|
/**
|
|
* Draw Specified Bar ...
|
|
*
|
|
* @param bar: XOHCL, refrence to Specified Bar ...
|
|
* @param object: XCOHCLObject, pointer reference for Drawn Object ...
|
|
* @param to: datetime, Specified To Time ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawBar(
|
|
XOHCL &bar,
|
|
XCOHCLObject *&object,
|
|
datetime to = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = NULL;
|
|
|
|
//
|
|
// Validate ...
|
|
result = bar.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string prefix = Prefix();
|
|
ulong chartId = ChartIdentification();
|
|
int window = SubWindowIdentification();
|
|
to = IsSpecifiedValid(to)
|
|
? to
|
|
: ((datetime)((int)bar.time) + (PeriodSeconds(bar.period) - 1));
|
|
object = new XCOHCLObject();
|
|
result = object.Create(
|
|
chartId,
|
|
window,
|
|
bar,
|
|
to,
|
|
prefix //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
ApplyBarStyle(
|
|
object,
|
|
bar //
|
|
);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Bar Arrow Object ...
|
|
*
|
|
* @param bar: XOHCL instance Reference ...
|
|
* @param object: XCBarArrowObject, pointer reference for Drawn Object ...
|
|
* @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 DrawBarArrow(
|
|
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 ignoreBarTag = true,
|
|
int threshold = 5 //
|
|
)
|
|
{
|
|
//
|
|
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();
|
|
|
|
//
|
|
prefix =
|
|
(IsValid(prefix)
|
|
? prefix + "_"
|
|
: prefix) +
|
|
(IsSpecifiedValid(name)
|
|
? name
|
|
: "") +
|
|
(ignoreBarTag ? "" : ToMD5(barTag));
|
|
|
|
//
|
|
object = new XCBarArrowObject();
|
|
result = object
|
|
.CreateByBar(
|
|
chartID,
|
|
prefix,
|
|
window,
|
|
arrow,
|
|
bar,
|
|
priceType,
|
|
threshold //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
object.ArrowColor(clr);
|
|
object.ArrowWidth(width);
|
|
object.ArrowAnchor(anchor);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Dar Specified Pivot ...
|
|
*
|
|
* @param pivot: XPivot, Specified Pivot ...
|
|
* @param object: XCBarArrowObject, pointer reference for Drawn Object ...
|
|
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
|
|
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
|
|
* @param threshold: int, distance between price and arrow in Point ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawPivot(
|
|
XPivot &pivot,
|
|
XCBarArrowObject *&object,
|
|
int peakArrow = 159,
|
|
int valeArrow = 159,
|
|
int threshold = 5 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = NULL;
|
|
|
|
//
|
|
// Normalize ...
|
|
threshold = NormalizeInt(threshold, 5);
|
|
peakArrow = NormalizeInt(peakArrow, 159);
|
|
valeArrow = NormalizeInt(valeArrow, 159);
|
|
|
|
//
|
|
// Validate ...
|
|
result = pivot.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Get Pivot's Bar ...
|
|
XOHCL bar;
|
|
result = pivot.GetBar(bar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
int arrow = pivot.IsPeak()
|
|
? peakArrow
|
|
: valeArrow;
|
|
string name = pivot.GetObjectID();
|
|
ENUM_X_PRICE type = pivot.IsPeak()
|
|
? X_PRICE_HIGH
|
|
: X_PRICE_LOW;
|
|
XPOIStyle style = pivot.IsPeak()
|
|
? defaultBearishStyle
|
|
: defaultBullishStyle;
|
|
ENUM_ARROW_ANCHOR anchor = pivot.IsPeak()
|
|
? ANCHOR_BOTTOM
|
|
: ANCHOR_TOP;
|
|
object = new XCBarArrowObject();
|
|
result = object.CreateByBar(
|
|
ChartIdentification(),
|
|
name,
|
|
SubWindowIdentification(),
|
|
arrow,
|
|
bar,
|
|
type,
|
|
threshold //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
// Apply Styles ...
|
|
object.ArrowAnchor(anchor);
|
|
ApplyBarArrowStyle(
|
|
object,
|
|
style //
|
|
);
|
|
}
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
bar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Pivot Collection ...
|
|
*
|
|
* @param pivots: XPivot, reference Collection to Draw ...
|
|
* @param draws: CArrayObj, pointer reference to Hold Drawn Objects ...
|
|
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
|
|
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
|
|
* @param threshold: int, distance between price and arrow in Point ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int DrawPivots(
|
|
XPivot &pivots[],
|
|
CArrayObj *&draws,
|
|
int peakArrow = 159,
|
|
int valeArrow = 159,
|
|
int threshold = 5 //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Prepare ...
|
|
if (draws == NULL)
|
|
{
|
|
draws = new CArrayObj();
|
|
}
|
|
draws.Clear();
|
|
|
|
//
|
|
// Validate ...
|
|
if (!HasChild(pivots))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool has = false;
|
|
XCBarArrowObject *iObj;
|
|
int count = ArraySize(pivots);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
// Draw Indexed Pivot ...
|
|
has = DrawPivot(
|
|
pivots[i],
|
|
iObj,
|
|
peakArrow,
|
|
valeArrow,
|
|
threshold //
|
|
);
|
|
|
|
//
|
|
if (has)
|
|
{
|
|
draws.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
result = draws.Total();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Box ...
|
|
*
|
|
* @param object: XCBoxObject, pointer reference for Drawn Object ...
|
|
* @param name: Box Name ...
|
|
* @param upper: double, Box Upper ...
|
|
* @param lower: double, Box Lower ...
|
|
* @param from: datetime, From Time ...
|
|
* @param to: datetime, To Time ...
|
|
* @param at: datetime, Specified At Time ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawBox(
|
|
XCBoxObject *&object,
|
|
string name,
|
|
double upper,
|
|
double lower,
|
|
datetime from,
|
|
datetime to,
|
|
datetime at //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = NULL;
|
|
|
|
//
|
|
// Normalize ...
|
|
to = NormalizeTime(to);
|
|
from = NormalizeTime(from);
|
|
|
|
//
|
|
// Validate ...
|
|
result =
|
|
upper > 0 &&
|
|
lower > 0 &&
|
|
to > from &&
|
|
IsSpecifiedValid(to) &&
|
|
IsSpecifiedValid(name) &&
|
|
IsSpecifiedValid(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 //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Specific Box ...
|
|
*
|
|
* @param box: XBoxZone, Specified Box ...
|
|
* @param object: XCBarArrowObject, pointer reference for Drawn Object ...
|
|
* @param ignoreAt: bool, Ignore Box at or not ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawBox(
|
|
XBoxZone &box,
|
|
XCBoxObject *&object,
|
|
bool ignoreAt = true,
|
|
string name = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = NULL;
|
|
|
|
//
|
|
// Validate ...
|
|
result = box.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
datetime at = box.at;
|
|
if (ignoreAt)
|
|
{
|
|
at = NULL;
|
|
}
|
|
|
|
//
|
|
name = IsSpecifiedValid(name)
|
|
? name
|
|
: box.GetTag();
|
|
result = DrawBox(
|
|
object,
|
|
name,
|
|
box.upper,
|
|
box.lower,
|
|
box.from,
|
|
box.to,
|
|
at //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
// Apply Style ...
|
|
XPOIStyle style;
|
|
GetBoxStyle(
|
|
style,
|
|
box.dir //
|
|
);
|
|
|
|
//
|
|
ApplyBoxStyle(
|
|
object,
|
|
style //
|
|
);
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw a Collection of Boxes ...
|
|
*
|
|
* @param boxes: reference collection to Provide Boxes ...
|
|
* @param objects: reference pointer to holds drawn Objects ...
|
|
* @param ignoreAt: bool, ignore Box At Drawn ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int DrawBoxes(
|
|
XBoxZone &boxes[],
|
|
CArrayObj *&objects,
|
|
bool useTypeName = true,
|
|
bool ignoreAt = true //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
// Prepare ...
|
|
objects = new CArrayObj();
|
|
|
|
//
|
|
// Validate ...
|
|
if (!HasChild(boxes))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool has = false;
|
|
XCBoxObject *iObj;
|
|
string name = NULL;
|
|
int count = ArraySize(boxes);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
if (useTypeName)
|
|
{
|
|
name = boxes[i].type;
|
|
}
|
|
|
|
//
|
|
has = DrawBox(
|
|
boxes[i],
|
|
iObj,
|
|
ignoreAt,
|
|
name //
|
|
);
|
|
if (has)
|
|
{
|
|
objects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
//
|
|
result = objects.Total();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Signal ...
|
|
*
|
|
* @param signal: XSignal, Specified Signal ...
|
|
* @param object: XCSignalObject, pointer reference for Drawn Object ...
|
|
* @param length: int, Signal Length ...
|
|
*/
|
|
bool DrawSignal(
|
|
XSignal &signal,
|
|
XCSignalObject *&object,
|
|
int length = 3 //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
object = NULL;
|
|
length = NormalizeInt(length, 3);
|
|
|
|
//
|
|
result = signal.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string prefix = Prefix();
|
|
long chartID = ChartIdentification();
|
|
int window = SubWindowIdentification();
|
|
|
|
//
|
|
object = new XCSignalObject();
|
|
result = object.Create(
|
|
chartID,
|
|
window,
|
|
signal,
|
|
length,
|
|
prefix //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
object.TPWidth(1);
|
|
object.TPColor(clrGreen);
|
|
object.TPWidth(STYLE_DOT);
|
|
|
|
//
|
|
object.SLWidth(1);
|
|
object.SLColor(clrRed);
|
|
object.SLWidth(STYLE_DOT);
|
|
|
|
//
|
|
object.TargetWidth(1);
|
|
object.TargetColor(clrLightBlue);
|
|
object.TargetWidth(STYLE_DOT);
|
|
|
|
//
|
|
object.EntryWidth(1);
|
|
object.EntryColor(clrYellow);
|
|
object.EntryWidth(STYLE_DOT);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Trend Line ...
|
|
*
|
|
* @param fromPrice: double, from Price ...
|
|
* @param fromTime: datetime, from Time ...
|
|
* @param toPrice: double, to Price ...
|
|
* @param toTime: datetime, to Time ...
|
|
* @param object: CChartObjectTrend, pointer reference for Drawn Object ...
|
|
* @param name: Object Name ...
|
|
* @param rayRight: bool, ray to Right ...
|
|
* @param rayLeft: boo, ray to Left ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawTrendLine(
|
|
double fromPrice,
|
|
datetime fromTime,
|
|
double toPrice,
|
|
datetime toTime,
|
|
CChartObjectTrend *&object,
|
|
string name,
|
|
bool rayRight = false,
|
|
bool rayLeft = false //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = new CChartObjectTrend();
|
|
|
|
//
|
|
// Validate ...
|
|
result =
|
|
toPrice > 0 &&
|
|
fromPrice > 0 &&
|
|
IsSpecifiedValid(toTime) &&
|
|
IsSpecifiedValid(fromTime) &&
|
|
toTime > fromTime;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Create Object ...
|
|
result = object.Create(
|
|
ChartIdentification(),
|
|
name,
|
|
SubWindowIdentification(),
|
|
fromTime,
|
|
fromPrice,
|
|
toTime,
|
|
toPrice //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
ENUM_X_DIRECTION dir =
|
|
fromPrice < toPrice
|
|
? X_DIRECTION_BULLISH
|
|
: fromPrice > toPrice
|
|
? X_DIRECTION_BEARISH
|
|
: X_DIRECTION_NONE;
|
|
ApplyTrendLineStyle(
|
|
object,
|
|
dir //
|
|
);
|
|
|
|
//
|
|
object.RayLeft(rayLeft);
|
|
object.RayRight(rayRight);
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Draw Trend Line based on Swings Points ...
|
|
*
|
|
* @param swings: XOHCL, Specified Swings ...
|
|
* @param dir: ENUM_X_DIRECTION, Specified Trend Direction ...
|
|
* @param object: CChartObjectTrend, pointer reference for Drawn Object ...
|
|
* @param rayRight: Ray to Right ...
|
|
* @param rayLeft: Ray to Left ...
|
|
*
|
|
* @return ( bool )
|
|
*/
|
|
bool DrawSwingTrend(
|
|
XOHCL &swings[],
|
|
ENUM_X_DIRECTION dir,
|
|
CChartObjectTrend *&object,
|
|
bool rayRight = false,
|
|
bool rayLeft = false //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Prepare ...
|
|
object = NULL;
|
|
|
|
//
|
|
int count = ArraySize(swings);
|
|
result = HasChild(swings) &&
|
|
count >= 2 &&
|
|
HasDirection(dir);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish = IsSpecifiedBullish(dir);
|
|
|
|
//
|
|
XOHCL _swings[];
|
|
Copy(
|
|
swings,
|
|
_swings //
|
|
);
|
|
SortBar(
|
|
_swings,
|
|
X_SORT_BY_DATE,
|
|
X_DIRECTION_BULLISH //
|
|
);
|
|
|
|
//
|
|
double price1 =
|
|
isBullish
|
|
? _swings[0].low
|
|
: _swings[0].high;
|
|
datetime time1 = _swings[0].time;
|
|
|
|
//
|
|
double price2 =
|
|
isBullish
|
|
? _swings[count - 1].low
|
|
: _swings[count - 1].high;
|
|
datetime time2 = _swings[count - 1].time;
|
|
|
|
//
|
|
ulong chartId = ChartIdentification();
|
|
int subWindow = SubWindowIdentification();
|
|
string name = ToXString(dir) + "_Trend_" + ToXString(price1) + "_" + ToXString(price2);
|
|
RemoveObjects("_Trend_", chartId, subWindow);
|
|
|
|
//
|
|
object = new CChartObjectTrend();
|
|
result = object.Create(
|
|
chartId,
|
|
name,
|
|
subWindow,
|
|
time1,
|
|
price1,
|
|
time2,
|
|
price2 //
|
|
);
|
|
if (result)
|
|
{
|
|
//
|
|
ApplyTrendLineStyle(
|
|
object,
|
|
dir //
|
|
);
|
|
|
|
//
|
|
object.RayLeft(rayLeft);
|
|
object.RayRight(rayRight);
|
|
}
|
|
|
|
//
|
|
SpecifiedClean(_swings);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Stylers ...
|
|
|
|
/**
|
|
* Get Specified Style for Specified Direction ...
|
|
*
|
|
* @param style: XPOIStyle, reference to hold result ...
|
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
|
*/
|
|
void GetStyle(
|
|
XPOIStyle &style,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
// Prepare ...
|
|
style.Clean();
|
|
|
|
//
|
|
// Validate ...
|
|
if (!HasDirection(forDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (IsSpecifiedBullish(forDir))
|
|
{
|
|
style = defaultBullishStyle;
|
|
}
|
|
else
|
|
{
|
|
style = defaultBearishStyle;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get Specified Box Style for Specified Direction ...
|
|
*
|
|
* @param style: XPOIStyle, reference to hold result ...
|
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
|
*/
|
|
void GetBoxStyle(
|
|
XPOIStyle &style,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
// Prepare ...
|
|
style.Clean();
|
|
|
|
//
|
|
// Validate ...
|
|
if (!HasDirection(forDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (IsSpecifiedBullish(forDir))
|
|
{
|
|
style = boxBullishStyle;
|
|
}
|
|
else
|
|
{
|
|
style = boxBearishStyle;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: XCBoxObject, pointer reference of Object ...
|
|
* @param bar: XOHCL, Specified Bar ...
|
|
* @param fill: boolean, Fill Bar's Body or not ...
|
|
*/
|
|
void ApplyBarStyle(
|
|
XCOHCLObject *&object,
|
|
XOHCL &bar,
|
|
bool fill = false //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = bar.IsValid() &&
|
|
object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XPOIStyle style;
|
|
GetStyle(
|
|
style,
|
|
bar.GetDirection() //
|
|
);
|
|
|
|
//
|
|
object.BarSpes(
|
|
style.width,
|
|
style.clr,
|
|
style.style,
|
|
fill //
|
|
);
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: XCBoxObject, pointer reference of Object ...
|
|
* @param style: XPOIStyle, Specifed Style to Apply ...
|
|
*/
|
|
void ApplyBoxStyle(
|
|
XCBoxObject *&object,
|
|
XPOIStyle &style //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.BoxFill(style.fill);
|
|
object.BoxColor(style.clr);
|
|
object.BoxWidth(style.width);
|
|
object.BoxStyle(style.style);
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to a Collection on Drawn Boxes ...
|
|
*
|
|
* @param objects: pointer reference of Objects ...
|
|
* @param style: XPOIStyle, Specifed Style to Apply ...
|
|
*/
|
|
void ApplyBoxesStyle(
|
|
CArrayObj *&objects,
|
|
XPOIStyle &style //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
if (objects == NULL || objects.Total() <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < objects.Total(); i++)
|
|
{
|
|
//
|
|
XCBoxObject *iObj = ((XCBoxObject *)objects.At(i));
|
|
ApplyBoxStyle(
|
|
iObj,
|
|
style //
|
|
);
|
|
ZeroMemory(iObj);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: XCBarArrowObject, pointer reference of Object ...
|
|
* @param style: XPOIStyle, Specifed Style to Apply ...
|
|
*/
|
|
void ApplyBarArrowStyle(
|
|
XCBarArrowObject *&object,
|
|
XPOIStyle &style //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.ArrowColor(style.clr);
|
|
object.ArrowWidth(style.width);
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: CChartObjectVLine, pointer reference of Object ...
|
|
* @param style: XPOIStyle, Specifed Style to Apply ...
|
|
*/
|
|
void ApplyLineStyle(
|
|
CChartObjectVLine *&object,
|
|
XPOIStyle &style //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.Color(style.clr);
|
|
object.Style(style.style);
|
|
object.Width(style.width);
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: CChartObjectVLine, pointer reference of Object ...
|
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
|
*/
|
|
void ApplyLineStyle(
|
|
CChartObjectVLine *&object,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = HasDirection(forDir);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XPOIStyle style;
|
|
GetStyle(style, forDir);
|
|
|
|
//
|
|
object.Color(style.clr);
|
|
object.Style(style.style);
|
|
object.Width(style.width);
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: CChartObjectHLine, pointer reference of Object ...
|
|
* @param style: XPOIStyle, Specifed Style to Apply ...
|
|
*/
|
|
void ApplyLineStyle(
|
|
CChartObjectHLine *&object,
|
|
XPOIStyle &style //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
object.Color(style.clr);
|
|
object.Style(style.style);
|
|
object.Width(style.width);
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: CChartObjectHLine, pointer reference of Object ...
|
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
|
*/
|
|
void ApplyLineStyle(
|
|
CChartObjectHLine *&object,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
has = HasDirection(forDir);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XPOIStyle style;
|
|
GetStyle(style, forDir);
|
|
|
|
//
|
|
object.Color(style.clr);
|
|
object.Style(style.style);
|
|
object.Width(style.width);
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
|
|
/**
|
|
* Apply Specified Style to Specified Object ...
|
|
*
|
|
* @param object: CChartObjectTrend, pointer reference of Object ...
|
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
|
*/
|
|
void ApplyTrendLineStyle(
|
|
CChartObjectTrend *&object,
|
|
ENUM_X_DIRECTION forDir //
|
|
)
|
|
{
|
|
//
|
|
bool has = object != NULL;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (!HasDirection(forDir))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XPOIStyle style;
|
|
GetStyle(style, forDir);
|
|
|
|
//
|
|
object.Color(style.clr);
|
|
object.Style(style.style);
|
|
object.Width(style.width);
|
|
|
|
//
|
|
style.Clean();
|
|
}
|
|
|
|
//
|
|
// SPecial Draws Functions ...
|
|
|
|
/**
|
|
* Draw Specified Pattern Pivot ...
|
|
*
|
|
* @param _pivot: XPivot, reference to Specified Pivot ...
|
|
* @param config: XPOIDrawConfig, Darwing Configuration ...
|
|
* @param thresholdMultiplier: int, pivot point threshold ...
|
|
*/
|
|
void DrawPivot(
|
|
XPivot &_pivot,
|
|
XPOIDrawConfig &config,
|
|
int thresholdMultiplier = 0 //
|
|
)
|
|
{
|
|
//
|
|
// Normalize ...
|
|
thresholdMultiplier = NormalizeInt(thresholdMultiplier, 1);
|
|
|
|
//
|
|
int arrowThreshold = config.arrowsThreshold * thresholdMultiplier;
|
|
arrowThreshold = NormalizeInt(arrowThreshold, 1);
|
|
|
|
//
|
|
// Validate ...
|
|
bool has = _pivot.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XOHCL _bar;
|
|
has = _pivot.GetBar(_bar);
|
|
if (!has)
|
|
{
|
|
//
|
|
_bar.Clean();
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCBarArrowObject *iObj;
|
|
has = DrawBarArrow(
|
|
_bar,
|
|
iObj,
|
|
_pivot.IsPeak()
|
|
? config.arrowsPeakPriceType
|
|
: config.arrowsValePriceType,
|
|
_pivot.IsBullish()
|
|
? config.bullishArrow
|
|
: config.bearishArrow,
|
|
_pivot.IsBullish()
|
|
? config.bullishColor
|
|
: config.bearishColor,
|
|
config.arrowsWidth,
|
|
_pivot.IsBullish()
|
|
? ANCHOR_TOP
|
|
: ANCHOR_BOTTOM,
|
|
_pivot.prefix + "_Pivot_" + ToXString(TimeToSeconds(_pivot.time)),
|
|
true, // Ignore Bar Tag ...
|
|
arrowThreshold // Threshold ...
|
|
);
|
|
if (has)
|
|
{
|
|
drawnObjects.Add(iObj);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Pattern Zone ...
|
|
*
|
|
* @param _zone: XBozxZone, reference to Specified Zone ...
|
|
* @param config: XPOIDrawConfig, Darwing Configuration ...
|
|
*/
|
|
void DrawZone(
|
|
XBoxZone &_zone,
|
|
XPOIDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = _zone.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XCBoxObject *iObj;
|
|
has = DrawBox(
|
|
_zone,
|
|
iObj,
|
|
config.ignoreZonesAt,
|
|
_zone.type + "_Zone_" + ToXString(TimeToSeconds(_zone.from)) //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
XPOIStyle iStyle;
|
|
GetBoxStyle(
|
|
iStyle,
|
|
_zone.dir //
|
|
);
|
|
|
|
//
|
|
iStyle.clr =
|
|
_zone.IsBullish()
|
|
? config.bullishColor
|
|
: config.bearishColor;
|
|
iStyle.width = config.zonesWidth;
|
|
iStyle.style = config.zonesStyle;
|
|
|
|
//
|
|
ApplyBoxStyle(
|
|
iObj,
|
|
iStyle //
|
|
);
|
|
|
|
//
|
|
drawnObjects.Add(iObj);
|
|
|
|
//
|
|
iStyle.Clean();
|
|
}
|
|
|
|
//
|
|
ZeroMemory(iObj);
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Zones ...
|
|
*
|
|
* @param _zone: XBozxZone, reference to Collection Specified Zone ...
|
|
* @param config: XPOIDrawConfig, Darwing Configuration ...
|
|
*/
|
|
void DrawZones(
|
|
XBoxZone &_zones[],
|
|
XPOIDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = HasChild(_zones);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < ArraySize(_zones); i++)
|
|
{
|
|
//
|
|
DrawZone(
|
|
_zones[i],
|
|
config //
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Pivots ...
|
|
*
|
|
* @param pivots: XPivot, collection reference to Draw ...
|
|
* @param config: XPOIDrawConfig, reference to Specified Draw Style ...
|
|
*/
|
|
void DrawPivots(
|
|
XPivot &pivots[],
|
|
XPOIDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = HasChild(pivots);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XPivot tmps[];
|
|
int count = ArraySize(pivots);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XClean(tmps);
|
|
int sameCounts = ExtractSameTimePivots(pivots[i], tmps, pivots);
|
|
has = IsValidSize(sameCounts);
|
|
if (has)
|
|
{
|
|
//
|
|
for (int j = 0; j < sameCounts; j++)
|
|
{
|
|
DrawPivot(tmps[j], config, j + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
XClean(tmps);
|
|
}
|
|
|
|
void DrawTrendLine(
|
|
string name,
|
|
double fromPrice,
|
|
datetime fromTime,
|
|
double toPrice,
|
|
datetime toTime,
|
|
XPOIDrawConfig &config,
|
|
color clr = CLR_NONE //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has =
|
|
IsXValid(name) &&
|
|
IsXValid(toTime) &&
|
|
IsXValid(fromTime) &&
|
|
NotEmptyZero(toPrice) &&
|
|
NotEmptyZero(fromPrice) &&
|
|
fromTime < toTime;
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
ENUM_X_DIRECTION trendDir =
|
|
fromPrice > toPrice
|
|
? X_DIRECTION_BEARISH
|
|
: fromPrice < toPrice
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_NONE;
|
|
color clrTrend =
|
|
(clr != CLR_NONE)
|
|
? clr
|
|
: IsXBullish(trendDir)
|
|
? config.bullishColor
|
|
: config.bearishColor;
|
|
|
|
//
|
|
CChartObjectTrend *object;
|
|
has = DrawTrendLine(
|
|
fromPrice,
|
|
fromTime,
|
|
toPrice,
|
|
toTime,
|
|
object,
|
|
name,
|
|
config.trendRayRight,
|
|
config.trendRayLeft //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Apply Style ...
|
|
object.Color(clrTrend);
|
|
object.Width(config.trendWidth);
|
|
object.Style(config.trendStyle);
|
|
|
|
//
|
|
// Save Object ...
|
|
drawnObjects.Add(object);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(object);
|
|
}
|
|
|
|
void DrawTrendLine(
|
|
XTrend &trend,
|
|
XPOIDrawConfig &config,
|
|
color clr = CLR_NONE //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has = trend.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
color trendColor =
|
|
(clr != CLR_NONE)
|
|
? clr
|
|
: trend.IsBullish()
|
|
? config.bullishColor
|
|
: trend.IsBearish()
|
|
? config.bearishColor
|
|
: config.neuturalColor;
|
|
string name = trend.GetObjectID();
|
|
|
|
//
|
|
CChartObjectTrend *object;
|
|
has = DrawTrendLine(
|
|
trend.fromValue,
|
|
trend.fromTime,
|
|
trend.toValue,
|
|
trend.toTime,
|
|
object,
|
|
name,
|
|
config.trendRayRight,
|
|
config.trendRayLeft //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Apply Style ...
|
|
object.Color(trendColor);
|
|
object.Width(config.trendWidth);
|
|
object.Style(config.trendStyle);
|
|
|
|
//
|
|
// Save Object ...
|
|
drawnObjects.Add(object);
|
|
}
|
|
|
|
//
|
|
ZeroMemory(object);
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Pattern info ...
|
|
*
|
|
* @param _bar: XOHCL, reference to Pattern's Bar ...
|
|
* @param _pivot: XPivot, reference to Pattern's Pivot ...
|
|
* @param _zone: XBoxZone, reference to Pattern's Zone ...
|
|
* @param _pattern: ENUM_X_BAR_PATTERN, Specified Bar Pattern ...
|
|
* @param _patternDir: ENUM_X_DIRECTION, Specified Bar Pattern's Direction ...
|
|
* @param thresholdMultiplier: int, pivot point threshold ...
|
|
* @param config: XPOIDrawConfig, Darwing Configuration ...
|
|
*/
|
|
void DrawPattern(
|
|
XOHCL &_bar,
|
|
XPivot &_pivot,
|
|
XBoxZone &_zone,
|
|
ENUM_X_BAR_PATTERN _pattern,
|
|
ENUM_X_DIRECTION _patternDir,
|
|
XPOIDrawConfig &config,
|
|
int thresholdMultiplier = 0 //
|
|
)
|
|
{
|
|
//
|
|
// Validate ...
|
|
bool has =
|
|
_bar.IsValid() &&
|
|
IsXValid(_pattern) &&
|
|
HasDirection(_patternDir);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Handle Draws ...
|
|
|
|
//
|
|
// Draw OHCL Bar ...
|
|
|
|
//
|
|
// Draw Pivot ...
|
|
DrawPivot(_pivot, config, thresholdMultiplier);
|
|
|
|
//
|
|
// Draw Zone ...
|
|
_zone.to = cTime;
|
|
DrawZone(_zone, config);
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Bar Pattern Analysis ...
|
|
*
|
|
* @param analysis: XPatternAnalysis, reference to Specified Bar Pattern Analysis ...
|
|
* @param config: XPatternAnalysisDrawConfig, reference to Provide Drawing Configuration ...
|
|
*/
|
|
void DrawPatternAnalysis(
|
|
XPatternAnalysis &analysis,
|
|
XPatternAnalysisDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
bool has = analysis.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
bool canDraw;
|
|
bool isBullish;
|
|
bool isBearish;
|
|
XOHCL patternBar;
|
|
bool canDrawZone;
|
|
bool canDrawPivot;
|
|
XPivot patternPivot;
|
|
XBoxZone patternBox;
|
|
ENUM_X_BAR_PATTERN pattern;
|
|
ENUM_X_DIRECTION patternDir;
|
|
|
|
//
|
|
datetime cTime = TimeCurrent();
|
|
int patternsPivotThresholdMultiplier = 0;
|
|
|
|
//
|
|
// Support and Resistance ...
|
|
|
|
//
|
|
// Support ...
|
|
isBearish = false;
|
|
isBullish = analysis.IsSupport();
|
|
has = isBullish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_SUPPORT;
|
|
patternDir = X_DIRECTION_BULLISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance ...
|
|
isBullish = false;
|
|
isBearish = analysis.IsResistance();
|
|
has = isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_RESISTANCE;
|
|
patternDir = X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// PV: High and Low ...
|
|
|
|
//
|
|
// Low ...
|
|
isBearish = false;
|
|
isBullish = analysis.IsLow();
|
|
has = isBullish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_LOW;
|
|
patternDir = X_DIRECTION_BULLISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// High ...
|
|
isBullish = false;
|
|
isBearish = analysis.IsHigh();
|
|
has = isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_HIGH;
|
|
patternDir = X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// OB ...
|
|
isBullish = analysis.IsOB(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsOB(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_OB;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// FVG ...
|
|
isBullish = analysis.IsFVG(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsFVG(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_FVG;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Momentum ...
|
|
isBullish = analysis.IsMomentum(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsMomentum(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_MOMENTUM;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Engulfed ...
|
|
isBullish = analysis.IsEngulfed(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsEngulfed(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_ENGULFED;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Pinned ...
|
|
isBullish = analysis.IsPinned(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsPinned(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_PINNED;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// TrueGaped ...
|
|
isBullish = analysis.IsTrueGaped(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsTrueGaped(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_TRUE_GAPED;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Star ...
|
|
isBullish = analysis.IsStar(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsStar(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_STAR;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Piercing ...
|
|
isBullish = analysis.IsPiercing(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsPiercing(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_PIERCING;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Rising ...
|
|
isBullish = analysis.IsRising(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsRising(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_RISING;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Flag ...
|
|
isBullish = analysis.IsFlag(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsFlag(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_FLAG;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// SignalKey ...
|
|
isBullish = analysis.IsSignalKey(X_DIRECTION_BULLISH);
|
|
isBearish = analysis.IsSignalKey(X_DIRECTION_BEARISH);
|
|
has = isBullish || isBearish;
|
|
if (has)
|
|
{
|
|
//
|
|
pattern = X_BAR_PATTERN_SIGNALKEY;
|
|
patternDir =
|
|
isBullish
|
|
? X_DIRECTION_BULLISH
|
|
: X_DIRECTION_BEARISH;
|
|
canDraw = config.CanDraw(pattern);
|
|
if (canDraw)
|
|
{
|
|
//
|
|
has = analysis.GetPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
canDrawZone = config.CanDrawZone(pattern);
|
|
if (!canDrawZone)
|
|
{
|
|
patternBox.Clean();
|
|
}
|
|
|
|
//
|
|
canDrawPivot = config.CanDrawPivot(pattern);
|
|
if (!canDrawPivot)
|
|
{
|
|
patternPivot.Clean();
|
|
}
|
|
else
|
|
{
|
|
patternsPivotThresholdMultiplier++;
|
|
}
|
|
|
|
//
|
|
DrawPattern(
|
|
patternBar,
|
|
patternPivot,
|
|
patternBox,
|
|
pattern,
|
|
patternDir,
|
|
config.drawConfig,
|
|
patternsPivotThresholdMultiplier //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cleanup Resources ...
|
|
patternBar.Clean();
|
|
patternBox.Clean();
|
|
patternPivot.Clean();
|
|
}
|
|
|
|
/**
|
|
* Draw a Collection of Pattern Analysis ...
|
|
*
|
|
* @param analysises: XPatternAnalysis, collection reference to Data Source ...
|
|
* @param config: XPatternAnalysisDrawConfig, reference to Specified Drawing Config ...
|
|
*/
|
|
void DrawPatternAnalysises(
|
|
XPatternAnalysis &analysises[],
|
|
XPatternAnalysisDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
bool has = HasChild(analysises);
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(analysises);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
DrawPatternAnalysis(analysises[i], config);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Draw Specified Pivots Analysis ...
|
|
*
|
|
* @param analysis: XPivotAnalysis, reference to Specified Pivot Analysis ...
|
|
* @param config: XPivotAnalysisDrawConfig, reference to Provide Drawing Configuration ...
|
|
*/
|
|
void DrawPivotAnalysis(
|
|
XPivotAnalysis &analysis,
|
|
XPivotAnalysisDrawConfig &config //
|
|
)
|
|
{
|
|
//
|
|
bool has = analysis.IsValid();
|
|
if (!has)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
int count = 0;
|
|
XBoxZone tmpBox;
|
|
datetime cTime = TimeCurrent();
|
|
|
|
//
|
|
// Pivots ...
|
|
if (config.drawPivots)
|
|
{
|
|
//
|
|
has = analysis.HasPivots();
|
|
if (has)
|
|
{
|
|
//
|
|
count = ArraySize(analysis.pivots);
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
DrawPivot(
|
|
analysis.pivots[i],
|
|
config.drawConfig //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Support ...
|
|
if (config.drawSupport)
|
|
{
|
|
//
|
|
tmpBox.Clean();
|
|
has = analysis.HasSupportBox(tmpBox);
|
|
if (has)
|
|
{
|
|
//
|
|
tmpBox.to = cTime;
|
|
DrawZone(
|
|
tmpBox,
|
|
config.drawConfig //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Resistance ...
|
|
if (config.drawResistance)
|
|
{
|
|
//
|
|
tmpBox.Clean();
|
|
has = analysis.HasResistanceBox(tmpBox);
|
|
if (has)
|
|
{
|
|
//
|
|
tmpBox.to = cTime;
|
|
DrawZone(
|
|
tmpBox,
|
|
config.drawConfig //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Peak Trend ...
|
|
if (config.drawPeakTrend)
|
|
{
|
|
//
|
|
has = analysis.IsPeakAnalysed();
|
|
if (has)
|
|
{
|
|
//
|
|
string iUpperName = analysis.GetUpperObjectID();
|
|
CChartObjectTrend *iObj = new CChartObjectTrend();
|
|
has = iObj.Create(
|
|
ChartIdentification(),
|
|
iUpperName,
|
|
SubWindowIdentification(),
|
|
analysis.fromTime,
|
|
analysis.peakFrom,
|
|
analysis.toTime,
|
|
analysis.peakTo //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Styling ...
|
|
iObj.RayLeft(config.rayLeftTrends);
|
|
iObj.RayRight(config.rayRightTrends);
|
|
iObj.Width(config.drawConfig.zonesWidth);
|
|
iObj.Style(config.drawConfig.zonesStyle);
|
|
iObj.Color(IsXBullish(analysis.peakDir)
|
|
? config.drawConfig.bullishColor
|
|
: config.drawConfig.bearishColor);
|
|
|
|
//
|
|
// Storing ...
|
|
drawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Vale Trend ...
|
|
if (config.drawValeTrend)
|
|
{
|
|
//
|
|
has = analysis.IsValeAnalysed();
|
|
if (has)
|
|
{
|
|
//
|
|
string iLowerName = analysis.GetLowerObjectID();
|
|
CChartObjectTrend *iObj = new CChartObjectTrend();
|
|
has = iObj.Create(
|
|
ChartIdentification(),
|
|
iLowerName,
|
|
SubWindowIdentification(),
|
|
analysis.fromTime,
|
|
analysis.valeFrom,
|
|
analysis.toTime,
|
|
analysis.valeTo //
|
|
);
|
|
if (has)
|
|
{
|
|
//
|
|
// Styling ...
|
|
iObj.RayLeft(config.rayLeftTrends);
|
|
iObj.RayRight(config.rayRightTrends);
|
|
iObj.Width(config.drawConfig.zonesWidth);
|
|
iObj.Style(config.drawConfig.zonesStyle);
|
|
iObj.Color(IsXBullish(analysis.valeDir)
|
|
? config.drawConfig.bullishColor
|
|
: config.drawConfig.bearishColor);
|
|
|
|
//
|
|
// Storing ...
|
|
drawnObjects.Add(iObj);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Cleanup ...
|
|
tmpBox.Clean();
|
|
|
|
//
|
|
}
|
|
|
|
protected:
|
|
//
|
|
|
|
//
|
|
private:
|
|
//
|
|
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
string mPrefix; // Prefix of Created Objects ...
|
|
long mChartIdentification; // Chart Id ...
|
|
int mSubWindowIdentification; // Sub Window ...
|
|
|
|
//
|
|
}; |