Skip to content

Commit

Permalink
3.03
Browse files Browse the repository at this point in the history
1. Added an option to set commission in percentage of the contract's value.
2. Added a possibility to use fractional values for custom leverage and symbol leverage.
3. Added an option to surpass the broker's maximum position with multiple trades (SurpassBrokerMaxPositionSize).
4. Added an option to apply SL/TP to market execution mode trades only after all positions are opened (MarketModeApplySLTPAfterAllTradesExecuted).
5. Added an option to limit maximum total risk per pair or overall.
6. Added support for trade execution when the Position Sizer is attached to a custom symbol in MT5. The actual symbol for trading is set via the TradeSymbol input parameter.
7. Added a warning when broker has tick value set to zero for a Forex trading instrument.
8. Added a hotkey setting (SwitchHideShowLinesHotKey) to hide/show the EA's lines.
9. Added an input parameter (DisableTradingSounds) to disable sounds during trade execution.
10. Added a possibility to use Escape, Tab, Backspace, and Caps Lock keys for panel hotkeys.
11. Added a new hotkey setting (SwitchOrderTypeHotKey) to quickly switch order type.
12. Added quick buttons to modify Entry, Stop-loss, Take-profit, and Stop price values.
13. Added a possibility to add and remove additional take-profits directly on the panel.
14. Added a panel button to quickly populate take-profit volume shares based on three different schemes: equal, descending, ascending.
15. Added the Stop limit line label to show the distance from Entry.
16. Added an option to switch the spread display from points to stop-loss ratio via the ShowSpread input parameter.
17. Added a setting (DisableStopLimit) to disable the Stop limit order type selection when switching via the 'Order type' button.
18. Changed the trading function to check the symbol's execution mode only if the relevant input parameter (IgnoreMarketExecutionMode) is set to false.
19. Changed the 'All symbols' checkbox to apply to 'Max # of trades', 'Max total volume', and 'Max total risk' fields simultaneously.
20. Changed the margin currency display to switch to the currency pair's base currency when conversion to the account currency is impossible.
21. Changed the 'Ignore orders without stop-loss/take-profit' checkbox to two separate checkboxes: 'Ignore orders without stop-loss' and 'Ignore orders without take-profit'.
22. Fixed the algorithm for trading volume distribution between multiple TP trades on trade execution.
23. Fixed a bug that would cause stop-loss to sometimes reset to zero.
24. Fixed a bug that was causing some panel edit values to reset to previous value after changing them.
25. Fixed a bug that resulted in a failing trade execution following a switch from a currency pair with Stop Limit order type to another pair.
26. Fixed a bug that caused the open trade's commentary to be "PS EA" despite empty the empty Order commentary field.
27. Fixed a bug that caused wrong values in volume shares after changing the TakeProfitsNumber input parameter.
28. Fixed a bug that resulted in the take-profit line not disappearing even after setting TP to zero.
29. Fixed the ATR timeframe button to remain in the Current state when the default ATR timeframe is set to Current.
30. Fixed a bug that would sometimes cause SL/TP lines to snap back when dragging them in the ATR mode.
31. Fixed a bug that would deselect SL/TP/Entry lines on chart template change.
32. Fixed a bug with lines re-appearing on platform profile change even if the 'Hide lines' button was pressed.
33. Fixed rounding issues with the risk value in the additional stop-loss label.
34. Fixed a bug with incorrect processing of the situation when Stop-loss is equal to Entry.
35. Fixed the default PositionSize input parameter to make it override the percentage Risk setting.
36. Fixed incorrect volume calculation that could sometimes occur on the Risk tab in MT5.
37. Fixed a bug that caused the 'Do not apply take-profit' checkbox to be ignored.
38. Fixed a minor bug that would sometimes cause line labels to freeze on the chart.
39. Fixed a bug that would sometimes cause the EA initialization to fail in MT5.
40. Improved currency conversion for calculations in MT5.
41. Optimized the EA initialization and deinitialization phases to significantly improve the loading speed when switching the chart symbol.
42. Removed the PanelOnTopOfChart input parameter. Use the 'Chart on foreground' checkbox in the chart's settings instead.
  • Loading branch information
EarnForex authored Mar 29, 2023
1 parent bb39549 commit 45e7c67
Show file tree
Hide file tree
Showing 8 changed files with 4,272 additions and 1,981 deletions.
59 changes: 56 additions & 3 deletions MQL4/Experts/Position Sizer/Defines.mqh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//+------------------------------------------------------------------+
//| Defines.mqh |
//| Copyright © 2022, EarnForex.com |
//| Copyright © 2023, EarnForex.com |
//| https://www.earnforex.com/ |
//+------------------------------------------------------------------+
#include <Controls\Button.mqh>
#include <Controls\Dialog.mqh>
#include <Controls\CheckBox.mqh>
#include <Controls\Label.mqh>
#include <Arrays\List.mqh>

#define CONTROLS_EDIT_COLOR_ENABLE C'255,255,255'
#define CONTROLS_EDIT_COLOR_DISABLE C'221,221,211'
Expand Down Expand Up @@ -54,28 +55,58 @@ enum CANDLE_NUMBER
Previous_Candle = 1 // Previous candle
};

enum VOLUME_SHARE_MODE
{
Equal, // Equal shares
Decreasing, // Decreasing shares
Increasing // Increasing shares
};

enum SHOW_SPREAD
{
No,
Points,
Ratio // Spread / SL ratio
};

enum SYMBOL_CHART_CHANGE_REACTION
{
SYMBOL_CHART_CHANGE_EACH_OWN, // Each symbol - own settings
SYMBOL_CHART_CHANGE_HARD_RESET, // Reset to defaults on symbol change
SYMBOL_CHART_CHANGE_KEEP_PANEL // Keep panel as is
};

enum COMMISSION_TYPE
{
COMMISSION_CURRENCY, // Currency units
COMMISSION_PERCENT, // Percentage
};

struct Settings
{
ENTRY_TYPE EntryType;
double EntryLevel;
double StopLossLevel;
double TakeProfitLevel;
int TakeProfitsNumber;
double Risk;
double MoneyRisk;
double CommissionPerLot;
COMMISSION_TYPE CommissionType;
bool UseMoneyInsteadOfPercentage;
bool RiskFromPositionSize;
double PositionSize; // Used only when RiskFromPositionSize == true.
ACCOUNT_BUTTON AccountButton;
double CustomBalance;
bool DeleteLines;
bool CountPendingOrders;
bool IgnoreOrdersWithoutStopLoss;
bool IgnoreOrdersWithoutSL;
bool IgnoreOrdersWithoutTP;
bool IgnoreOtherSymbols;
bool HideAccSize;
bool ShowLines;
TABS SelectedTab;
int CustomLeverage;
double CustomLeverage;
int MagicNumber;
string Commentary;
bool DisableTradingWhenLinesAreHidden;
Expand All @@ -102,6 +133,7 @@ struct Settings
int BreakEvenPoints;
int MaxNumberOfTrades;
bool AllSymbols;
double MaxTotalRisk;
// For ATR:
int ATRPeriod;
double ATRMultiplierSL;
Expand All @@ -117,5 +149,26 @@ struct Settings
// Panel states:
bool IsPanelMinimized;
bool TPLockedOnSL;
VOLUME_SHARE_MODE ShareVolumeMode;
bool TemplateChanged;
} sets;

// An object class for a list of panel objects with their names for fields located on a given tab of the panel. There will be one list per tab.
class CStringForList : public CObject
{
public:
string Name;
CWnd* Obj;
bool Hidden; // Used only in the Trading tab to avoid deleting the extra TPs but keep them hidden after removal.
CStringForList() {Hidden = false;}
};

class CPanelList : public CList
{
public:
void DeleteListElementByName(const string name);
void MoveListElementByName(const string name, const int index);
void CreateListElementByName(CObject &obj, const string name);
void SetHiddenByName(const string name, const bool hidden);
};
//+------------------------------------------------------------------+
Loading

0 comments on commit 45e7c67

Please sign in to comment.