add support for Use Force Momentum Protection in Protecting GUI Panel ...

This commit is contained in:
2024-10-03 11:48:09 +03:30
parent 3ca49fec2e
commit 3c6d16e953
2 changed files with 93 additions and 15 deletions
Binary file not shown.
+93 -15
View File
@@ -92,7 +92,8 @@ input double eaMaxDrawdownPercentForOpenTrades = 3; // Max Drawdown Percent for
//
// Protector ...
input group "Protector";
input int eaDelayBarBetweenTwoSameSignal = 5; // Delay Bars Between Two Same Type Signal
input bool eaUseForceMomentumsInProtection = true; // Use Force Momentums In Protection;
input int eaDelayBarBetweenTwoSameSignal = 5; // Delay Bars Between Two Same Type Signal
//
// Protector > Hedging Properties ...
@@ -222,9 +223,11 @@ XCPanel eaProtectorPanel;
XCButton eaHedgingBtn;
XCButton eaTraillingBtn;
XCButton eaProtectingBtn;
XCButton eaUseForceMomentumProtectingBtn;
bool eaEnableHedging = false;
bool eaEnableTrailling = false;
bool eaEnableProtecting = false;
bool eaUseForceMomentumProtecting = eaUseForceMomentumsInProtection;
//
// VOLUME GUI ...
@@ -252,18 +255,18 @@ int OnInit()
return INIT_PARAMETERS_INCORRECT;
}
//
if (!InitEA())
{
return INIT_FAILED;
}
//
mTag =
!IsValid(eaLogSuffix)
? ShortName
: ShortName + "_" + eaLogSuffix;
//
if (!InitEA())
{
return INIT_FAILED;
}
//
drawPrefix = mTag;
@@ -582,6 +585,7 @@ bool InitEA()
// Configure Position Protector ...
//
eaTradeHandler.UseForceMomentumsInProtection(eaUseForceMomentumsInProtection);
eaTradeHandler.DelayBarBetweenTwoSameSignal(eaDelayBarBetweenTwoSameSignal);
//
@@ -1185,6 +1189,15 @@ void HandleOnClickEvent(string name)
eaProtectingBtn.State(false);
}
//
// Use Force Momentum Protecting Button ...
else if (name == eaUseForceMomentumProtectingBtn.Name())
{
//
isClicked = true;
HandleChangeForceMomentumProtectingState();
eaUseForceMomentumProtectingBtn.State(false);
}
//
// Dynamic Volume State ...
else if (name == eaDynamicVolumeBtn.Name())
{
@@ -1707,7 +1720,7 @@ bool InitProtectorGUI()
10,
110,
300,
75 //
100 //
);
if (!result)
{
@@ -1754,7 +1767,7 @@ bool InitProtectorGUI()
//
// Protecting ...
string eaProtectingBtnName = eaProtectorPrefix + "FREEZING_btn";
string eaProtectingBtnName = eaProtectorPrefix + "PROTECTING_btn";
result = eaProtectingBtn.Create(
eaProtectingBtnName,
10,
@@ -1769,6 +1782,23 @@ bool InitProtectorGUI()
eaProtectingBtn.Text("");
eaProtectorPanel.Add(eaProtectingBtnName);
//
// Use Force Momentum Protecting ...
string eaUseForceMomentumProtectingBtnName = eaProtectorPrefix + "FORCE_MOMENTUM_btn";
result = eaUseForceMomentumProtectingBtn.Create(
eaUseForceMomentumProtectingBtnName,
10,
205,
300,
25 //
);
if (!result)
{
return result;
}
eaUseForceMomentumProtectingBtn.Text("");
eaProtectorPanel.Add(eaUseForceMomentumProtectingBtnName);
//
UpdateProtectorGUI();
@@ -1879,6 +1909,22 @@ void UpdateProtectorGUI()
: "Active Protecting";
eaProtectingBtn.Text(eaProtectingBtnText);
eaProtectingBtn.Color(eaProtectingBtnTextColor);
//
color eaUseForceMomentumProtectingBtnColor =
(!eaEnableProtecting && !eaEnableTrailling)
? clrGray
: eaUseForceMomentumProtecting
? clrRed
: clrGreen;
string eaUseForceMomentumProtectingBtnText =
(!eaEnableProtecting && !eaEnableTrailling)
? "Force Momentum Disabled"
: eaUseForceMomentumProtecting
? "Deactive Force Momentum"
: "Active Force Momentum";
eaUseForceMomentumProtectingBtn.Text(eaUseForceMomentumProtectingBtnText);
eaUseForceMomentumProtectingBtn.Color(eaUseForceMomentumProtectingBtnColor);
}
/**
@@ -1890,6 +1936,7 @@ void DestroyProtectorGUI()
eaHedgingBtn.Destroy();
eaTraillingBtn.Destroy();
eaProtectingBtn.Destroy();
eaUseForceMomentumProtectingBtn.Destroy();
//
eaProtectorPanel.Destroy();
@@ -1967,6 +2014,27 @@ void HandleChangeProtectingState()
//
eaEnableProtecting = !eaEnableProtecting;
//
UpdateProtectingOnTradeHandler();
}
/**
* Toggle Force Momentum Protecting State ...
*/
void HandleChangeForceMomentumProtectingState()
{
//
if (!eaEnableProtecting && !eaEnableTrailling)
{
return;
}
//
eaUseForceMomentumProtecting = !eaUseForceMomentumProtecting;
//
UpdateProtectingOnTradeHandler();
}
/**
@@ -1978,6 +2046,7 @@ void UpdateProtectingOnTradeHandler()
eaTradeHandler.AllowHedge(eaEnableHedging);
eaTradeHandler.AllowTrail(eaEnableTrailling);
eaTradeHandler.AllowProtect(eaEnableProtecting);
eaTradeHandler.UseForceMomentumsInProtection(eaUseForceMomentumProtecting);
//
UpdateProtectorGUI();
@@ -2004,7 +2073,7 @@ bool InitVolumeGUI()
result = eaVolumePanel.Create(
eaVolumePanelName,
10,
205,
230,
300,
75 //
);
@@ -2023,7 +2092,7 @@ bool InitVolumeGUI()
result = eaDynamicVolumeBtn.Create(
eaDynamicVolumeBtnName,
10,
225,
250,
300,
25 //
);
@@ -2043,7 +2112,7 @@ bool InitVolumeGUI()
result = eaStaticVolumeLbl.Create(
eaStaticVolumeLblName,
10,
250 //
275 //
);
if (!result)
{
@@ -2060,7 +2129,7 @@ bool InitVolumeGUI()
result = eaStaticVolumeTb.Create(
eaStaticVolumeTbName,
160,
250,
275,
150,
25 //
);
@@ -2080,7 +2149,7 @@ bool InitVolumeGUI()
result = eaSetStaticVolumeBtn.Create(
eaSetStaticVolumeBtnName,
10,
275,
300,
150,
25 //
);
@@ -2097,7 +2166,7 @@ bool InitVolumeGUI()
result = eaResetStaticVolumeBtn.Create(
eaResetStaticVolumeBtnName,
160,
275,
300,
150,
25 //
);
@@ -2208,6 +2277,9 @@ void HandleChangeDynamicVolumeState()
//
eEnableDynamicVolumeVolume = !eEnableDynamicVolumeVolume;
//
UpdateVolumeGUI();
}
/**
@@ -2238,6 +2310,9 @@ void HandleChangeStaticVolume()
{
eaAppliedStaticVolume = eaVolume;
}
//
UpdateVolumeGUI();
}
/**
@@ -2264,6 +2339,9 @@ void HandleResetStaticVolume()
//
eaStaticVolumeTb.Text(ToString(eaVolume));
//
UpdateVolumeGUI();
}
//