From 3c6d16e953625c173e37572524e5c9a9519c2706 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Thu, 3 Oct 2024 11:48:09 +0330 Subject: [PATCH] add support for Use Force Momentum Protection in Protecting GUI Panel ... --- .../x-saherelm.x121.xtrade.handler.class.mq5 | Bin 162340 -> 167572 bytes Experts/x-saherelm.x121.ea.mq5 | 108 +++++++++++++++--- 2 files changed, 93 insertions(+), 15 deletions(-) diff --git a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 index 39c45286c99018797ba6e89fecf49ebe53082d5e..21044ed47a652ad45e2055291849e6c2127dbf88 100644 GIT binary patch delta 1820 zcmb7FU1(HS5I%EU*7at0y-FG-P2-LGlQmxBHked2Sz^?vVUw&&MNrX-N~4W&O%z3Z zh?ZIqL~sIA3d)LQAAAyoE`lZ-MSW3;PnFgOQNg!RLS9kl$2Rf1OSJH4uc&2}_OdR!#d`jJFS_V#5<*aqRT~$~X&0ShjaVyo@ZbiqPOQhO zpF1^Hpj&iLffZ-Hj}#!yo=4OqP8U=r~Bl{lB=P+Y-GmAdv`Ci9p_!?AGL5AvT z3%{y{PiJ5vY!D0SUi<0xI(ihpVyOHUlw&I4q5hXJf3Xr%i5lj|;>9(^!lOAp_y)}t z)?&rD$jWheWfkV!9!fPqgqlHy>DzG#lKC3!l9=wL?kiqw4LLE-12W=R<}4Y0o2!j? z^XWkzYG`BvE{^GcOf^HB26qO>UqkARKTQ0WQ2q`T@isn8-Z6INUV#nE=;1g7C^`nM zI!&{-dZj^84{y~sg`A6&EBie$KHJofi;*m8)H>)jIXxYcbWchxL9e2lVqHvn zR3mM=5|GBUNGs&!3b~Lq`)bu3rJ6d9K64ge^e5g)2?CS0+tSQF3d++ZTB~eNRKEOD z-5}NbMe!#>{Yu{XOZl-TlB|NO=fk5}9oKyQ;K3X7@bZwKwzqNP_Qho*SlLT)d1A@` D76kNg delta 614 zcmY*VT}V@L6#t*&y4}0(F4sAy=Et_%h#^y&Sq+VtOA2z>s9q8uW;VeZHq3emicxQS zlM^0-dI%DN1}%hcR>)q22nvbt!60T&J;{oohedYpEGrJ@<#&D`=bYR3oDaS!#SxYC zJ5JYxm=HbGMo zmj0^M8Hz|PT)GZUDx6UN!W?)4O|+zTQbKal%43aws42!z;GvAGjo(Fa_s)zM6PLvd zMXC)uPKqhf&ztMeLh_JW=NE%KdjJ}!yP(zo=84ndipW}ZiPp^~-nfV|=RaD((vVhf z3B;uBW_eDDagioScP$iM&pa@}?TfIV%lH3V`-|Vl6$54Jsk-T=G0L$;&})eDZ%!j^ zJd(&^^zzC8Xba7IrgN0LE8oh_o7s8ji%_qm6Sj7kuU6r09r$S=*v_dqI=Hk3K~5eA z2ZxrS!_+^37NX*&&WX>U@lrFo&F78iP&j`GRo>^rQ(Srh5@!!$kYC2Ijr61XmO5yNtHF7OEc)C${Fct0FxdL`Yb~BHH5Z(4E`BMiE@)Vl_a?qej$$Gxm7FX z@OLnHxC$!Iy@3&XzHMHU8SL+e9uCLQYZjuI-&Ld7_n3Wy__fvk0>4k;5z{+{H@bcS Ddzi#p diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index 4e89e10a..0e995c2e 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -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(); } // \ No newline at end of file