From f6c144fc53359539a4130aedc4ac1c728ffc5cf2 Mon Sep 17 00:00:00 2001 From: EarnForex <48102957+EarnForex@users.noreply.github.com> Date: Thu, 23 May 2024 15:46:35 +0200 Subject: [PATCH] 3.09 1. Fixed a bug that could cause the trade button to trigger when pressing unrelated buttons. 2. Fixed a bug that could cause the panel to get stuck in the initialization process when the SL line was generated at the same price as the Entry line. 3. Fixed a bug with deleting the settings file when closing the panel. --- MQL4/Experts/Position Sizer/Position Sizer.mq4 | 4 ++-- MQL4/Experts/Position Sizer/Position Sizer.mqh | 15 ++++++++++----- MQL5/Experts/Position Sizer/Position Sizer.mq5 | 10 +++------- MQL5/Experts/Position Sizer/Position Sizer.mqh | 13 +++++++++---- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/MQL4/Experts/Position Sizer/Position Sizer.mq4 b/MQL4/Experts/Position Sizer/Position Sizer.mq4 index 8d637f4..84edcb7 100644 --- a/MQL4/Experts/Position Sizer/Position Sizer.mq4 +++ b/MQL4/Experts/Position Sizer/Position Sizer.mq4 @@ -6,8 +6,8 @@ #property copyright "EarnForex.com" #property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/" #property icon "EF-Icon-64x64px.ico" -#property version "3.08" -string Version = "3.08"; +#property version "3.09" +string Version = "3.09"; #property strict #property description "Calculates risk-based position size for your account." diff --git a/MQL4/Experts/Position Sizer/Position Sizer.mqh b/MQL4/Experts/Position Sizer/Position Sizer.mqh index 2f96583..4bc8ecc 100644 --- a/MQL4/Experts/Position Sizer/Position Sizer.mqh +++ b/MQL4/Experts/Position Sizer/Position Sizer.mqh @@ -249,7 +249,7 @@ if (ShowATROptions) ON_EVENT(ON_CLICK, m_BtnATRTimeframe, OnClickBtnATRTimeframe ON_EVENT(ON_CLICK, m_BtnTrade, OnClickBtnTrade) if (QuickRisk1 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk1, OnClickBtnQuickRisk1) if (QuickRisk2 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk2, OnClickBtnQuickRisk2) -ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade) +if ((AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_MAIN) || (AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_BOTH)) ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade) EVENT_MAP_END(CAppDialog) //+-------------------+ @@ -4920,15 +4920,20 @@ bool CPositionSizeCalculator::LoadSettingsFromDisk() bool CPositionSizeCalculator::DeleteSettingsFile() { - if (!FileIsExist(m_FileName)) + string fn_with_path = "PS_" + m_FileName; + if (!FileIsExist(fn_with_path)) // Try old location. + { + fn_with_path = "PS_Settings\\" + m_FileName; // Change to new location. + } + if (!FileIsExist(fn_with_path)) { Print("No settings file to delete."); return false; } Print("Trying to delete settings file."); - if (!FileDelete(m_FileName)) + if (!FileDelete(fn_with_path)) { - Print("Failed to delete file: " + m_FileName + ". Error: " + IntegerToString(GetLastError())); + Print("Failed to delete file: " + fn_with_path + ". Error: " + IntegerToString(GetLastError())); return false; } Print("Deleted settings file successfully."); @@ -5431,7 +5436,7 @@ void Initialization() if (sets.EntryLevel - sets.StopLossLevel == 0) { Print("Entry and Stop-Loss levels should be different and non-zero."); - return; +// return; } if (sets.EntryType == Instant) diff --git a/MQL5/Experts/Position Sizer/Position Sizer.mq5 b/MQL5/Experts/Position Sizer/Position Sizer.mq5 index 6f10c7f..3765f82 100644 --- a/MQL5/Experts/Position Sizer/Position Sizer.mq5 +++ b/MQL5/Experts/Position Sizer/Position Sizer.mq5 @@ -6,8 +6,8 @@ #property copyright "EarnForex.com" #property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/" #property icon "EF-Icon-64x64px.ico" -#property version "3.08" -string Version = "3.08"; +#property version "3.09" +string Version = "3.09"; #include "Translations\English.mqh" //#include "Translations\Arabic.mqh" @@ -398,11 +398,7 @@ int OnInit() sets.StopPriceLevel = 0; Dont_Move_the_Panel_to_Default_Corner_X_Y = false; } -/* else if (SymbolChange == SYMBOL_CHART_CHANGE_EACH_OWN) // Load the INI file if it was a symbol change and a each symbol has its own settings. - { - ExtDialog.IniFileLoad(); - } - */ } + } // Avoid re-initialization on timeframe change and on symbol change with the 'keep panel' setting. if ((DeinitializationReason != REASON_CHARTCHANGE) || ((DeinitializationReason == REASON_CHARTCHANGE) && (OldSymbol != _Symbol) && ((SymbolChange == SYMBOL_CHART_CHANGE_HARD_RESET) || (SymbolChange == SYMBOL_CHART_CHANGE_EACH_OWN)))) diff --git a/MQL5/Experts/Position Sizer/Position Sizer.mqh b/MQL5/Experts/Position Sizer/Position Sizer.mqh index 34e4f36..b259797 100644 --- a/MQL5/Experts/Position Sizer/Position Sizer.mqh +++ b/MQL5/Experts/Position Sizer/Position Sizer.mqh @@ -258,7 +258,7 @@ if (ShowATROptions) ON_EVENT(ON_CLICK, m_BtnATRTimeframe, OnClickBtnATRTimeframe ON_EVENT(ON_CLICK, m_BtnTrade, OnClickBtnTrade) if (QuickRisk1 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk1, OnClickBtnQuickRisk1) if (QuickRisk2 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk2, OnClickBtnQuickRisk2) -ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade) +if ((AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_MAIN) || (AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_BOTH)) ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade) EVENT_MAP_END(CAppDialog) //+-------------------+ @@ -5397,13 +5397,18 @@ bool CPositionSizeCalculator::LoadSettingsFromDisk() bool CPositionSizeCalculator::DeleteSettingsFile() { - if (!FileIsExist(m_FileName)) + string fn_with_path = "PS_" + m_FileName; + if (!FileIsExist(fn_with_path)) // Try old location. + { + fn_with_path = "PS_Settings\\" + m_FileName; // Change to new location. + } + if (!FileIsExist(fn_with_path)) { Print(TRANSLATION_MESSAGE_NO_SETTINGS_FILE_TO_DELETE); return false; } Print(TRANSLATION_MESSAGE_TRYING_TO_DELETE_FILE); - if (!FileDelete(m_FileName)) + if (!FileDelete(fn_with_path)) { Print(TRANSLATION_MESSAGE_FAILED_TO_DELETE_FILE + ": " + m_FileName + ". " + TRANSLATION_MESSAGE_ERROR + ": " + IntegerToString(GetLastError())); return false; @@ -5975,7 +5980,7 @@ void Initialization() if (sets.EntryLevel - sets.StopLossLevel == 0) { Print(TRANSLATION_MESSAGE_ENTRY_SL_DIFFERENT_NON_ZERO); - return; +// return; } if (sets.EntryType == Instant)