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 ... // Protector ...
input group "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 ... // Protector > Hedging Properties ...
@@ -222,9 +223,11 @@ XCPanel eaProtectorPanel;
XCButton eaHedgingBtn; XCButton eaHedgingBtn;
XCButton eaTraillingBtn; XCButton eaTraillingBtn;
XCButton eaProtectingBtn; XCButton eaProtectingBtn;
XCButton eaUseForceMomentumProtectingBtn;
bool eaEnableHedging = false; bool eaEnableHedging = false;
bool eaEnableTrailling = false; bool eaEnableTrailling = false;
bool eaEnableProtecting = false; bool eaEnableProtecting = false;
bool eaUseForceMomentumProtecting = eaUseForceMomentumsInProtection;
// //
// VOLUME GUI ... // VOLUME GUI ...
@@ -252,18 +255,18 @@ int OnInit()
return INIT_PARAMETERS_INCORRECT; return INIT_PARAMETERS_INCORRECT;
} }
//
if (!InitEA())
{
return INIT_FAILED;
}
// //
mTag = mTag =
!IsValid(eaLogSuffix) !IsValid(eaLogSuffix)
? ShortName ? ShortName
: ShortName + "_" + eaLogSuffix; : ShortName + "_" + eaLogSuffix;
//
if (!InitEA())
{
return INIT_FAILED;
}
// //
drawPrefix = mTag; drawPrefix = mTag;
@@ -582,6 +585,7 @@ bool InitEA()
// Configure Position Protector ... // Configure Position Protector ...
// //
eaTradeHandler.UseForceMomentumsInProtection(eaUseForceMomentumsInProtection);
eaTradeHandler.DelayBarBetweenTwoSameSignal(eaDelayBarBetweenTwoSameSignal); eaTradeHandler.DelayBarBetweenTwoSameSignal(eaDelayBarBetweenTwoSameSignal);
// //
@@ -1185,6 +1189,15 @@ void HandleOnClickEvent(string name)
eaProtectingBtn.State(false); eaProtectingBtn.State(false);
} }
// //
// Use Force Momentum Protecting Button ...
else if (name == eaUseForceMomentumProtectingBtn.Name())
{
//
isClicked = true;
HandleChangeForceMomentumProtectingState();
eaUseForceMomentumProtectingBtn.State(false);
}
//
// Dynamic Volume State ... // Dynamic Volume State ...
else if (name == eaDynamicVolumeBtn.Name()) else if (name == eaDynamicVolumeBtn.Name())
{ {
@@ -1707,7 +1720,7 @@ bool InitProtectorGUI()
10, 10,
110, 110,
300, 300,
75 // 100 //
); );
if (!result) if (!result)
{ {
@@ -1754,7 +1767,7 @@ bool InitProtectorGUI()
// //
// Protecting ... // Protecting ...
string eaProtectingBtnName = eaProtectorPrefix + "FREEZING_btn"; string eaProtectingBtnName = eaProtectorPrefix + "PROTECTING_btn";
result = eaProtectingBtn.Create( result = eaProtectingBtn.Create(
eaProtectingBtnName, eaProtectingBtnName,
10, 10,
@@ -1769,6 +1782,23 @@ bool InitProtectorGUI()
eaProtectingBtn.Text(""); eaProtectingBtn.Text("");
eaProtectorPanel.Add(eaProtectingBtnName); 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(); UpdateProtectorGUI();
@@ -1879,6 +1909,22 @@ void UpdateProtectorGUI()
: "Active Protecting"; : "Active Protecting";
eaProtectingBtn.Text(eaProtectingBtnText); eaProtectingBtn.Text(eaProtectingBtnText);
eaProtectingBtn.Color(eaProtectingBtnTextColor); 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(); eaHedgingBtn.Destroy();
eaTraillingBtn.Destroy(); eaTraillingBtn.Destroy();
eaProtectingBtn.Destroy(); eaProtectingBtn.Destroy();
eaUseForceMomentumProtectingBtn.Destroy();
// //
eaProtectorPanel.Destroy(); eaProtectorPanel.Destroy();
@@ -1967,6 +2014,27 @@ void HandleChangeProtectingState()
// //
eaEnableProtecting = !eaEnableProtecting; 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.AllowHedge(eaEnableHedging);
eaTradeHandler.AllowTrail(eaEnableTrailling); eaTradeHandler.AllowTrail(eaEnableTrailling);
eaTradeHandler.AllowProtect(eaEnableProtecting); eaTradeHandler.AllowProtect(eaEnableProtecting);
eaTradeHandler.UseForceMomentumsInProtection(eaUseForceMomentumProtecting);
// //
UpdateProtectorGUI(); UpdateProtectorGUI();
@@ -2004,7 +2073,7 @@ bool InitVolumeGUI()
result = eaVolumePanel.Create( result = eaVolumePanel.Create(
eaVolumePanelName, eaVolumePanelName,
10, 10,
205, 230,
300, 300,
75 // 75 //
); );
@@ -2023,7 +2092,7 @@ bool InitVolumeGUI()
result = eaDynamicVolumeBtn.Create( result = eaDynamicVolumeBtn.Create(
eaDynamicVolumeBtnName, eaDynamicVolumeBtnName,
10, 10,
225, 250,
300, 300,
25 // 25 //
); );
@@ -2043,7 +2112,7 @@ bool InitVolumeGUI()
result = eaStaticVolumeLbl.Create( result = eaStaticVolumeLbl.Create(
eaStaticVolumeLblName, eaStaticVolumeLblName,
10, 10,
250 // 275 //
); );
if (!result) if (!result)
{ {
@@ -2060,7 +2129,7 @@ bool InitVolumeGUI()
result = eaStaticVolumeTb.Create( result = eaStaticVolumeTb.Create(
eaStaticVolumeTbName, eaStaticVolumeTbName,
160, 160,
250, 275,
150, 150,
25 // 25 //
); );
@@ -2080,7 +2149,7 @@ bool InitVolumeGUI()
result = eaSetStaticVolumeBtn.Create( result = eaSetStaticVolumeBtn.Create(
eaSetStaticVolumeBtnName, eaSetStaticVolumeBtnName,
10, 10,
275, 300,
150, 150,
25 // 25 //
); );
@@ -2097,7 +2166,7 @@ bool InitVolumeGUI()
result = eaResetStaticVolumeBtn.Create( result = eaResetStaticVolumeBtn.Create(
eaResetStaticVolumeBtnName, eaResetStaticVolumeBtnName,
160, 160,
275, 300,
150, 150,
25 // 25 //
); );
@@ -2208,6 +2277,9 @@ void HandleChangeDynamicVolumeState()
// //
eEnableDynamicVolumeVolume = !eEnableDynamicVolumeVolume; eEnableDynamicVolumeVolume = !eEnableDynamicVolumeVolume;
//
UpdateVolumeGUI();
} }
/** /**
@@ -2238,6 +2310,9 @@ void HandleChangeStaticVolume()
{ {
eaAppliedStaticVolume = eaVolume; eaAppliedStaticVolume = eaVolume;
} }
//
UpdateVolumeGUI();
} }
/** /**
@@ -2264,6 +2339,9 @@ void HandleResetStaticVolume()
// //
eaStaticVolumeTb.Text(ToString(eaVolume)); eaStaticVolumeTb.Text(ToString(eaVolume));
//
UpdateVolumeGUI();
} }
// //