Refactor XCObjects and Extends them from Base XCObject Class and also Implement GUI Features on EA Class and Refactor Inputs ...
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#property strict
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//
|
||||
// a Button Creation Class ...
|
||||
class XCButton : XSCBase
|
||||
class XCButton : public XCObject
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -64,7 +64,8 @@ class XCButton : XSCBase
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
int ySize,
|
||||
long chartID = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -72,33 +73,26 @@ class XCButton : XSCBase
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_BUTTON, 0, 0, 0);
|
||||
result = ObjectCreate(chartID, name, OBJ_BUTTON, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
mChartID = chartID;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
@@ -107,9 +101,9 @@ class XCButton : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBorderColor(color value)
|
||||
void BorderColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_BORDER_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,9 +111,9 @@ class XCButton : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
void BGColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_BGCOLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,9 +121,9 @@ class XCButton : XSCBase
|
||||
*
|
||||
* @param value: Color
|
||||
*/
|
||||
void SetColor(color value)
|
||||
void Color(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,29 +131,9 @@ class XCButton : XSCBase
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
void Text(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ZOrder ...
|
||||
*
|
||||
* @param value: z order
|
||||
*/
|
||||
void SetZOrder(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object as Background ...
|
||||
*
|
||||
* @param value: boolean value
|
||||
*/
|
||||
void SetAsBackGround(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
|
||||
ObjectSetString(mChartID, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,9 +141,9 @@ class XCButton : XSCBase
|
||||
*
|
||||
* @param value: state
|
||||
*/
|
||||
void SetState(bool value)
|
||||
void State(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_STATE, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_STATE, value);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -179,24 +153,4 @@ class XCButton : XSCBase
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#property strict
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//
|
||||
// a Label Creation Class ...
|
||||
class XCEdit : XSCBase
|
||||
class XCEdit : public XCObject
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -64,7 +64,8 @@ class XCEdit : XSCBase
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
int ySize,
|
||||
long chartID = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -72,33 +73,26 @@ class XCEdit : XSCBase
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_EDIT, 0, 0, 0);
|
||||
result = ObjectCreate(chartID, name, OBJ_EDIT, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
mChartID = chartID;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
@@ -107,9 +101,9 @@ class XCEdit : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBorderColor(color value)
|
||||
void BorderColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BORDER_COLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_BORDER_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,9 +111,9 @@ class XCEdit : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
void BGColor(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BGCOLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_BGCOLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,9 +121,9 @@ class XCEdit : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetTextColor(color value)
|
||||
void Color(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,9 +131,9 @@ class XCEdit : XSCBase
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
void Text(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
ObjectSetString(mChartID, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,29 +141,9 @@ class XCEdit : XSCBase
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetText()
|
||||
string Text()
|
||||
{
|
||||
return ObjectGetString(0, mName, OBJPROP_TEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ZOrder ...
|
||||
*
|
||||
* @param value: z order
|
||||
*/
|
||||
void SetZOrder(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object as Background ...
|
||||
*
|
||||
* @param value: boolean value
|
||||
*/
|
||||
void SetAsBackGround(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
|
||||
return ObjectGetString(mChartID, mName, OBJPROP_TEXT);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -179,24 +153,4 @@ class XCEdit : XSCBase
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#property strict
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//
|
||||
// a Label Creation Class ...
|
||||
class XCLabel : XSCBase
|
||||
class XCLabel : public XCObject
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -60,7 +60,8 @@ class XCLabel : XSCBase
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis //
|
||||
int yDis,
|
||||
long chartID = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -68,31 +69,24 @@ class XCLabel : XSCBase
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
|
||||
result = ObjectCreate(chartID, name, OBJ_LABEL, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
mChartID = chartID;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
@@ -101,9 +95,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetTextColor(color value)
|
||||
void Color(color value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_COLOR, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,9 +105,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @param value: text
|
||||
*/
|
||||
void SetText(string value)
|
||||
void Text(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
||||
ObjectSetString(mChartID, mName, OBJPROP_TEXT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,9 +115,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetText()
|
||||
string Text()
|
||||
{
|
||||
return ObjectGetString(0, mName, OBJPROP_TEXT);
|
||||
return ObjectGetString(mChartID, mName, OBJPROP_TEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,9 +125,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @param value: size
|
||||
*/
|
||||
void SetFontSize(int value)
|
||||
void FontSize(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_FONTSIZE, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_FONTSIZE, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,9 +135,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @param value: font name
|
||||
*/
|
||||
void SetFont(string value)
|
||||
void Font(string value)
|
||||
{
|
||||
ObjectSetString(0, mName, OBJPROP_FONT, value);
|
||||
ObjectSetString(mChartID, mName, OBJPROP_FONT, value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,29 +145,9 @@ class XCLabel : XSCBase
|
||||
*
|
||||
* @param value: anchor
|
||||
*/
|
||||
void SetAnchor(ENUM_ANCHOR_POINT value)
|
||||
void Anchor(ENUM_ANCHOR_POINT value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ZOrder ...
|
||||
*
|
||||
* @param value: z order
|
||||
*/
|
||||
void SetZOrder(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object as Background ...
|
||||
*
|
||||
* @param value: boolean value
|
||||
*/
|
||||
void SetAsBackGround(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
|
||||
ObjectSetInteger(mChartID, mName, OBJPROP_ANCHOR, value);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -183,24 +157,4 @@ class XCLabel : XSCBase
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
int mlbDownY;
|
||||
int mlbDownXDistance;
|
||||
int mlbDownYDistance;
|
||||
int mPreviousMouseState;
|
||||
|
||||
//
|
||||
bool mMovingState; // State for whether the object is moving
|
||||
|
||||
//
|
||||
string mAddedNames[]; // Array of added names
|
||||
long mAddedXDisDiffrence[]; // Arrays to store added distance differences
|
||||
long mAddedYDisDiffrence[]; // Arrays to store added distance differences
|
||||
};
|
||||
|
||||
@@ -30,16 +30,13 @@
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
class XCPanel : XSCBase
|
||||
class XCPanel : XCObject
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCPanel()
|
||||
{
|
||||
//
|
||||
// Enables mouse move events on the chart
|
||||
ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, true);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -78,6 +75,8 @@ class XCPanel : XSCBase
|
||||
int xSize,
|
||||
int ySize,
|
||||
//
|
||||
long chartID = 0,
|
||||
//
|
||||
// Title Bar ...
|
||||
ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT,
|
||||
color titleBarBGColor = clrBlueViolet,
|
||||
@@ -96,6 +95,10 @@ class XCPanel : XSCBase
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Enables mouse move events on the chart
|
||||
ChartSetInteger(chartID, CHART_EVENT_MOUSE_MOVE, true);
|
||||
|
||||
//
|
||||
result = IsValid(name);
|
||||
if (!result)
|
||||
@@ -132,8 +135,8 @@ class XCPanel : XSCBase
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mTitleBar.SetBorderType(titleBarBorderType);
|
||||
mTitleBar.SetBGColor(titleBarBGColor);
|
||||
mTitleBar.BorderType(titleBarBorderType);
|
||||
mTitleBar.BGColor(titleBarBGColor);
|
||||
|
||||
//
|
||||
// Body ...
|
||||
@@ -150,9 +153,9 @@ class XCPanel : XSCBase
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mBody.SetBorderType(bodyBorderType);
|
||||
mBody.SetBGColor(bodyBGColor);
|
||||
mBody.SetAsBackGround(true);
|
||||
mBody.BorderType(bodyBorderType);
|
||||
mBody.BGColor(bodyBGColor);
|
||||
mBody.AsBackGround(true);
|
||||
|
||||
//
|
||||
// Caption ...
|
||||
@@ -163,10 +166,10 @@ class XCPanel : XSCBase
|
||||
Destroy();
|
||||
return result;
|
||||
}
|
||||
mCaptionLbl.SetText(caption);
|
||||
mCaptionLbl.SetAnchor(captionAnchor);
|
||||
mCaptionLbl.SetTextColor(captionColor);
|
||||
mCaptionLbl.SetFontSize(captionontSize);
|
||||
mCaptionLbl.Text(caption);
|
||||
mCaptionLbl.Color(captionColor);
|
||||
mCaptionLbl.Anchor(captionAnchor);
|
||||
mCaptionLbl.FontSize(captionontSize);
|
||||
|
||||
//
|
||||
// Adding Child Objects ...
|
||||
@@ -233,7 +236,7 @@ class XCPanel : XSCBase
|
||||
*/
|
||||
string Caption()
|
||||
{
|
||||
return mCaptionLbl.GetText();
|
||||
return mCaptionLbl.Text();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +246,37 @@ class XCPanel : XSCBase
|
||||
*/
|
||||
void Caption(string value)
|
||||
{
|
||||
mCaptionLbl.SetText(value);
|
||||
mCaptionLbl.Text(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Caption Color ...
|
||||
*
|
||||
* @param value: Color
|
||||
*/
|
||||
void CptionColor(color value)
|
||||
{
|
||||
mCaptionLbl.Color(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Panel Body BG Color ...
|
||||
*
|
||||
* @param value: Color
|
||||
*/
|
||||
void BodyColor(color value)
|
||||
{
|
||||
mBody.BGColor(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Panel Titlebar BG Color ...
|
||||
*
|
||||
* @param value: Color
|
||||
*/
|
||||
void TitleBarBGColor(color value)
|
||||
{
|
||||
mTitleBar.BGColor(value);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#property strict
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
//
|
||||
// a Rectangle Label Creation Class ...
|
||||
class XCRectangleLabel : XSCBase
|
||||
class XCRectangleLabel : public XCObject
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -48,7 +48,68 @@ class XCRectangleLabel : XSCBase
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
* @param xSize: X Size
|
||||
* @param ySize: Y Size
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize,
|
||||
long chartID = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(chartID, name, OBJ_RECTANGLE_LABEL, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
mChartID = chartID;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Name to Object
|
||||
* @param name: name
|
||||
*/
|
||||
void Add(string name)
|
||||
{
|
||||
//
|
||||
// Add a new object by name to the rectangle label and track distances
|
||||
ArrayResize(mAddedNames, ArraySize(mAddedNames) + 1);
|
||||
ArrayResize(mAddedXDisDiffrence, ArraySize(mAddedXDisDiffrence) + 1);
|
||||
ArrayResize(mAddedYDisDiffrence, ArraySize(mAddedYDisDiffrence) + 1);
|
||||
|
||||
//
|
||||
mAddedNames[ArraySize(mAddedNames) - 1] = name;
|
||||
mAddedXDisDiffrence[ArraySize(mAddedXDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_XDISTANCE) - ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
mAddedYDisDiffrence[ArraySize(mAddedYDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_YDISTANCE) - ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
}
|
||||
|
||||
//
|
||||
// Handlers ...
|
||||
@@ -137,67 +198,18 @@ class XCRectangleLabel : XSCBase
|
||||
}
|
||||
|
||||
//
|
||||
// Actions ...
|
||||
|
||||
/**
|
||||
* Create an Instance of Class Object ...
|
||||
*
|
||||
* @param name: Object Name
|
||||
* @param xDis: X Distance
|
||||
* @param yDis: Y Distance
|
||||
* @param xSize: X Size
|
||||
* @param ySize: Y Size
|
||||
*/
|
||||
bool Create(
|
||||
string name,
|
||||
int xDis,
|
||||
int yDis,
|
||||
int xSize,
|
||||
int ySize //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Object creation and property settings
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
||||
|
||||
//
|
||||
mName = name;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Set Object Border Type ...
|
||||
*
|
||||
* @param borderType: Specified border type
|
||||
*/
|
||||
void SetBorderType(ENUM_BORDER_TYPE borderType)
|
||||
void BorderType(ENUM_BORDER_TYPE borderType)
|
||||
{
|
||||
//
|
||||
ObjectSetInteger(
|
||||
0,
|
||||
mChartID,
|
||||
mName,
|
||||
OBJPROP_BORDER_TYPE,
|
||||
borderType //
|
||||
@@ -209,55 +221,17 @@ class XCRectangleLabel : XSCBase
|
||||
*
|
||||
* @param value: color
|
||||
*/
|
||||
void SetBGColor(color value)
|
||||
void BGColor(color value)
|
||||
{
|
||||
//
|
||||
ObjectSetInteger(
|
||||
0,
|
||||
mChartID,
|
||||
mName,
|
||||
OBJPROP_BGCOLOR,
|
||||
value //
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ZOrder ...
|
||||
*
|
||||
* @param value: z order
|
||||
*/
|
||||
void SetZOrder(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object as Background ...
|
||||
*
|
||||
* @param value: boolean value
|
||||
*/
|
||||
void SetAsBackGround(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Name to Object
|
||||
* @param name: name
|
||||
*/
|
||||
void Add(string name)
|
||||
{
|
||||
//
|
||||
// Add a new object by name to the rectangle label and track distances
|
||||
ArrayResize(mAddedNames, ArraySize(mAddedNames) + 1);
|
||||
ArrayResize(mAddedXDisDiffrence, ArraySize(mAddedXDisDiffrence) + 1);
|
||||
ArrayResize(mAddedYDisDiffrence, ArraySize(mAddedYDisDiffrence) + 1);
|
||||
|
||||
//
|
||||
mAddedNames[ArraySize(mAddedNames) - 1] = name;
|
||||
mAddedXDisDiffrence[ArraySize(mAddedXDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_XDISTANCE) - ObjectGetInteger(0, name, OBJPROP_XDISTANCE);
|
||||
mAddedYDisDiffrence[ArraySize(mAddedYDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_YDISTANCE) - ObjectGetInteger(0, name, OBJPROP_YDISTANCE);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
@@ -267,9 +241,6 @@ class XCRectangleLabel : XSCBase
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mName; // Name of Object
|
||||
|
||||
//
|
||||
// Mouse state tracking variables ...
|
||||
int mlbDownX;
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XCObject
|
||||
// Description: Base Class Of Chart Object Class
|
||||
//
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Implementation ...
|
||||
|
||||
//
|
||||
// a Button Creation Class ...
|
||||
class XCObject : XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor(s) ...
|
||||
void XCObject()
|
||||
{
|
||||
mChartID = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XCObject()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Class Instance ...
|
||||
*/
|
||||
void Destroy()
|
||||
{
|
||||
//
|
||||
mName = NULL;
|
||||
ObjectDelete(0, mName);
|
||||
}
|
||||
|
||||
//
|
||||
// Getter(s) / Setter(s) ...
|
||||
|
||||
/**
|
||||
* Retrieve Object Name ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string Name()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Registered Chart ID ...
|
||||
*
|
||||
* @return ( long )
|
||||
*/
|
||||
long ChartID()
|
||||
{
|
||||
return mChartID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object ZOrder ...
|
||||
*
|
||||
* @param value: z order
|
||||
*/
|
||||
void ZOrder(int value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_ZORDER, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Object as Background ...
|
||||
*
|
||||
* @param value: boolean value
|
||||
*/
|
||||
void AsBackGround(bool value)
|
||||
{
|
||||
ObjectSetInteger(0, mName, OBJPROP_BACK, value);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
string mName; // Name of Object ...
|
||||
long mChartID; // Chart ID ...
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
};
|
||||
+688
-84
@@ -93,7 +93,7 @@ input int eaDelayBarBetweenTwoSameSignal = 5; // Delay Bars Between Two Same Typ
|
||||
//
|
||||
// Protector > Hedging Properties ...
|
||||
input group "Hedging";
|
||||
input bool eaAllowHedge = true; // Allow Protector to Hedge Positions
|
||||
input bool eaAllowHedge = true; // Allow Hedge Positions
|
||||
input double eaHedgeMinVolumeStep = 0.01; // Minimum Volume Step For Hedge
|
||||
input int eaMinimumOpenPositionsForHEHedge = 2; // Minimum Open Positions For HE Hedge
|
||||
input double eaHedgeHEMinProfitPerVolumeStep = 1; // Minimum Required Profit For HE Hedge Per Volume Step
|
||||
@@ -144,11 +144,11 @@ input group "In Drawdown Positions Protecting";
|
||||
// Protect ...
|
||||
input group "Protect";
|
||||
input bool eaAllowProtect = true; // Allow Proptecting
|
||||
input int eaProtectionDelay = 60; // Delay Between two Protection in Secconds
|
||||
input int eaProtectionDelay = 300; // Delay Between two Protection in Secconds
|
||||
input bool eaProtectOnConditions = true; // Do Protection only when Conditions happens
|
||||
input bool eaAllowDirectionProtct = false; // Allow also Directional Protect
|
||||
input double eaProtectionStartDistance = 50; // Protection Start Drawdown in Profit
|
||||
input double eaProtectionVolumeMultiplier = 2; // Protection Volume Multiplier
|
||||
input double eaProtectionStartDistance = 100; // Protection Start Drawdown in Profit
|
||||
input double eaProtectionVolumeMultiplier = 1; // Protection Volume Multiplier
|
||||
|
||||
//
|
||||
// Partial Close (In Drawdown) ...
|
||||
@@ -203,14 +203,6 @@ XTimeTracker eaTimeTracker;
|
||||
// Trade Handler Instance Class ...
|
||||
X121SCTradeHandler *eaTradeHandler;
|
||||
|
||||
//
|
||||
// Panel of EA ...
|
||||
XCPanel eaPanel;
|
||||
XCButton eaStateButton;
|
||||
string eaStateButtonTitle;
|
||||
bool eaEnableLongs = true;
|
||||
bool eaEnableShorts = true;
|
||||
|
||||
//
|
||||
string mTag = "";
|
||||
|
||||
@@ -219,6 +211,25 @@ double eaR2R = 1.5;
|
||||
datetime lastSignalOn = NULL;
|
||||
bool eaUseFixedTPSLPoints = true;
|
||||
|
||||
//
|
||||
// SIGNALLING GUI ...
|
||||
XCPanel eaSignallingPanel;
|
||||
XCButton eaSignallingBtn;
|
||||
XCButton eaSignallingLongBtn;
|
||||
XCButton eaSignallingShortBtn;
|
||||
bool eaEnableLongs = eaAllowLong && eaMaxAllowedLongs >= 0;
|
||||
bool eaEnableShorts = eaAllowShort && eaMaxAllowedShorts >= 0;
|
||||
|
||||
//
|
||||
// PROTECTOR GUI ...
|
||||
XCPanel eaProtectorPanel;
|
||||
XCButton eaHedgingBtn;
|
||||
XCButton eaTraillingBtn;
|
||||
XCButton eaProtectingBtn;
|
||||
bool eaEnableHedging = false;
|
||||
bool eaEnableTrailling = false;
|
||||
bool eaEnableProtecting = false;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -233,7 +244,7 @@ int OnInit()
|
||||
}
|
||||
|
||||
//
|
||||
if (!InitialEA())
|
||||
if (!InitEA())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
@@ -252,8 +263,7 @@ int OnInit()
|
||||
// EventSetMillisecondTimer(100);
|
||||
|
||||
//
|
||||
// Create Panel for EA Data ...
|
||||
if (!InitialPanel())
|
||||
if (!InitGUI())
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
@@ -300,7 +310,7 @@ void OnDeinit(const int reason)
|
||||
delete eaTradeHandler;
|
||||
|
||||
//
|
||||
eaPanel.Destroy();
|
||||
DestroyGUI();
|
||||
|
||||
//
|
||||
Clean(strategies);
|
||||
@@ -311,9 +321,9 @@ void OnDeinit(const int reason)
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
UpdateGUI();
|
||||
HandleTradeState();
|
||||
HandleTimeReport();
|
||||
HandlePanelUpdate();
|
||||
HandleStrategiesOnTick();
|
||||
}
|
||||
|
||||
@@ -344,12 +354,16 @@ void OnChartEvent(
|
||||
)
|
||||
{
|
||||
//
|
||||
eaPanel.OnEvent(
|
||||
id,
|
||||
lparam,
|
||||
dparam,
|
||||
sparam //
|
||||
);
|
||||
// Handle Panel Removing ...
|
||||
eaProtectorPanel.OnEvent(id, lparam, dparam, sparam);
|
||||
eaSignallingPanel.OnEvent(id, lparam, dparam, sparam);
|
||||
|
||||
//
|
||||
// Handle OnClick Event ...
|
||||
if (id == CHARTEVENT_OBJECT_CLICK)
|
||||
{
|
||||
HandleOnClickEvent(sparam);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -468,45 +482,9 @@ bool ValidateInputs()
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool InitialPanel()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Create a Panel ...
|
||||
result = eaPanel.Create(
|
||||
mTag,
|
||||
100,
|
||||
100,
|
||||
300,
|
||||
200 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Create Activation Button ...
|
||||
string eaStatePrefix = mTag + "_State_";
|
||||
eaStateButtonTitle = eaStatePrefix + "lbl";
|
||||
result = eaStateButton.Create(
|
||||
eaStateButtonTitle,
|
||||
100,
|
||||
120,
|
||||
100,
|
||||
25 //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize all Requirements ...
|
||||
bool InitialEA()
|
||||
bool InitEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
@@ -875,25 +853,53 @@ bool InitialEA()
|
||||
}
|
||||
|
||||
//
|
||||
// Register Strategy ...
|
||||
void RegisterStrategy(XSCBaseStrategy *strategy)
|
||||
// Initial GUI ...
|
||||
bool InitGUI()
|
||||
{
|
||||
//
|
||||
if (strategy == NULL)
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initial Signalling GUI ...
|
||||
result = InitSignallingGUI();
|
||||
if (!result)
|
||||
{
|
||||
return;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ArrayResize(
|
||||
strategies,
|
||||
ArraySize(strategies) + 1 //
|
||||
);
|
||||
// Initial Protector GUI ...
|
||||
result = InitProtectorGUI();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
strategies[ArraySize(strategies) - 1] = strategy;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Update GUi ...
|
||||
void UpdateGUI()
|
||||
{
|
||||
//
|
||||
UpdateProtectorGUI();
|
||||
UpdateSignallingGUI();
|
||||
}
|
||||
|
||||
//
|
||||
// Destroy GUI ...
|
||||
void DestroyGUI()
|
||||
{
|
||||
//
|
||||
DestroyProtectorGUI();
|
||||
DestroySignallingGUI();
|
||||
}
|
||||
|
||||
//
|
||||
// HANDLERS ...
|
||||
|
||||
//
|
||||
// Call All Registered Strategis Tick Handler Functions ...
|
||||
void HandleStrategiesOnTick()
|
||||
@@ -981,21 +987,97 @@ void HandleTimeReport()
|
||||
}
|
||||
|
||||
//
|
||||
// Update Panel ...
|
||||
void HandlePanelUpdate()
|
||||
// Report Account Balance ...
|
||||
void HandleReportBalance()
|
||||
{
|
||||
//
|
||||
// Prepare State ...
|
||||
bool isEnable = eaEnableLongs ||
|
||||
eaEnableShorts;
|
||||
if (!IsRunningOnTestMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
string stateStr = isEnable ? "Active" : "Inactive";
|
||||
string msg = "Balance: " + ToString(eaTrader.mAccount.GetBalance());
|
||||
eaAlert.Log(msg);
|
||||
}
|
||||
|
||||
//
|
||||
// Handle On Click Event for GUI Components ...
|
||||
void HandleOnClickEvent(string name)
|
||||
{
|
||||
//
|
||||
if (!IsValid(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isClicked = false;
|
||||
|
||||
//
|
||||
// Signalling State Button ...
|
||||
if (name == eaSignallingBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeState();
|
||||
eaSignallingBtn.State(false);
|
||||
}
|
||||
//
|
||||
// Long Signalling State ...
|
||||
else if (name == eaSignallingLongBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeLongsState();
|
||||
eaSignallingLongBtn.State(false);
|
||||
}
|
||||
//
|
||||
// Short Signalling State ...
|
||||
else if (name == eaSignallingShortBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeShortsState();
|
||||
eaSignallingShortBtn.State(false);
|
||||
}
|
||||
//
|
||||
// Hedging State Button ...
|
||||
else if (name == eaHedgingBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeHedgingState();
|
||||
eaHedgingBtn.State(false);
|
||||
}
|
||||
//
|
||||
// Trailling State Button ...
|
||||
else if (name == eaTraillingBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeTraillingState();
|
||||
eaTraillingBtn.State(false);
|
||||
}
|
||||
//
|
||||
// Protecting State Button ...
|
||||
else if (name == eaProtectingBtn.Name())
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeProtectingState();
|
||||
eaProtectingBtn.State(false);
|
||||
}
|
||||
|
||||
//
|
||||
if (isClicked)
|
||||
{
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SIGNAL EVENT Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// All Signals from Strategies Comming Here for Execution or
|
||||
@@ -1167,7 +1249,7 @@ void OnStopLossTriggered(const XDeal &deal)
|
||||
eaTradeHandler.Finish(deal);
|
||||
|
||||
//
|
||||
ReportBalance();
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1179,7 +1261,7 @@ void OnTakeProfitTriggered(const XDeal &deal)
|
||||
eaTradeHandler.Finish(deal);
|
||||
|
||||
//
|
||||
ReportBalance();
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1199,22 +1281,544 @@ void OnPositionForceClosed(
|
||||
);
|
||||
|
||||
//
|
||||
ReportBalance();
|
||||
HandleReportBalance();
|
||||
}
|
||||
|
||||
//
|
||||
// Report Account Balance ...
|
||||
void ReportBalance()
|
||||
// HELPERS ...
|
||||
|
||||
//
|
||||
// Register Strategy ...
|
||||
void RegisterStrategy(XSCBaseStrategy *strategy)
|
||||
{
|
||||
//
|
||||
if (!IsRunningOnTestMode())
|
||||
if (strategy == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
string msg = "Balance: " + ToString(eaTrader.mAccount.GetBalance());
|
||||
eaAlert.Log(msg);
|
||||
ArrayResize(
|
||||
strategies,
|
||||
ArraySize(strategies) + 1 //
|
||||
);
|
||||
|
||||
//
|
||||
strategies[ArraySize(strategies) - 1] = strategy;
|
||||
}
|
||||
|
||||
//
|
||||
// GUI Parts ...
|
||||
|
||||
//
|
||||
// SIGNALLING GUI ...
|
||||
|
||||
/**
|
||||
* Initialize State and Signalling GUI ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool InitSignallingGUI()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string eaSignallingPanelName = mTag + "SIGNALLING";
|
||||
|
||||
//
|
||||
// Create a Panel ...
|
||||
result = eaSignallingPanel.Create(
|
||||
eaSignallingPanelName,
|
||||
10,
|
||||
40,
|
||||
300,
|
||||
50 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaSignallingPanel.Caption("Signalling");
|
||||
|
||||
//
|
||||
// Create Activation Button ...
|
||||
string eaSignallingPrefix = eaSignallingPanelName + "_";
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
string eaSignallingBtnName = eaSignallingPrefix + "btn";
|
||||
result = eaSignallingBtn.Create(
|
||||
eaSignallingBtnName,
|
||||
10,
|
||||
60,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaSignallingBtn.Text("");
|
||||
eaSignallingPanel.Add(eaSignallingBtnName);
|
||||
|
||||
//
|
||||
// Long Signalling ...
|
||||
string eaSignallingLongBtnName = eaSignallingPrefix + "_Long_btn";
|
||||
result = eaSignallingLongBtn.Create(
|
||||
eaSignallingLongBtnName,
|
||||
10,
|
||||
85,
|
||||
150,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaSignallingLongBtn.Text("");
|
||||
eaSignallingPanel.Add(eaSignallingLongBtnName);
|
||||
|
||||
//
|
||||
// Short Signalling ...
|
||||
string eaSignallingShortBtnName = eaSignallingPrefix + "_Short_btn";
|
||||
result = eaSignallingShortBtn.Create(
|
||||
eaSignallingShortBtnName,
|
||||
160,
|
||||
85,
|
||||
150,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaSignallingShortBtn.Text("");
|
||||
eaSignallingPanel.Add(eaSignallingShortBtnName);
|
||||
|
||||
//
|
||||
UpdateSignallingGUI();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Signalling GUI Content ...
|
||||
*/
|
||||
void UpdateSignallingGUI()
|
||||
{
|
||||
//
|
||||
// Preparing State ...
|
||||
bool isSignallingActive = eaEnableLongs ||
|
||||
eaEnableShorts;
|
||||
|
||||
//
|
||||
// All Signalls ...
|
||||
color mSignallingBtnTextColor = isSignallingActive
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string mSignallingBtnText = isSignallingActive
|
||||
? "Deactive"
|
||||
: "Active";
|
||||
eaSignallingBtn.Text(mSignallingBtnText);
|
||||
eaSignallingBtn.Color(mSignallingBtnTextColor);
|
||||
|
||||
//
|
||||
// Long Signals ...
|
||||
color mSignallingLongBtnTextColor = eaEnableLongs
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string mSignallingLongBtnText = eaEnableLongs
|
||||
? "Deactive Longs"
|
||||
: "Active Longs";
|
||||
eaSignallingLongBtn.Text(mSignallingLongBtnText);
|
||||
eaSignallingLongBtn.Color(mSignallingLongBtnTextColor);
|
||||
|
||||
//
|
||||
// Short Signals ...
|
||||
color mSignallingShortBtnTextColor = eaEnableShorts
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string mSignallingShortBtnText = eaEnableShorts
|
||||
? "Deactive Shorts"
|
||||
: "Active Shorts";
|
||||
eaSignallingShortBtn.Text(mSignallingShortBtnText);
|
||||
eaSignallingShortBtn.Color(mSignallingShortBtnTextColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Signalling GUI ...
|
||||
*/
|
||||
void DestroySignallingGUI()
|
||||
{
|
||||
//
|
||||
eaSignallingPanel.Destroy();
|
||||
eaSignallingBtn.Destroy();
|
||||
eaSignallingLongBtn.Destroy();
|
||||
eaSignallingShortBtn.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Signalling State ...
|
||||
*/
|
||||
void HandleChangeState()
|
||||
{
|
||||
//
|
||||
// Preparing State ...
|
||||
bool isSignallingActive = eaEnableLongs ||
|
||||
eaEnableShorts;
|
||||
|
||||
//
|
||||
if (isSignallingActive)
|
||||
{
|
||||
//
|
||||
eaEnableLongs = false;
|
||||
eaEnableShorts = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
eaEnableLongs = true;
|
||||
eaEnableShorts = true;
|
||||
}
|
||||
|
||||
//
|
||||
UpdateSignallingOnTradeHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Longs Signalling ...
|
||||
*/
|
||||
void HandleChangeLongsState()
|
||||
{
|
||||
//
|
||||
eaEnableLongs = !eaEnableLongs;
|
||||
|
||||
//
|
||||
UpdateSignallingOnTradeHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Shorts Signalling ...
|
||||
*/
|
||||
void HandleChangeShortsState()
|
||||
{
|
||||
//
|
||||
eaEnableShorts = !eaEnableShorts;
|
||||
|
||||
//
|
||||
UpdateSignallingOnTradeHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Signalling Features on Trade Handler ...
|
||||
*/
|
||||
void UpdateSignallingOnTradeHandler()
|
||||
{
|
||||
//
|
||||
eaTradeHandler.AllowLong(eaEnableLongs);
|
||||
eaTradeHandler.AllowShort(eaEnableShorts);
|
||||
|
||||
//
|
||||
UpdateSignallingGUI();
|
||||
}
|
||||
|
||||
//
|
||||
// PROTECTOR GUI ...
|
||||
|
||||
/**
|
||||
* Initial Protector GUI ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool InitProtectorGUI()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string eaProtectorPanelName = mTag + "PROTECTOR";
|
||||
|
||||
//
|
||||
// Create a Panel ...
|
||||
result = eaProtectorPanel.Create(
|
||||
eaProtectorPanelName,
|
||||
10,
|
||||
110,
|
||||
300,
|
||||
100 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaProtectorPanel.Caption("Protector");
|
||||
|
||||
//
|
||||
string eaProtectorPrefix = eaProtectorPanelName + "_";
|
||||
|
||||
//
|
||||
// Hedging ...
|
||||
string eaHedgingBtnName = eaProtectorPrefix + "HEDGING_btn";
|
||||
result = eaHedgingBtn.Create(
|
||||
eaHedgingBtnName,
|
||||
10,
|
||||
130,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaHedgingBtn.Text("");
|
||||
eaProtectorPanel.Add(eaHedgingBtnName);
|
||||
|
||||
//
|
||||
// Trailling ...
|
||||
string eaTraillingBtnName = eaProtectorPrefix + "TRAILLING_btn";
|
||||
result = eaTraillingBtn.Create(
|
||||
eaTraillingBtnName,
|
||||
10,
|
||||
155,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaTraillingBtn.Text("");
|
||||
eaProtectorPanel.Add(eaTraillingBtnName);
|
||||
|
||||
//
|
||||
// Protecting ...
|
||||
string eaProtectingBtnName = eaProtectorPrefix + "FREEZING_btn";
|
||||
result = eaProtectingBtn.Create(
|
||||
eaProtectingBtnName,
|
||||
10,
|
||||
180,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaProtectingBtn.Text("");
|
||||
eaProtectorPanel.Add(eaProtectingBtnName);
|
||||
|
||||
//
|
||||
UpdateProtectorGUI();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Protector GUI ...
|
||||
*/
|
||||
void UpdateProtectorGUI()
|
||||
{
|
||||
//
|
||||
// Hedging ...
|
||||
|
||||
//
|
||||
// Checking Hedging Props ...
|
||||
bool isHedgingActiveProps =
|
||||
eaHedgeMinVolumeStep > 0 &&
|
||||
((eaMinimumOpenPositionsForHEHedge > 0 &&
|
||||
eaHedgeHEMinProfitPerVolumeStep > 0) ||
|
||||
eaHedgeBEMinProfitPerVolumeStep);
|
||||
|
||||
//
|
||||
// Check Hedging State ...
|
||||
bool isHedgingActived = eaAllowHedge &&
|
||||
isHedgingActiveProps;
|
||||
eaEnableHedging = isHedgingActived;
|
||||
|
||||
//
|
||||
color eaHedgingBtnTextColor =
|
||||
!isHedgingActiveProps
|
||||
? clrGray
|
||||
: isHedgingActived
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaHedgingBtnText =
|
||||
!isHedgingActiveProps
|
||||
? "Hedging Disabled"
|
||||
: isHedgingActived
|
||||
? "Deactive Hedging"
|
||||
: "Active Hedging";
|
||||
eaHedgingBtn.Text(eaHedgingBtnText);
|
||||
eaHedgingBtn.Color(eaHedgingBtnTextColor);
|
||||
|
||||
//
|
||||
// Trailling ...
|
||||
|
||||
//
|
||||
// Checking Trailling Props ...
|
||||
bool isTraillingActiveProps =
|
||||
eaTrailStep > 0 &&
|
||||
eaTrailStartDistance > 0 &&
|
||||
eaTrailStep < eaTrailStartDistance;
|
||||
|
||||
//
|
||||
// Check Trailling State ...
|
||||
bool isTraillingActived =
|
||||
eaAllowTrail &&
|
||||
isTraillingActiveProps;
|
||||
eaEnableTrailling = isTraillingActived;
|
||||
|
||||
//
|
||||
color eaTraillingBtnTextColor =
|
||||
!isTraillingActiveProps
|
||||
? clrGray
|
||||
: isTraillingActived
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaTraillingBtnText =
|
||||
!isTraillingActiveProps
|
||||
? "Trailling Disabled"
|
||||
: isTraillingActived
|
||||
? "Deactive Trailling"
|
||||
: "Active Trailling";
|
||||
eaTraillingBtn.Text(eaTraillingBtnText);
|
||||
eaTraillingBtn.Color(eaTraillingBtnTextColor);
|
||||
|
||||
//
|
||||
// Protecting ...
|
||||
|
||||
//
|
||||
// Checking Protection Props ...
|
||||
bool isProtectingActiveProps =
|
||||
eaProtectionDelay >= 0 &&
|
||||
eaProtectionStartDistance > 0 &&
|
||||
eaProtectionVolumeMultiplier > 0;
|
||||
|
||||
//
|
||||
// Check Protection State ...
|
||||
bool isProtectingActived =
|
||||
eaAllowProtect &&
|
||||
isProtectingActiveProps;
|
||||
eaEnableProtecting = isProtectingActived;
|
||||
|
||||
//
|
||||
color eaProtectingBtnTextColor =
|
||||
!isProtectingActiveProps
|
||||
? clrGray
|
||||
: isProtectingActived
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaProtectingBtnText =
|
||||
!isProtectingActiveProps
|
||||
? "Protecting Disabled"
|
||||
: isProtectingActived
|
||||
? "Deactive Protecting"
|
||||
: "Active Protecting";
|
||||
eaProtectingBtn.Text(eaProtectingBtnText);
|
||||
eaProtectingBtn.Color(eaProtectingBtnTextColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Protector GUI ...
|
||||
*/
|
||||
void DestroyProtectorGUI()
|
||||
{
|
||||
//
|
||||
eaHedgingBtn.Destroy();
|
||||
eaTraillingBtn.Destroy();
|
||||
eaProtectingBtn.Destroy();
|
||||
eaProtectorPanel.Destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Hedging State ...
|
||||
*/
|
||||
void HandleChangeHedgingState()
|
||||
{
|
||||
//
|
||||
// Checking Hedging Props ...
|
||||
bool isHedgingActiveProps =
|
||||
eaHedgeMinVolumeStep > 0 &&
|
||||
((eaMinimumOpenPositionsForHEHedge > 0 &&
|
||||
eaHedgeHEMinProfitPerVolumeStep > 0) ||
|
||||
eaHedgeBEMinProfitPerVolumeStep);
|
||||
|
||||
//
|
||||
if (!isHedgingActiveProps)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
eaEnableHedging = !eaEnableHedging;
|
||||
|
||||
//
|
||||
UpdateProtectingOnTradeHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Trailling State ...
|
||||
*/
|
||||
void HandleChangeTraillingState()
|
||||
{
|
||||
//
|
||||
// Checking Trailling Props ...
|
||||
bool isTraillingActiveProps =
|
||||
eaTrailStep > 0 &&
|
||||
eaTrailStartDistance > 0 &&
|
||||
eaTrailStep < eaTrailStartDistance;
|
||||
|
||||
//
|
||||
if (!isTraillingActiveProps)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
eaEnableTrailling = !eaEnableTrailling;
|
||||
|
||||
//
|
||||
UpdateProtectingOnTradeHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Protecting State ...
|
||||
*/
|
||||
void HandleChangeProtectingState()
|
||||
{
|
||||
|
||||
//
|
||||
// Checking Protection Props ...
|
||||
bool isProtectingActiveProps =
|
||||
eaProtectionDelay >= 0 &&
|
||||
eaProtectionStartDistance > 0 &&
|
||||
eaProtectionVolumeMultiplier > 0;
|
||||
|
||||
//
|
||||
if (!isProtectingActiveProps)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
eaEnableProtecting = !eaEnableProtecting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Protecting Features on Trade Handler ...
|
||||
*/
|
||||
void UpdateProtectingOnTradeHandler()
|
||||
{
|
||||
//
|
||||
eaTradeHandler.AllowHedge(eaEnableHedging);
|
||||
eaTradeHandler.AllowTrail(eaEnableTrailling);
|
||||
eaTradeHandler.AllowProtect(eaEnableProtecting);
|
||||
|
||||
//
|
||||
UpdateProtectorGUI();
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user