2025-11-28 20:22:05 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| Ea.mq5 |
|
| | | //| Copyright 2025, Niquel Mendoza. |
|
| | | //| https://www.mql5.com/es/users/nique_372/news |
|
| | | //+------------------------------------------------------------------+
|
| | | #property copyright "Copyright 2025, Niquel Mendoza."
|
| | | #property link "https://www.mql5.com/es/users/nique_372/news"
|
| | | #property version "1.00"
|
| | | #property strict
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-10-29 20:10:16 -05:00 | | | //| Include |
|
2025-11-28 20:22:05 -05:00 | | | //+------------------------------------------------------------------+
|
| | | #include "Main.mqh"
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-10-29 20:10:16 -05:00 | | | //| Inputs |
|
| | | //+------------------------------------------------------------------+
|
| | | sinput group ""
|
| | | sinput group "-------| Account Status |-------"
|
| | | input ENUM_VERBOSE_LOG_LEVEL InpLogLevelAccountStatus = VERBOSE_LOG_LEVEL_ALL; //(Account Status|Ticket Mangement) log level:
|
| | |
|
| | | sinput group ""
|
| | | sinput group "-------| Breakeven |-------"
|
| | | input TSN::ENUM_BREAKEVEN_TYPE InpBeType = TSN::BREAKEVEN_TYPE_RR; // Calculation method (RR, ATR, or fixed points)
|
| | | input ENUM_VERBOSE_LOG_LEVEL InpBeLogLevel = VERBOSE_LOG_LEVEL_ALL; // Break Even log level:
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | sinput group "--- Breakeven based on Risk/Reward (RR) ---"
|
| | | input string InpBeRrAdv = "Requires a configured Stop Loss."; // Warning: Stop Loss is required to calculate RR
|
| | | input double InpBeRrRatio = 1.0; // Risk/Reward ratio to activate Breakeven (e.g. 1.0)
|
| | | input TSN::ENUM_TYPE_EXTRA_BE_BY_RRR InpBeRrTypeExtra = TSN::EXTRA_BE_RRR_BY_ATR;// Method to adjust Breakeven price (ATR or points)
|
| | | input double InpBeRrExtraPointsOrAtrMultiplier = 1.0; // Adjustment value: ATR multiplier (atr 14 period) if method = ATR, or fixed points if method = Points
|
| | |
|
| | | sinput group "--- Breakeven based solely on ATR ---"
|
| | | input double InpBeAtrMultiplier = 2.0; // ATR multiplier to trigger Breakeven (atr 14 period)
|
| | | input double InpBeAtrMultiplierExtra = 1.0; // Additional multiplier for precise Breakeven adjustment (atr 14 period)
|
| | |
|
| | | sinput group "--- Breakeven based on fixed points ---"
|
| | | input int InpBeFixedPointsToPutBe = 200; // Minimum distance (in points) to trigger Breakeven
|
| | | input int InpBeFixedPointsExtra = 100; // Extra points added when Breakeven is triggered
|
| | |
|
2025-11-28 20:22:05 -05:00 | | | //+------------------------------------------------------------------+
|
2026-10-29 20:10:16 -05:00 | | | //| Global variables |
|
| | | //+------------------------------------------------------------------+
|
| | | CBreakEvenPanel g_app;
|
| | | TSN::CAtrOptimizedZero g_atr_ultra_optimized(_Period, _Symbol, 14);
|
2025-11-28 20:22:05 -05:00 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert initialization function |
|
| | | //+------------------------------------------------------------------+
|
| | | int OnInit()
|
| | | {
|
| | | //---
|
2026-10-29 20:10:16 -05:00 | | | g_breakeven_creator.SetBeByAtr(InpBeAtrMultiplier, InpBeAtrMultiplierExtra, GetPointer(g_atr_ultra_optimized));
|
| | | g_breakeven_creator.SetBeByFixedPoints(InpBeFixedPointsToPutBe, InpBeFixedPointsExtra);
|
| | | g_breakeven_creator.SetBeByRR(InpBeRrRatio, InpBeRrTypeExtra, InpBeRrExtraPointsOrAtrMultiplier, GetPointer(g_atr_ultra_optimized));
|
| | |
|
| | | //--- Panel
|
2025-11-28 20:22:05 -05:00 | | | const int width = 500;
|
| | | const int height = 390;
|
2026-10-29 20:10:16 -05:00 | | | g_app.CreateGUI(width, height, InpBeType);
|
2025-11-28 20:22:05 -05:00 | | |
|
2026-10-29 20:10:16 -05:00 | | | //--- Account status
|
2026-09-13 08:47:52 -05:00 | | | TSN::account_status.AddLogFlags(InpLogLevelAccountStatus);
|
| | | TSN::account_status.OnInitEvent();
|
2025-11-28 20:22:05 -05:00 | | |
|
2026-01-31 19:44:40 -05:00 | | | //---
|
2026-09-13 08:47:52 -05:00 | | | CAutoCleaner::AddFunction(TSN::CAccountStatus_Deinit);
|
2026-10-29 20:10:16 -05:00 | | | CAutoCleaner::AddFunction(CBasicEvents::Deinit);
|
2026-01-31 19:44:40 -05:00 | | |
|
2025-11-28 20:22:05 -05:00 | | | //---
|
| | | return(INIT_SUCCEEDED);
|
| | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert deinitialization function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnDeinit(const int reason)
|
| | | {
|
| | | //---
|
2026-10-29 20:10:16 -05:00 | | | g_app.OnDeinitEvent(reason);
|
2026-01-31 19:44:40 -05:00 | | | CAutoCleaner::Deinit(reason);
|
2025-11-28 20:22:05 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| Expert tick function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnTick()
|
| | | {
|
2026-10-29 20:10:16 -05:00 | | | g_app.OnTickEvent();
|
2025-11-28 20:22:05 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| TradeTransaction function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnTradeTransaction(const MqlTradeTransaction& trans,
|
| | | const MqlTradeRequest& request,
|
| | | const MqlTradeResult& result)
|
| | | {
|
| | | //---
|
2026-09-13 08:47:52 -05:00 | | | TSN::account_status.OnTradeTransactionEvent(trans);
|
2025-11-28 20:22:05 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| ChartEvent function |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnChartEvent(const int id,
|
| | | const long &lparam,
|
| | | const double &dparam,
|
| | | const string &sparam)
|
| | | {
|
| | | //---
|
2026-10-29 20:10:16 -05:00 | | | g_app.ChartEvent(id, lparam, dparam, sparam);
|
2025-11-28 20:22:05 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | void OnTimer()
|
| | | {
|
2026-10-29 20:10:16 -05:00 | | | g_app.OnTimerEvent();
|
2025-11-28 20:22:05 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|