2025-12-09 13:32:01 -05:00
//+------------------------------------------------------------------+
//| 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
2026-02-01 13:11:51 -05:00
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
//| |
//+------------------------------------------------------------------+
# define DEFGLOBAL_SIMPLE
2026-01-06 06:46:34 -05:00
# include "..\\..\\DefGlobal.mqh"
2025-12-09 13:32:01 -05:00
2026-02-01 13:11:51 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2025-12-09 13:32:01 -05:00
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 "
2026-10-23 21:51:38 -05:00
input TSN : : ENUM_MODE_DIFF modo_diff_inverse_s_r = TSN : : MODE_DIFF_BY_ATR ; // Mode to calculate minimum difference for reversal
2025-12-09 13:32:01 -05:00
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 "
2026-10-23 21:51:38 -05:00
input TSN : : ENUM_MODE_DIFF modo_diff_range_s_r = TSN : : MODE_DIFF_BY_ATR ; // Mode to calculate minimum difference for matching
2025-12-09 13:32:01 -05:00
input double atr_multiplier_s_r_range_or_points = 0.95 ; // ATR multiplier (14 periods) or fixed points
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
2026-01-06 06:46:34 -05:00
int8_t idx_controler_d1 = INVALID_INDEX ;
2025-12-09 13:32:01 -05:00
CResistenceSupport g_res_sop ;
2026-01-06 06:46:34 -05:00
2025-12-09 13:32:01 -05:00
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ( )
{
2026-01-06 06:46:34 -05:00
//---
g_new_bar_manager . GetPosExecute ( PERIOD_D1 , idx_controler_d1 ) ;
//---
2025-12-09 13:32:01 -05:00
const int handle_pos_atr = ICTAtr_Create ( _Period , _Symbol , 14 , true ) ;
2026-10-23 21:51:38 -05:00
TSN : : CAtr * atr_ptr = ICTAtr_GetAtrPointer ( handle_pos_atr ) ;
2026-01-06 06:46:34 -05:00
2025-12-09 13:32:01 -05:00
//--- Creacion
g_res_sop . Create ( _Symbol , _Period , 0 , 0 , true ) ; // Creacion
2026-10-23 21:51:38 -05:00
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
2025-12-09 13:32:01 -05:00
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 )
{
//---
2026-02-01 13:11:51 -05:00
ICTGen_OnDeinitEvent ( reason ) ;
2025-12-09 13:32:01 -05:00
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ( )
{
//---
const datetime curr_time = TimeCurrent ( ) ;
2026-01-06 06:46:34 -05:00
g_new_bar_manager . Execute ( curr_time ) ;
2025-12-09 13:32:01 -05:00
//---
2026-01-06 06:46:34 -05:00
if ( CNewBarManager_IsNewBarM1 ( g_new_bar_manager ) )
2025-12-09 13:32:01 -05:00
{
2026-01-06 06:46:34 -05:00
const bool new_day = CNewBarManager_IsNewBar ( g_new_bar_manager , idx_controler_d1 ) ;
ICTGen_FuncionOnBarM1 ( new_day , curr_time ) ;
2025-12-09 13:32:01 -05:00
g_res_sop . OnNewBar ( ) ;
}
}
//+------------------------------------------------------------------+