| //+------------------------------------------------------------------+
|
| //| ResistenceSupport.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
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| #define DEFGLOBAL_SIMPLE
|
| #include "..\\..\\DefGlobal.mqh"
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| sinput group "-----| Support and Resistance |-----"
|
| input ENUM_TIMEFRAMES timeframe_s_r = PERIOD_CURRENT; // Support and resistance timeframe
|
| input int range_obt_s_r = 500; // Detection range
|
|
|
| sinput group ""
|
| sinput group "-----| Graphic Objects |-----"
|
| input int width_s_r_lines = 1; // S/R lines width
|
| input ENUM_LINE_STYLE style_lines_s_r = STYLE_SOLID; // S/R lines style
|
| input color color_resistencia = clrBlue; // Resistance line color
|
| input color color_soporte = clrRed; // Support line color
|
| input string font_sr = "Trebuchet MS"; // Text font
|
| input int8_t font_size_sr = 8; // Text size
|
|
|
|
|
| sinput group ""
|
| sinput group "-----| Detection |-----"
|
| input int8_t min_toques_s_r = 2; // Minimum touches
|
| input int16_t max_toques_s_tr = 5; // Maximum touches to invalidate S/R
|
| input int16_t periodo_maximo_minimo = 12; // Maximum/minimum period
|
|
|
| sinput group "--- Maximum difference for reversal"
|
| input TSN::ENUM_MODE_DIFF modo_diff_inverse_s_r = TSN::MODE_DIFF_BY_ATR; // Mode to calculate minimum difference for reversal
|
| input double atr_multiplier_s_r_inverse_or_points = 0.95; // ATR multiplier (14 periods) or fixed points
|
|
|
| sinput group "--- Maximum difference to find matching highs/lows"
|
| input TSN::ENUM_MODE_DIFF modo_diff_range_s_r = TSN::MODE_DIFF_BY_ATR; // Mode to calculate minimum difference for matching
|
| input double atr_multiplier_s_r_range_or_points = 0.95; // ATR multiplier (14 periods) or fixed points
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| |
|
| //+------------------------------------------------------------------+
|
| int8_t idx_controler_d1 = INVALID_INDEX;
|
| CResistenceSupport g_res_sop;
|
|
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert initialization function |
|
| //+------------------------------------------------------------------+
|
| int OnInit()
|
| {
|
| //---
|
| g_new_bar_manager.GetPosExecute(PERIOD_D1, idx_controler_d1);
|
| //---
|
| const int handle_pos_atr = ICTAtr_Create(_Period, _Symbol, 14, true);
|
| TSN::CAtr* atr_ptr = ICTAtr_GetAtrPointer(handle_pos_atr);
|
|
|
| //--- Creacion
|
| g_res_sop.Create(_Symbol, _Period, 0, 0, true); // Creacion
|
| g_res_sop.SetDiffInverse(TSN::CreateDiffptr(modo_diff_inverse_s_r, _Symbol, atr_ptr, 1, atr_multiplier_s_r_inverse_or_points)); // Seteo nueva diferenica
|
| g_res_sop.SetDiffMaxDiffRange(TSN::CreateDiffptr(modo_diff_range_s_r, _Symbol, atr_ptr, 1, atr_multiplier_s_r_range_or_points)); // Maxima diferencia en rango
|
| g_res_sop.SetGrapich(color_resistencia, color_soporte, style_lines_s_r, width_s_r_lines, font_size_sr, font_sr); // Seteo grafico
|
| g_res_sop.SetProperties(min_toques_s_r, max_toques_s_tr, periodo_maximo_minimo, PURE_SWINGS, range_obt_s_r); // Seteo de propiedades
|
|
|
| //---
|
| return(INIT_SUCCEEDED);
|
| }
|
| //+------------------------------------------------------------------+
|
| //| Expert deinitialization function |
|
| //+------------------------------------------------------------------+
|
| void OnDeinit(const int reason)
|
| {
|
| //---
|
| ICTGen_OnDeinitEvent(reason);
|
| }
|
| //+------------------------------------------------------------------+
|
| //| Expert tick function |
|
| //+------------------------------------------------------------------+
|
| void OnTick()
|
| {
|
| //---
|
| const datetime curr_time = TimeCurrent();
|
| g_new_bar_manager.Execute(curr_time);
|
|
|
| //---
|
| if(CNewBarManager_IsNewBarM1(g_new_bar_manager))
|
| {
|
| const bool new_day = CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_d1);
|
| ICTGen_FuncionOnBarM1(new_day, curr_time);
|
| g_res_sop.OnNewBar();
|
| }
|
| }
|
| //+------------------------------------------------------------------+
|