Skip to content

Commit f6c144f

Browse files
author
EarnForex
authored
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.
1 parent 903f700 commit f6c144f

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

MQL4/Experts/Position Sizer/Position Sizer.mq4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#property copyright "EarnForex.com"
77
#property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/"
88
#property icon "EF-Icon-64x64px.ico"
9-
#property version "3.08"
10-
string Version = "3.08";
9+
#property version "3.09"
10+
string Version = "3.09";
1111
#property strict
1212

1313
#property description "Calculates risk-based position size for your account."

MQL4/Experts/Position Sizer/Position Sizer.mqh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ if (ShowATROptions) ON_EVENT(ON_CLICK, m_BtnATRTimeframe, OnClickBtnATRTimeframe
249249
ON_EVENT(ON_CLICK, m_BtnTrade, OnClickBtnTrade)
250250
if (QuickRisk1 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk1, OnClickBtnQuickRisk1)
251251
if (QuickRisk2 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk2, OnClickBtnQuickRisk2)
252-
ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade)
252+
if ((AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_MAIN) || (AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_BOTH)) ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade)
253253
EVENT_MAP_END(CAppDialog)
254254

255255
//+-------------------+
@@ -4920,15 +4920,20 @@ bool CPositionSizeCalculator::LoadSettingsFromDisk()
49204920

49214921
bool CPositionSizeCalculator::DeleteSettingsFile()
49224922
{
4923-
if (!FileIsExist(m_FileName))
4923+
string fn_with_path = "PS_" + m_FileName;
4924+
if (!FileIsExist(fn_with_path)) // Try old location.
4925+
{
4926+
fn_with_path = "PS_Settings\\" + m_FileName; // Change to new location.
4927+
}
4928+
if (!FileIsExist(fn_with_path))
49244929
{
49254930
Print("No settings file to delete.");
49264931
return false;
49274932
}
49284933
Print("Trying to delete settings file.");
4929-
if (!FileDelete(m_FileName))
4934+
if (!FileDelete(fn_with_path))
49304935
{
4931-
Print("Failed to delete file: " + m_FileName + ". Error: " + IntegerToString(GetLastError()));
4936+
Print("Failed to delete file: " + fn_with_path + ". Error: " + IntegerToString(GetLastError()));
49324937
return false;
49334938
}
49344939
Print("Deleted settings file successfully.");
@@ -5431,7 +5436,7 @@ void Initialization()
54315436
if (sets.EntryLevel - sets.StopLossLevel == 0)
54325437
{
54335438
Print("Entry and Stop-Loss levels should be different and non-zero.");
5434-
return;
5439+
// return;
54355440
}
54365441

54375442
if (sets.EntryType == Instant)

MQL5/Experts/Position Sizer/Position Sizer.mq5

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#property copyright "EarnForex.com"
77
#property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/"
88
#property icon "EF-Icon-64x64px.ico"
9-
#property version "3.08"
10-
string Version = "3.08";
9+
#property version "3.09"
10+
string Version = "3.09";
1111

1212
#include "Translations\English.mqh"
1313
//#include "Translations\Arabic.mqh"
@@ -398,11 +398,7 @@ int OnInit()
398398
sets.StopPriceLevel = 0;
399399
Dont_Move_the_Panel_to_Default_Corner_X_Y = false;
400400
}
401-
/* 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.
402-
{
403-
ExtDialog.IniFileLoad();
404-
}
405-
*/ }
401+
}
406402

407403
// Avoid re-initialization on timeframe change and on symbol change with the 'keep panel' setting.
408404
if ((DeinitializationReason != REASON_CHARTCHANGE) || ((DeinitializationReason == REASON_CHARTCHANGE) && (OldSymbol != _Symbol) && ((SymbolChange == SYMBOL_CHART_CHANGE_HARD_RESET) || (SymbolChange == SYMBOL_CHART_CHANGE_EACH_OWN))))

MQL5/Experts/Position Sizer/Position Sizer.mqh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ if (ShowATROptions) ON_EVENT(ON_CLICK, m_BtnATRTimeframe, OnClickBtnATRTimeframe
258258
ON_EVENT(ON_CLICK, m_BtnTrade, OnClickBtnTrade)
259259
if (QuickRisk1 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk1, OnClickBtnQuickRisk1)
260260
if (QuickRisk2 > 0) ON_EVENT(ON_CLICK, m_BtnQuickRisk2, OnClickBtnQuickRisk2)
261-
ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade)
261+
if ((AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_MAIN) || (AdditionalTradeButtons == ADDITIONAL_TRADE_BUTTONS_BOTH)) ON_EVENT(ON_CLICK, m_BtnMainTrade, OnClickBtnTrade)
262262
EVENT_MAP_END(CAppDialog)
263263

264264
//+-------------------+
@@ -5397,13 +5397,18 @@ bool CPositionSizeCalculator::LoadSettingsFromDisk()
53975397

53985398
bool CPositionSizeCalculator::DeleteSettingsFile()
53995399
{
5400-
if (!FileIsExist(m_FileName))
5400+
string fn_with_path = "PS_" + m_FileName;
5401+
if (!FileIsExist(fn_with_path)) // Try old location.
5402+
{
5403+
fn_with_path = "PS_Settings\\" + m_FileName; // Change to new location.
5404+
}
5405+
if (!FileIsExist(fn_with_path))
54015406
{
54025407
Print(TRANSLATION_MESSAGE_NO_SETTINGS_FILE_TO_DELETE);
54035408
return false;
54045409
}
54055410
Print(TRANSLATION_MESSAGE_TRYING_TO_DELETE_FILE);
5406-
if (!FileDelete(m_FileName))
5411+
if (!FileDelete(fn_with_path))
54075412
{
54085413
Print(TRANSLATION_MESSAGE_FAILED_TO_DELETE_FILE + ": " + m_FileName + ". " + TRANSLATION_MESSAGE_ERROR + ": " + IntegerToString(GetLastError()));
54095414
return false;
@@ -5975,7 +5980,7 @@ void Initialization()
59755980
if (sets.EntryLevel - sets.StopLossLevel == 0)
59765981
{
59775982
Print(TRANSLATION_MESSAGE_ENTRY_SL_DIFFERENT_NON_ZERO);
5978-
return;
5983+
// return;
59795984
}
59805985

59815986
if (sets.EntryType == Instant)

0 commit comments

Comments
 (0)