Skip to content

Commit 765c85e

Browse files
author
EarnForex
authored
3.01
Hotfix for bugs with breakeven and hotkey.
1 parent 53a5c34 commit 765c85e

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

MQL4/Experts/Position Sizer/Position Sizer Trading.mqh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void DoBreakEven()
437437
}
438438
else if (OrderType() == OP_SELL)
439439
{
440-
double BE = NormalizeDouble(OrderOpenPrice() - sets.TrailingStopPoints * _Point, _Digits);
440+
double BE = NormalizeDouble(OrderOpenPrice() - sets.BreakEvenPoints * _Point, _Digits);
441441
if ((Ask <= BE) && ((OrderOpenPrice() < OrderStopLoss()) || (OrderStopLoss() == 0))) // Only move to breakeven if the current stop-loss is higher (or zero).
442442
{
443443
// Write Open price to the SL field.

MQL4/Experts/Position Sizer/Position Sizer.mq4

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//+------------------------------------------------------------------+
66
#property copyright "EarnForex.com"
77
#property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/"
8-
#property version "3.00"
9-
string Version = "3.00";
8+
#property version "3.01"
9+
string Version = "3.01";
1010
#property strict
1111

1212
#property description "Calculates risk-based position size for your account."
@@ -111,14 +111,18 @@ bool Dont_Move_the_Panel_to_Default_Corner_X_Y;
111111
uint LastRecalculationTime = 0;
112112
bool StopLossLineIsBeingMoved = false;
113113
bool TakeProfitLineIsBeingMoved = false;
114-
uchar MainKey = 0;
115-
bool CtrlRequired = false;
116-
bool ShiftRequired = false;
114+
uchar MainKey;
115+
bool CtrlRequired;
116+
bool ShiftRequired;
117117
bool NeedToCheckToggleScaleOffOn;
118118
int PrevChartWidth;
119119

120120
int OnInit()
121121
{
122+
CtrlRequired = false;
123+
ShiftRequired = false;
124+
MainKey = 0;
125+
122126
ExtDialog = new CPositionSizeCalculator;
123127
PrevChartWidth = 0;
124128

@@ -316,9 +320,14 @@ int OnInit()
316320
if (keys[i] == "SHIFT") ShiftRequired = true;
317321
else if (keys[i] == "CTRL") CtrlRequired = true;
318322
}
323+
StringToUpper(keys[n - 1]);
319324
MainKey = (uchar)StringGetCharacter(keys[n - 1], 0);
320325
}
321-
else MainKey = (uchar)StringGetCharacter(keys[0], 0); // Just a single key.
326+
else
327+
{
328+
StringToUpper(keys[0]);
329+
MainKey = (uchar)StringGetCharacter(keys[0], 0); // Just a single key.
330+
}
322331
}
323332

324333
if (!EventSetTimer(1)) Print("Error setting timer: ", GetLastError());
-6 Bytes
Binary file not shown.

MQL5/Experts/Position Sizer/Position Sizer.mq5

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
//+------------------------------------------------------------------+
66
#property copyright "EarnForex.com"
77
#property link "https://www.earnforex.com/metatrader-expert-advisors/Position-Sizer/"
8-
#property version "3.00"
9-
string Version = "3.00";
8+
#property version "3.01"
9+
string Version = "3.01";
1010

1111
#property description "Calculates risk-based position size for your account."
1212
#property description "Allows trade execution based the calculation results.\r\n"
@@ -122,12 +122,16 @@ bool Dont_Move_the_Panel_to_Default_Corner_X_Y = true;
122122
uint LastRecalculationTime = 0;
123123
bool StopLossLineIsBeingMoved = false;
124124
bool TakeProfitLineIsBeingMoved = false;
125-
uchar MainKey = 0;
126-
bool CtrlRequired = false;
127-
bool ShiftRequired = false;
125+
uchar MainKey;
126+
bool CtrlRequired;
127+
bool ShiftRequired;
128128

129129
int OnInit()
130130
{
131+
CtrlRequired = false;
132+
ShiftRequired = false;
133+
MainKey = 0;
134+
131135
ExtDialog = new CPositionSizeCalculator;
132136

133137
MathSrand(GetTickCount() + 293029); // Used by CreateInstanceId() in Dialog.mqh (standard library). Keep the second number unique across other panel indicators/EAs.
@@ -323,9 +327,14 @@ int OnInit()
323327
if (keys[i] == "SHIFT") ShiftRequired = true;
324328
else if (keys[i] == "CTRL") CtrlRequired = true;
325329
}
330+
StringToUpper(keys[n - 1]);
326331
MainKey = (uchar)StringGetCharacter(keys[n - 1], 0);
327332
}
328-
else MainKey = (uchar)StringGetCharacter(keys[0], 0); // Just a single key.
333+
else
334+
{
335+
StringToUpper(keys[0]);
336+
MainKey = (uchar)StringGetCharacter(keys[0], 0); // Just a single key.
337+
}
329338
}
330339

331340
if (!EventSetTimer(1)) Print("Error setting timer: ", GetLastError());

0 commit comments

Comments
 (0)