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
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "../x-saherelm.base.class.mq5"
|
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// a Button Creation Class ...
|
// a Button Creation Class ...
|
||||||
class XCButton : XSCBase
|
class XCButton : public XCObject
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Public ...
|
// Public ...
|
||||||
@@ -64,7 +64,8 @@ class XCButton : XSCBase
|
|||||||
int xDis,
|
int xDis,
|
||||||
int yDis,
|
int yDis,
|
||||||
int xSize,
|
int xSize,
|
||||||
int ySize //
|
int ySize,
|
||||||
|
long chartID = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -72,33 +73,26 @@ class XCButton : XSCBase
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ObjectCreate(0, name, OBJ_BUTTON, 0, 0, 0);
|
result = ObjectCreate(chartID, name, OBJ_BUTTON, 0, 0, 0);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
|
||||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
|
||||||
|
|
||||||
//
|
//
|
||||||
mName = name;
|
mName = name;
|
||||||
|
mChartID = chartID;
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy Class Instance ...
|
|
||||||
*/
|
|
||||||
void Destroy()
|
|
||||||
{
|
|
||||||
ObjectDelete(0, mName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getter(s) / Setter(s) ...
|
// Getter(s) / Setter(s) ...
|
||||||
|
|
||||||
@@ -107,9 +101,9 @@ class XCButton : XSCBase
|
|||||||
*
|
*
|
||||||
* @param value: color
|
* @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
|
* @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
|
* @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
|
* @param value: text
|
||||||
*/
|
*/
|
||||||
void SetText(string value)
|
void Text(string value)
|
||||||
{
|
{
|
||||||
ObjectSetString(0, mName, OBJPROP_TEXT, value);
|
ObjectSetString(mChartID, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,9 +141,9 @@ class XCButton : XSCBase
|
|||||||
*
|
*
|
||||||
* @param value: state
|
* @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 ...
|
||||||
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
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "../x-saherelm.base.class.mq5"
|
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// a Label Creation Class ...
|
// a Label Creation Class ...
|
||||||
class XCEdit : XSCBase
|
class XCEdit : public XCObject
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Public ...
|
// Public ...
|
||||||
@@ -64,7 +64,8 @@ class XCEdit : XSCBase
|
|||||||
int xDis,
|
int xDis,
|
||||||
int yDis,
|
int yDis,
|
||||||
int xSize,
|
int xSize,
|
||||||
int ySize //
|
int ySize,
|
||||||
|
long chartID = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -72,33 +73,26 @@ class XCEdit : XSCBase
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ObjectCreate(0, name, OBJ_EDIT, 0, 0, 0);
|
result = ObjectCreate(chartID, name, OBJ_EDIT, 0, 0, 0);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||||
ObjectSetInteger(0, name, OBJPROP_XSIZE, xSize);
|
ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize);
|
||||||
ObjectSetInteger(0, name, OBJPROP_YSIZE, ySize);
|
ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize);
|
||||||
|
|
||||||
//
|
//
|
||||||
mName = name;
|
mName = name;
|
||||||
|
mChartID = chartID;
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy Class Instance ...
|
|
||||||
*/
|
|
||||||
void Destroy()
|
|
||||||
{
|
|
||||||
ObjectDelete(0, mName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getter(s) / Setter(s) ...
|
// Getter(s) / Setter(s) ...
|
||||||
|
|
||||||
@@ -107,9 +101,9 @@ class XCEdit : XSCBase
|
|||||||
*
|
*
|
||||||
* @param value: color
|
* @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
|
* @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
|
* @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
|
* @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 )
|
* @return ( string )
|
||||||
*/
|
*/
|
||||||
string GetText()
|
string Text()
|
||||||
{
|
{
|
||||||
return ObjectGetString(0, mName, OBJPROP_TEXT);
|
return ObjectGetString(mChartID, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -179,24 +153,4 @@ class XCEdit : XSCBase
|
|||||||
// Private ...
|
// Private ...
|
||||||
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
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "../x-saherelm.base.class.mq5"
|
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// a Label Creation Class ...
|
// a Label Creation Class ...
|
||||||
class XCLabel : XSCBase
|
class XCLabel : public XCObject
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Public ...
|
// Public ...
|
||||||
@@ -60,7 +60,8 @@ class XCLabel : XSCBase
|
|||||||
bool Create(
|
bool Create(
|
||||||
string name,
|
string name,
|
||||||
int xDis,
|
int xDis,
|
||||||
int yDis //
|
int yDis,
|
||||||
|
long chartID = 0 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -68,31 +69,24 @@ class XCLabel : XSCBase
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ObjectCreate(0, name, OBJ_LABEL, 0, 0, 0);
|
result = ObjectCreate(chartID, name, OBJ_LABEL, 0, 0, 0);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, xDis);
|
ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis);
|
||||||
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, yDis);
|
ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis);
|
||||||
|
|
||||||
//
|
//
|
||||||
mName = name;
|
mName = name;
|
||||||
|
mChartID = chartID;
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy Class Instance ...
|
|
||||||
*/
|
|
||||||
void Destroy()
|
|
||||||
{
|
|
||||||
ObjectDelete(0, mName);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Getter(s) / Setter(s) ...
|
// Getter(s) / Setter(s) ...
|
||||||
|
|
||||||
@@ -101,9 +95,9 @@ class XCLabel : XSCBase
|
|||||||
*
|
*
|
||||||
* @param value: color
|
* @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
|
* @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 )
|
* @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
|
* @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
|
* @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
|
* @param value: anchor
|
||||||
*/
|
*/
|
||||||
void SetAnchor(ENUM_ANCHOR_POINT value)
|
void Anchor(ENUM_ANCHOR_POINT value)
|
||||||
{
|
{
|
||||||
ObjectSetInteger(0, mName, OBJPROP_ANCHOR, value);
|
ObjectSetInteger(mChartID, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -183,24 +157,4 @@ class XCLabel : XSCBase
|
|||||||
// Private ...
|
// Private ...
|
||||||
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 ...
|
// Implementation ...
|
||||||
|
|
||||||
//
|
//
|
||||||
class XCPanel : XSCBase
|
class XCPanel : XCObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//
|
//
|
||||||
// Constructor(s) ...
|
// Constructor(s) ...
|
||||||
void XCPanel()
|
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 xSize,
|
||||||
int ySize,
|
int ySize,
|
||||||
//
|
//
|
||||||
|
long chartID = 0,
|
||||||
|
//
|
||||||
// Title Bar ...
|
// Title Bar ...
|
||||||
ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT,
|
ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT,
|
||||||
color titleBarBGColor = clrBlueViolet,
|
color titleBarBGColor = clrBlueViolet,
|
||||||
@@ -96,6 +95,10 @@ class XCPanel : XSCBase
|
|||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enables mouse move events on the chart
|
||||||
|
ChartSetInteger(chartID, CHART_EVENT_MOUSE_MOVE, true);
|
||||||
|
|
||||||
//
|
//
|
||||||
result = IsValid(name);
|
result = IsValid(name);
|
||||||
if (!result)
|
if (!result)
|
||||||
@@ -132,8 +135,8 @@ class XCPanel : XSCBase
|
|||||||
Destroy();
|
Destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
mTitleBar.SetBorderType(titleBarBorderType);
|
mTitleBar.BorderType(titleBarBorderType);
|
||||||
mTitleBar.SetBGColor(titleBarBGColor);
|
mTitleBar.BGColor(titleBarBGColor);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Body ...
|
// Body ...
|
||||||
@@ -150,9 +153,9 @@ class XCPanel : XSCBase
|
|||||||
Destroy();
|
Destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
mBody.SetBorderType(bodyBorderType);
|
mBody.BorderType(bodyBorderType);
|
||||||
mBody.SetBGColor(bodyBGColor);
|
mBody.BGColor(bodyBGColor);
|
||||||
mBody.SetAsBackGround(true);
|
mBody.AsBackGround(true);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Caption ...
|
// Caption ...
|
||||||
@@ -163,10 +166,10 @@ class XCPanel : XSCBase
|
|||||||
Destroy();
|
Destroy();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
mCaptionLbl.SetText(caption);
|
mCaptionLbl.Text(caption);
|
||||||
mCaptionLbl.SetAnchor(captionAnchor);
|
mCaptionLbl.Color(captionColor);
|
||||||
mCaptionLbl.SetTextColor(captionColor);
|
mCaptionLbl.Anchor(captionAnchor);
|
||||||
mCaptionLbl.SetFontSize(captionontSize);
|
mCaptionLbl.FontSize(captionontSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Adding Child Objects ...
|
// Adding Child Objects ...
|
||||||
@@ -233,7 +236,7 @@ class XCPanel : XSCBase
|
|||||||
*/
|
*/
|
||||||
string Caption()
|
string Caption()
|
||||||
{
|
{
|
||||||
return mCaptionLbl.GetText();
|
return mCaptionLbl.Text();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,7 +246,37 @@ class XCPanel : XSCBase
|
|||||||
*/
|
*/
|
||||||
void Caption(string value)
|
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
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
#include "../x-saherelm.base.class.mq5"
|
#include "../XCObjects/x-saherelm.xcobject.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// a Rectangle Label Creation Class ...
|
// a Rectangle Label Creation Class ...
|
||||||
class XCRectangleLabel : XSCBase
|
class XCRectangleLabel : public XCObject
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Public ...
|
// 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 ...
|
// Handlers ...
|
||||||
@@ -137,67 +198,18 @@ class XCRectangleLabel : XSCBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Actions ...
|
// Getter(s) / Setter(s) ...
|
||||||
|
|
||||||
/**
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Object Border Type ...
|
* Set Object Border Type ...
|
||||||
*
|
*
|
||||||
* @param borderType: Specified border type
|
* @param borderType: Specified border type
|
||||||
*/
|
*/
|
||||||
void SetBorderType(ENUM_BORDER_TYPE borderType)
|
void BorderType(ENUM_BORDER_TYPE borderType)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
ObjectSetInteger(
|
ObjectSetInteger(
|
||||||
0,
|
mChartID,
|
||||||
mName,
|
mName,
|
||||||
OBJPROP_BORDER_TYPE,
|
OBJPROP_BORDER_TYPE,
|
||||||
borderType //
|
borderType //
|
||||||
@@ -209,55 +221,17 @@ class XCRectangleLabel : XSCBase
|
|||||||
*
|
*
|
||||||
* @param value: color
|
* @param value: color
|
||||||
*/
|
*/
|
||||||
void SetBGColor(color value)
|
void BGColor(color value)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
ObjectSetInteger(
|
ObjectSetInteger(
|
||||||
0,
|
mChartID,
|
||||||
mName,
|
mName,
|
||||||
OBJPROP_BGCOLOR,
|
OBJPROP_BGCOLOR,
|
||||||
value //
|
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 ...
|
||||||
protected:
|
protected:
|
||||||
@@ -267,9 +241,6 @@ class XCRectangleLabel : XSCBase
|
|||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
|
|
||||||
//
|
|
||||||
string mName; // Name of Object
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Mouse state tracking variables ...
|
// Mouse state tracking variables ...
|
||||||
int mlbDownX;
|
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 ...
|
// Protector > Hedging Properties ...
|
||||||
input group "Hedging";
|
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 double eaHedgeMinVolumeStep = 0.01; // Minimum Volume Step For Hedge
|
||||||
input int eaMinimumOpenPositionsForHEHedge = 2; // Minimum Open Positions For HE Hedge
|
input int eaMinimumOpenPositionsForHEHedge = 2; // Minimum Open Positions For HE Hedge
|
||||||
input double eaHedgeHEMinProfitPerVolumeStep = 1; // Minimum Required Profit For HE Hedge Per Volume Step
|
input double eaHedgeHEMinProfitPerVolumeStep = 1; // Minimum Required Profit For HE Hedge Per Volume Step
|
||||||
@@ -144,11 +144,11 @@ input group "In Drawdown Positions Protecting";
|
|||||||
// Protect ...
|
// Protect ...
|
||||||
input group "Protect";
|
input group "Protect";
|
||||||
input bool eaAllowProtect = true; // Allow Proptecting
|
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 eaProtectOnConditions = true; // Do Protection only when Conditions happens
|
||||||
input bool eaAllowDirectionProtct = false; // Allow also Directional Protect
|
input bool eaAllowDirectionProtct = false; // Allow also Directional Protect
|
||||||
input double eaProtectionStartDistance = 50; // Protection Start Drawdown in Profit
|
input double eaProtectionStartDistance = 100; // Protection Start Drawdown in Profit
|
||||||
input double eaProtectionVolumeMultiplier = 2; // Protection Volume Multiplier
|
input double eaProtectionVolumeMultiplier = 1; // Protection Volume Multiplier
|
||||||
|
|
||||||
//
|
//
|
||||||
// Partial Close (In Drawdown) ...
|
// Partial Close (In Drawdown) ...
|
||||||
@@ -203,14 +203,6 @@ XTimeTracker eaTimeTracker;
|
|||||||
// Trade Handler Instance Class ...
|
// Trade Handler Instance Class ...
|
||||||
X121SCTradeHandler *eaTradeHandler;
|
X121SCTradeHandler *eaTradeHandler;
|
||||||
|
|
||||||
//
|
|
||||||
// Panel of EA ...
|
|
||||||
XCPanel eaPanel;
|
|
||||||
XCButton eaStateButton;
|
|
||||||
string eaStateButtonTitle;
|
|
||||||
bool eaEnableLongs = true;
|
|
||||||
bool eaEnableShorts = true;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
string mTag = "";
|
string mTag = "";
|
||||||
|
|
||||||
@@ -219,6 +211,25 @@ double eaR2R = 1.5;
|
|||||||
datetime lastSignalOn = NULL;
|
datetime lastSignalOn = NULL;
|
||||||
bool eaUseFixedTPSLPoints = true;
|
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 ...
|
// Event Handlers ...
|
||||||
|
|
||||||
@@ -233,7 +244,7 @@ int OnInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (!InitialEA())
|
if (!InitEA())
|
||||||
{
|
{
|
||||||
return INIT_FAILED;
|
return INIT_FAILED;
|
||||||
}
|
}
|
||||||
@@ -252,8 +263,7 @@ int OnInit()
|
|||||||
// EventSetMillisecondTimer(100);
|
// EventSetMillisecondTimer(100);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create Panel for EA Data ...
|
if (!InitGUI())
|
||||||
if (!InitialPanel())
|
|
||||||
{
|
{
|
||||||
return INIT_FAILED;
|
return INIT_FAILED;
|
||||||
}
|
}
|
||||||
@@ -300,7 +310,7 @@ void OnDeinit(const int reason)
|
|||||||
delete eaTradeHandler;
|
delete eaTradeHandler;
|
||||||
|
|
||||||
//
|
//
|
||||||
eaPanel.Destroy();
|
DestroyGUI();
|
||||||
|
|
||||||
//
|
//
|
||||||
Clean(strategies);
|
Clean(strategies);
|
||||||
@@ -311,9 +321,9 @@ void OnDeinit(const int reason)
|
|||||||
void OnTick()
|
void OnTick()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
UpdateGUI();
|
||||||
HandleTradeState();
|
HandleTradeState();
|
||||||
HandleTimeReport();
|
HandleTimeReport();
|
||||||
HandlePanelUpdate();
|
|
||||||
HandleStrategiesOnTick();
|
HandleStrategiesOnTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,12 +354,16 @@ void OnChartEvent(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
eaPanel.OnEvent(
|
// Handle Panel Removing ...
|
||||||
id,
|
eaProtectorPanel.OnEvent(id, lparam, dparam, sparam);
|
||||||
lparam,
|
eaSignallingPanel.OnEvent(id, lparam, dparam, sparam);
|
||||||
dparam,
|
|
||||||
sparam //
|
//
|
||||||
);
|
// Handle OnClick Event ...
|
||||||
|
if (id == CHARTEVENT_OBJECT_CLICK)
|
||||||
|
{
|
||||||
|
HandleOnClickEvent(sparam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -468,45 +482,9 @@ bool ValidateInputs()
|
|||||||
return result;
|
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 ...
|
// Initialize all Requirements ...
|
||||||
bool InitialEA()
|
bool InitEA()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -875,25 +853,53 @@ bool InitialEA()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register Strategy ...
|
// Initial GUI ...
|
||||||
void RegisterStrategy(XSCBaseStrategy *strategy)
|
bool InitGUI()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (strategy == NULL)
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initial Signalling GUI ...
|
||||||
|
result = InitSignallingGUI();
|
||||||
|
if (!result)
|
||||||
{
|
{
|
||||||
return;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ArrayResize(
|
// Initial Protector GUI ...
|
||||||
strategies,
|
result = InitProtectorGUI();
|
||||||
ArraySize(strategies) + 1 //
|
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 ...
|
// Call All Registered Strategis Tick Handler Functions ...
|
||||||
void HandleStrategiesOnTick()
|
void HandleStrategiesOnTick()
|
||||||
@@ -981,21 +987,97 @@ void HandleTimeReport()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Update Panel ...
|
// Report Account Balance ...
|
||||||
void HandlePanelUpdate()
|
void HandleReportBalance()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Prepare State ...
|
if (!IsRunningOnTestMode())
|
||||||
bool isEnable = eaEnableLongs ||
|
{
|
||||||
eaEnableShorts;
|
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 ...
|
// SIGNAL EVENT Handlers ...
|
||||||
//
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// All Signals from Strategies Comming Here for Execution or
|
// All Signals from Strategies Comming Here for Execution or
|
||||||
@@ -1167,7 +1249,7 @@ void OnStopLossTriggered(const XDeal &deal)
|
|||||||
eaTradeHandler.Finish(deal);
|
eaTradeHandler.Finish(deal);
|
||||||
|
|
||||||
//
|
//
|
||||||
ReportBalance();
|
HandleReportBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1179,7 +1261,7 @@ void OnTakeProfitTriggered(const XDeal &deal)
|
|||||||
eaTradeHandler.Finish(deal);
|
eaTradeHandler.Finish(deal);
|
||||||
|
|
||||||
//
|
//
|
||||||
ReportBalance();
|
HandleReportBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1199,22 +1281,544 @@ void OnPositionForceClosed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
ReportBalance();
|
HandleReportBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Report Account Balance ...
|
// HELPERS ...
|
||||||
void ReportBalance()
|
|
||||||
|
//
|
||||||
|
// Register Strategy ...
|
||||||
|
void RegisterStrategy(XSCBaseStrategy *strategy)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (!IsRunningOnTestMode())
|
if (strategy == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
string msg = "Balance: " + ToString(eaTrader.mAccount.GetBalance());
|
ArrayResize(
|
||||||
eaAlert.Log(msg);
|
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