Skip to content

Commit

Permalink
3.09
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EarnForex committed May 23, 2024
1 parent 903f700 commit f6c144f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions MQL4/Experts/Position Sizer/Position Sizer.mq4
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
15 changes: 10 additions & 5 deletions MQL4/Experts/Position Sizer/Position Sizer.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

//+-------------------+
Expand Down Expand Up @@ -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.");
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 3 additions & 7 deletions MQL5/Experts/Position Sizer/Position Sizer.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))))
Expand Down
13 changes: 9 additions & 4 deletions MQL5/Experts/Position Sizer/Position Sizer.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

//+-------------------+
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f6c144f

Please sign in to comment.