last works on Position ...
This commit is contained in:
@@ -40,11 +40,16 @@ class XCPositionDrawer : public XCBase
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
int window;
|
||||
ulong chartID;
|
||||
XCTrade *trader;
|
||||
CArrayObj positionObjects;
|
||||
CArrayObj finalizedObjects;
|
||||
int window; // Window ID of Chart ...
|
||||
ulong chartID; // Chart ID ...
|
||||
XCTrade *trader; // XCTrade Instance ...
|
||||
XPOIStyle riskStyle; // Risk Box Style ...
|
||||
color inProfitColor; // In Profit Price Box Color ...
|
||||
color inDrawdownColor; // In Drawdown Price Box Color ...
|
||||
ENUM_LINE_STYLE priceStyle; // Price Box Style ...
|
||||
XPOIStyle rewardStyle; // Reward Box Style ...
|
||||
CArrayObj positionObjects; // Drawn Positions Object Instances Collection ...
|
||||
CArrayObj finalizedObjects; // Finalized Drawn Positions Object Instances Collection ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -72,6 +77,13 @@ class XCPositionDrawer : public XCBase
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Initialize Class Instance ...
|
||||
*
|
||||
* @param _trader: XCTrade, reference Pointer to Trader Instance Class ...
|
||||
* @param _chartID: ulong, Specified Chart ID ...
|
||||
* @param _window: int, Specified Chart Window ID ...
|
||||
*/
|
||||
void Init(
|
||||
XCTrade *_trader,
|
||||
ulong _chartID = 0,
|
||||
@@ -93,12 +105,48 @@ class XCPositionDrawer : public XCBase
|
||||
trader = _trader;
|
||||
window = _window;
|
||||
chartID = _chartID;
|
||||
|
||||
//
|
||||
// Prepare Default Styles ...
|
||||
|
||||
//
|
||||
// Risk Style ...
|
||||
riskStyle.width = 1;
|
||||
riskStyle.fill = false;
|
||||
riskStyle.clr = clrRed;
|
||||
riskStyle.style = STYLE_DASH;
|
||||
|
||||
//
|
||||
// Reward Style ...
|
||||
rewardStyle.width = 1;
|
||||
rewardStyle.fill = false;
|
||||
rewardStyle.clr = clrLime;
|
||||
rewardStyle.style = STYLE_DASH;
|
||||
|
||||
//
|
||||
// Price Style ...
|
||||
priceStyle = STYLE_SOLID;
|
||||
inProfitColor = ApplyAlpha(clrAqua, 100);
|
||||
inDrawdownColor = ApplyAlpha(clrMagenta, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
//
|
||||
riskStyle.Clean();
|
||||
rewardStyle.Clean();
|
||||
// positionObjects
|
||||
// finalizedObjects
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
@@ -112,6 +160,11 @@ class XCPositionDrawer : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Positions ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
*/
|
||||
void Update(int barIndex = 0)
|
||||
{
|
||||
//
|
||||
@@ -138,6 +191,7 @@ class XCPositionDrawer : public XCBase
|
||||
has = IsValidSize(drawingsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < positionsCount; i++)
|
||||
{
|
||||
//
|
||||
@@ -148,7 +202,9 @@ class XCPositionDrawer : public XCBase
|
||||
has = ((XCPositionObject *)positionObjects.At(j)).IsBelong(positions[i]);
|
||||
if (has)
|
||||
{
|
||||
((XCPositionObject *)positionObjects.At(j)).Update(positions[i]);
|
||||
//
|
||||
// Update Position Object ...
|
||||
has = ((XCPositionObject *)positionObjects.At(j)).Update(positions[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,7 +230,7 @@ class XCPositionDrawer : public XCBase
|
||||
{
|
||||
//
|
||||
// Manully Update Position ...
|
||||
((XCPositionObject *)positionObjects.At(i)).Update(barIndex);
|
||||
has = ((XCPositionObject *)positionObjects.At(i)).Update(barIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,12 +286,26 @@ class XCPositionDrawer : public XCBase
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCPositionObject *iObj;
|
||||
XCPositionObject *iObj = new XCPositionObject();
|
||||
has = iObj.Create(
|
||||
chartID,
|
||||
window,
|
||||
iPosition //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Set Stylers to Position ...
|
||||
iObj.riskStyle = riskStyle;
|
||||
iObj.priceStyle = priceStyle;
|
||||
iObj.rewardStyle = rewardStyle;
|
||||
iObj.inProfitColor = inProfitColor;
|
||||
iObj.inDrawdownColor = inDrawdownColor;
|
||||
|
||||
//
|
||||
// Add to Collection ...
|
||||
positionObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -284,7 +354,12 @@ class XCPositionDrawer : public XCBase
|
||||
protected:
|
||||
//
|
||||
|
||||
//
|
||||
/**
|
||||
* Finalize Specified Position ...
|
||||
* Remove it From Position Objects and add it to Finalized Objects Cllection ...
|
||||
*
|
||||
* @param ticket: ulong, Specified Position Ticket ...
|
||||
*/
|
||||
void Finalize(ulong ticket)
|
||||
{
|
||||
//
|
||||
@@ -301,6 +376,13 @@ class XCPositionDrawer : public XCBase
|
||||
finalizedObjects.Add(iObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Specified Position Index ...
|
||||
*
|
||||
* @param ticket: ulong, Specified Position Ticket ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int FindIndex(ulong ticket)
|
||||
{
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user