last works on GUI and also Comment Freezing and Supporting Properties and Functionality ...
This commit is contained in:
@@ -16,6 +16,7 @@ CTrade trade;
|
||||
string mTag;
|
||||
|
||||
//
|
||||
// SIGNALLING GUI ...
|
||||
XCPanel eaSignallingPanel;
|
||||
string eaSignallingPanelName;
|
||||
XCButton eaSignallingBtn;
|
||||
@@ -25,10 +26,45 @@ string eaSignallingLongBtnName;
|
||||
XCButton eaSignallingShortBtn;
|
||||
string eaSignallingShortBtnName;
|
||||
|
||||
//
|
||||
// PROTECTOR GUI ...
|
||||
XCPanel eaProtectorPanel;
|
||||
string eaProtectorPanelName;
|
||||
XCButton eaHedgingBtn;
|
||||
string eaHedgingBtnName;
|
||||
XCButton eaTraillingBtn;
|
||||
string eaTraillingBtnName;
|
||||
XCButton eaFreezingBtn;
|
||||
string eaFreezingBtnName;
|
||||
XCButton eaSupportingBtn;
|
||||
string eaSupportingBtnName;
|
||||
|
||||
//
|
||||
bool eaEnableLongs = true;
|
||||
bool eaEnableShorts = true;
|
||||
|
||||
//
|
||||
bool mAllowHedge = true; // Allow Protector to Hedge Positions
|
||||
double eaHedgeMinVolumeStep = 0.01; // Minimum Volume Step For Hedge
|
||||
int eaMinimumOpenPositionsForHEHedge = 2; // Minimum Open Positions For HE Hedge
|
||||
double eaHedgeHEMinProfitPerVolumeStep = 1; // Minimum Required Profit For HE Hedge Per Volume Step
|
||||
double eaHedgeBEMinProfitPerVolumeStep = 0.5; // Minimum Required Profit For BE Hedge Per Volume Step
|
||||
|
||||
//
|
||||
bool mAllowTrail = true; // Allow Trail Stop for Positions
|
||||
double eaTrailStartDistance = 35; // Specify Trail Start in Point
|
||||
double eaTrailStep = 10; // Trail Step in Point
|
||||
|
||||
//
|
||||
bool mllowFreeze = false; // Allow Freezing
|
||||
double eaFreezeVolumeMultiplier = 3; // Specify Freeze Volume Multiplier
|
||||
double eaFreezeDistance = 100; // Specify Freeze Start Drawdown in Point
|
||||
|
||||
//
|
||||
bool mAllowSupport = false; // Allow Support
|
||||
double eaSupportStartDistance = 0; // Specify Start Support Drawdown in Point
|
||||
double eaSupportVolumeMultiplier = 1; // Specify Support Volume Multiplier
|
||||
|
||||
//+------------------------------------------------------------------+
|
||||
//| Expert initialization function |
|
||||
//+------------------------------------------------------------------+
|
||||
@@ -69,6 +105,7 @@ void OnChartEvent(const int id, const long &lparam, const double &dparam, const
|
||||
{
|
||||
//
|
||||
// Handle Object Movement ...
|
||||
eaProtectorPanel.OnEvent(id, lparam, dparam, sparam);
|
||||
eaSignallingPanel.OnEvent(id, lparam, dparam, sparam);
|
||||
|
||||
//
|
||||
@@ -97,6 +134,13 @@ bool InitialGUI()
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = InitialProtectorGUI();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ChartRedraw(0);
|
||||
|
||||
@@ -111,8 +155,116 @@ void UpdateGUI()
|
||||
{
|
||||
//
|
||||
UpdateSignallingGUI();
|
||||
UpdateProtectorGUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy GUI ...
|
||||
*/
|
||||
void DestroyGUI()
|
||||
{
|
||||
//
|
||||
DestroySignallingGUI();
|
||||
DestroyProtectorGUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Object's Click Events ...
|
||||
*
|
||||
* @param name: Clicked Object Name
|
||||
*/
|
||||
void HandleOnClickEvent(string name)
|
||||
{
|
||||
//
|
||||
if (!IsValid(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isClicked = false;
|
||||
|
||||
//
|
||||
// Signalling State Button ...
|
||||
if (name == eaSignallingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeState();
|
||||
eaSignallingBtn.SetState(false);
|
||||
Print("State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Long Signalling State ...
|
||||
else if (name == eaSignallingLongBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeLongsState();
|
||||
eaSignallingLongBtn.SetState(false);
|
||||
Print("Long State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Short Signalling State ...
|
||||
else if (name == eaSignallingShortBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeShortsState();
|
||||
eaSignallingShortBtn.SetState(false);
|
||||
Print("Short State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Hedging State Button ...
|
||||
else if (name == eaHedgingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeHedgingState();
|
||||
eaHedgingBtn.SetState(false);
|
||||
Print("Hedging State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Trailling State Button ...
|
||||
else if (name == eaTraillingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeTraillingState();
|
||||
eaTraillingBtn.SetState(false);
|
||||
Print("Trailling State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Freezing State Button ...
|
||||
else if (name == eaFreezingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeFreezingState();
|
||||
eaFreezingBtn.SetState(false);
|
||||
Print("Freezing State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
// Supporting State Button ...
|
||||
else if (name == eaSupportingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeSupportingState();
|
||||
eaSupportingBtn.SetState(false);
|
||||
Print("Supporting State Button Clicked ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (isClicked)
|
||||
{
|
||||
UpdateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// SIGNALLING GUI ...
|
||||
|
||||
/**
|
||||
* Initialize State and Signalling GUI ...
|
||||
*
|
||||
@@ -143,7 +295,7 @@ bool InitSignallingGUI()
|
||||
|
||||
//
|
||||
// Create Activation Button ...
|
||||
string eaSignallingPrefix = eaSignallingPanelName + "_State_";
|
||||
string eaSignallingPrefix = eaSignallingPanelName + "_";
|
||||
|
||||
//
|
||||
// Signalling ...
|
||||
@@ -248,9 +400,9 @@ void UpdateSignallingGUI()
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy GUI ...
|
||||
* Destroy Signalling GUI ...
|
||||
*/
|
||||
void DestroyGUI()
|
||||
void DestroySignallingGUI()
|
||||
{
|
||||
//
|
||||
eaSignallingBtnName = NULL;
|
||||
@@ -264,54 +416,210 @@ void DestroyGUI()
|
||||
eaSignallingShortBtn.Destroy();
|
||||
}
|
||||
|
||||
//
|
||||
// PROTECTOR GUI ...
|
||||
|
||||
/**
|
||||
* Handle Object's Click Events ...
|
||||
* Initial Protector GUI ...
|
||||
*
|
||||
* @param name: Clicked Object Name
|
||||
* @return ( bool )
|
||||
*/
|
||||
void HandleOnClickEvent(string name)
|
||||
bool InitialProtectorGUI()
|
||||
{
|
||||
//
|
||||
if (!IsValid(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// State Button ...
|
||||
bool isClicked = false;
|
||||
if (name == eaSignallingBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeState();
|
||||
eaSignallingBtn.SetState(false);
|
||||
Print("State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
else if (name == eaSignallingLongBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeLongsState();
|
||||
eaSignallingLongBtn.SetState(false);
|
||||
Print("Long State Button Clicked ...");
|
||||
}
|
||||
//
|
||||
else if (name == eaSignallingShortBtnName)
|
||||
{
|
||||
//
|
||||
isClicked = true;
|
||||
HandleChangeShortsState();
|
||||
eaSignallingShortBtn.SetState(false);
|
||||
Print("Short State Button Clicked ...");
|
||||
}
|
||||
eaProtectorPanelName = mTag + "PROTECTOR";
|
||||
|
||||
//
|
||||
if (isClicked)
|
||||
// Create a Panel ...
|
||||
result = eaProtectorPanel.Create(
|
||||
eaProtectorPanelName,
|
||||
10,
|
||||
110,
|
||||
300,
|
||||
100 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
UpdateGUI();
|
||||
return result;
|
||||
}
|
||||
eaProtectorPanel.Caption("Protector");
|
||||
|
||||
//
|
||||
string eaProtectorPrefix = eaProtectorPanelName + "_";
|
||||
|
||||
//
|
||||
// Hedging ...
|
||||
eaHedgingBtnName = eaProtectorPrefix + "HEDGING_btn";
|
||||
result = eaHedgingBtn.Create(
|
||||
eaHedgingBtnName,
|
||||
10,
|
||||
130,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaHedgingBtn.SetText("");
|
||||
eaProtectorPanel.Add(eaHedgingBtnName);
|
||||
|
||||
//
|
||||
// Trailling ...
|
||||
eaTraillingBtnName = eaProtectorPrefix + "TRAILLING_btn";
|
||||
result = eaTraillingBtn.Create(
|
||||
eaTraillingBtnName,
|
||||
10,
|
||||
155,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaTraillingBtn.SetText("");
|
||||
eaProtectorPanel.Add(eaTraillingBtnName);
|
||||
|
||||
//
|
||||
// Freezing ...
|
||||
eaFreezingBtnName = eaProtectorPrefix + "FREEZING_btn";
|
||||
result = eaFreezingBtn.Create(
|
||||
eaFreezingBtnName,
|
||||
10,
|
||||
180,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaFreezingBtn.SetText("");
|
||||
eaProtectorPanel.Add(eaFreezingBtnName);
|
||||
|
||||
//
|
||||
// Supporting ...
|
||||
eaSupportingBtnName = eaProtectorPrefix + "SUPPORTING_btn";
|
||||
result = eaSupportingBtn.Create(
|
||||
eaSupportingBtnName,
|
||||
10,
|
||||
205,
|
||||
300,
|
||||
25 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
eaSupportingBtn.SetText("");
|
||||
eaProtectorPanel.Add(eaSupportingBtnName);
|
||||
|
||||
//
|
||||
UpdateProtectorGUI();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Signalling GUI Content ...
|
||||
*/
|
||||
void UpdateProtectorGUI()
|
||||
{
|
||||
//
|
||||
// Hedging ...
|
||||
bool isHedgingEnabled =
|
||||
mAllowHedge &&
|
||||
eaHedgeMinVolumeStep > 0 &&
|
||||
(eaHedgeHEMinProfitPerVolumeStep > 0 ||
|
||||
eaHedgeBEMinProfitPerVolumeStep > 0) &&
|
||||
eaMinimumOpenPositionsForHEHedge >= 0;
|
||||
|
||||
//
|
||||
color eaHedgingBtnTextColor = isHedgingEnabled
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaHedgingBtnText = isHedgingEnabled
|
||||
? "Deactive Hedging"
|
||||
: "Active Hedging";
|
||||
eaHedgingBtn.SetText(eaHedgingBtnText);
|
||||
eaHedgingBtn.SetColor(eaHedgingBtnTextColor);
|
||||
|
||||
//
|
||||
// Trailling ...
|
||||
bool isTraillingEnabled =
|
||||
mAllowTrail &&
|
||||
eaTrailStep > 0 &&
|
||||
eaTrailStartDistance >= 0;
|
||||
|
||||
//
|
||||
color eaTraillingBtnColor = isTraillingEnabled
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaTraillingBtnText = isTraillingEnabled
|
||||
? "Deactive Trailling"
|
||||
: "Active Trailling";
|
||||
eaTraillingBtn.SetText(eaTraillingBtnText);
|
||||
eaTraillingBtn.SetColor(eaTraillingBtnColor);
|
||||
|
||||
//
|
||||
// Freezing ...
|
||||
bool isFreezingEnabled =
|
||||
mllowFreeze &&
|
||||
eaFreezeDistance > 0 &&
|
||||
eaFreezeVolumeMultiplier > 0;
|
||||
|
||||
//
|
||||
color eaFreezingBtnColor = isFreezingEnabled
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaFreezingBtnText = isFreezingEnabled
|
||||
? "Deactive Freezing"
|
||||
: "Active Freezing";
|
||||
eaFreezingBtn.SetText(eaFreezingBtnText);
|
||||
eaFreezingBtn.SetColor(eaFreezingBtnColor);
|
||||
|
||||
//
|
||||
// Supporting ...
|
||||
bool isSupportingEnabled =
|
||||
!isFreezingEnabled &&
|
||||
mAllowSupport &&
|
||||
eaSupportStartDistance > 0 &&
|
||||
eaSupportVolumeMultiplier > 0;
|
||||
|
||||
//
|
||||
color eaSupportingBtnColor = isSupportingEnabled
|
||||
? clrRed
|
||||
: clrGreen;
|
||||
string eaSupportingBtnText = isSupportingEnabled
|
||||
? "Deactive Supporting"
|
||||
: "Active Supporting";
|
||||
eaSupportingBtn.SetText(eaSupportingBtnText);
|
||||
eaSupportingBtn.SetColor(eaSupportingBtnColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy Protector GUI ...
|
||||
*/
|
||||
void DestroyProtectorGUI()
|
||||
{
|
||||
//
|
||||
eaHedgingBtnName = NULL;
|
||||
eaFreezingBtnName = NULL;
|
||||
eaTraillingBtnName = NULL;
|
||||
eaSupportingBtnName = NULL;
|
||||
eaProtectorPanelName = NULL;
|
||||
|
||||
//
|
||||
eaHedgingBtn.Destroy();
|
||||
eaFreezingBtn.Destroy();
|
||||
eaTraillingBtn.Destroy();
|
||||
eaSupportingBtn.Destroy();
|
||||
eaProtectorPanel.Destroy();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -357,4 +665,32 @@ void HandleChangeShortsState()
|
||||
eaEnableShorts = !eaEnableShorts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Hedging State ...
|
||||
*/
|
||||
void HandleChangeHedgingState()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Trailling State ...
|
||||
*/
|
||||
void HandleChangeTraillingState()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Toogle Freezing State ...
|
||||
*/
|
||||
void HandleChangeFreezingState()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Toogle Supporting State ...
|
||||
*/
|
||||
void HandleChangeSupportingState()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
@@ -123,22 +123,22 @@ input group "In Drawdown Positions Protecting";
|
||||
|
||||
//
|
||||
// Freeze ...
|
||||
input group "Freeze";
|
||||
input bool eaAllowFreeze = false; // Allow Freezing
|
||||
input double eaFreezeDistance = 100; // Specify Freeze Start Drawdown in Point
|
||||
input bool eaRemoveFreezedPositionTPSL = true; // Remove Freezed Positions TPSL
|
||||
input bool eaDisableTrailWhenFreezedPosition = true; // Disable Trail when has Freezed Position
|
||||
// input group "Freeze";
|
||||
// input bool eaAllowFreeze = false; // Allow Freezing
|
||||
// input double eaFreezeDistance = 100; // Specify Freeze Start Drawdown in Point
|
||||
// input bool eaRemoveFreezedPositionTPSL = true; // Remove Freezed Positions TPSL
|
||||
// input bool eaDisableTrailWhenFreezedPosition = true; // Disable Trail when has Freezed Position
|
||||
|
||||
//
|
||||
// Support ...
|
||||
input group "Support";
|
||||
input bool eaAllowSupport = false; // Allow Support
|
||||
input double eaSupportStartDistance = 0; // Specify Start Support Drawdown in Point
|
||||
input int eaMaxAllowedSupport = 2; // Max Allowed Number of Support Position
|
||||
input double eaSupportVolumeMultiplier = 1; // Specify Support Volume Multiplier
|
||||
input bool eaMultiplySupportLevelOnVolume = false; // Multiply Support Level on Volume Multiplier
|
||||
input bool eaDoSupportOnConditions = true; // Do Support on Conditions
|
||||
input int eaDelayBetweenTwoSupport = 60; // Delay Between To Support in Second
|
||||
// input group "Support";
|
||||
// input bool eaAllowSupport = false; // Allow Support
|
||||
// input double eaSupportStartDistance = 0; // Specify Start Support Drawdown in Point
|
||||
// input int eaMaxAllowedSupport = 2; // Max Allowed Number of Support Position
|
||||
// input double eaSupportVolumeMultiplier = 1; // Specify Support Volume Multiplier
|
||||
// input bool eaMultiplySupportLevelOnVolume = false; // Multiply Support Level on Volume Multiplier
|
||||
// input bool eaDoSupportOnConditions = true; // Do Support on Conditions
|
||||
// input int eaDelayBetweenTwoSupport = 60; // Delay Between To Support in Second
|
||||
|
||||
//
|
||||
// Partial Close (In Drawdown) ...
|
||||
@@ -610,20 +610,20 @@ bool InitialEA()
|
||||
|
||||
//
|
||||
// Freeze ...
|
||||
eaTradeHandler.AllowFreeze(eaAllowFreeze);
|
||||
eaTradeHandler.FreezeDistance(eaFreezeDistance);
|
||||
eaTradeHandler.RemoveFreezedPositionTPSL(eaRemoveFreezedPositionTPSL);
|
||||
eaTradeHandler.DisableTrailWhenFreezedPosition(eaDisableTrailWhenFreezedPosition);
|
||||
// eaTradeHandler.AllowFreeze(eaAllowFreeze);
|
||||
// eaTradeHandler.FreezeDistance(eaFreezeDistance);
|
||||
// eaTradeHandler.RemoveFreezedPositionTPSL(eaRemoveFreezedPositionTPSL);
|
||||
// eaTradeHandler.DisableTrailWhenFreezedPosition(eaDisableTrailWhenFreezedPosition);
|
||||
|
||||
//
|
||||
// Support ...
|
||||
eaTradeHandler.AllowSupport(eaAllowSupport);
|
||||
eaTradeHandler.SupportStartDistance(eaSupportStartDistance);
|
||||
eaTradeHandler.MaxAllowedSupport(eaMaxAllowedSupport);
|
||||
eaTradeHandler.SupportVolumeMultiplier(eaSupportVolumeMultiplier);
|
||||
eaTradeHandler.MultiplySupportLevelOnVolume(eaMultiplySupportLevelOnVolume);
|
||||
eaTradeHandler.DoSupportOnConditions(eaDoSupportOnConditions);
|
||||
eaTradeHandler.DelayBetweenTwoSupport(eaDelayBetweenTwoSupport);
|
||||
// eaTradeHandler.AllowSupport(eaAllowSupport);
|
||||
// eaTradeHandler.SupportStartDistance(eaSupportStartDistance);
|
||||
// eaTradeHandler.MaxAllowedSupport(eaMaxAllowedSupport);
|
||||
// eaTradeHandler.SupportVolumeMultiplier(eaSupportVolumeMultiplier);
|
||||
// eaTradeHandler.MultiplySupportLevelOnVolume(eaMultiplySupportLevelOnVolume);
|
||||
// eaTradeHandler.DoSupportOnConditions(eaDoSupportOnConditions);
|
||||
// eaTradeHandler.DelayBetweenTwoSupport(eaDelayBetweenTwoSupport);
|
||||
|
||||
//
|
||||
// Partial Close (In Profit) ...
|
||||
|
||||
Reference in New Issue
Block a user