// SPDX-License-Identifier: MIT // Copyright (c) 2026 WickAtlas. MIT-licensed; provided "AS IS", without warranty. // Version 1.0.0 | Released 2026-08-13 | Platform: MetaTrader 4 / MQL4 build 600+ // Defaults: RSI 14 on close; research levels 40, 50 and 60. Indicator only; no external access. #property strict #property copyright "WickAtlas" #property link "https://wickatlas.com/downloads" #property version "1.00" #property description "RSI with 40, 50 and 60 research regime levels." #property description "Regime levels are references, not order prompts." #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 1 #property indicator_color1 clrMediumSeaGreen #property indicator_level1 40.0 #property indicator_level2 50.0 #property indicator_level3 60.0 #property indicator_levelcolor clrSlateGray #property indicator_levelstyle STYLE_DOT input int InpRSIPeriod = 14; input ENUM_APPLIED_PRICE InpAppliedPrice = PRICE_CLOSE; double RSIBuffer[]; int OnInit() { if(InpRSIPeriod<2) return(INIT_PARAMETERS_INCORRECT); if(!SetIndexBuffer(0,RSIBuffer)) return(INIT_FAILED); ArraySetAsSeries(RSIBuffer,true); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,clrMediumSeaGreen); SetIndexLabel(0,"RSI"); SetIndexEmptyValue(0,EMPTY_VALUE); SetIndexDrawBegin(0,InpRSIPeriod); IndicatorShortName("WickAtlas RSI Regime ("+IntegerToString(InpRSIPeriod)+")"); IndicatorDigits(2); return(INIT_SUCCEEDED); } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(rates_total<=InpRSIPeriod) return(0); int oldest=rates_total-InpRSIPeriod; int first=(prev_calculated==0 || prev_calculated>rates_total) ? oldest : MathMin(rates_total-prev_calculated+1,oldest); if(prev_calculated==0) ArrayInitialize(RSIBuffer,EMPTY_VALUE); for(int i=first;i>=0;i--) { ResetLastError(); double rsiValue=iRSI(NULL,0,InpRSIPeriod,InpAppliedPrice,i); int rsiError=GetLastError(); RSIBuffer[i]=(rsiError==0 && rsiValue!=EMPTY_VALUE) ? rsiValue : EMPTY_VALUE; } return(rates_total); }