Theil_Sen Indicator Free - MetaTrader 4 Script | Forex Indicator Download - MT4/MT5 Resource








This is essentially a tool that estimates the general trajectory of a line drawn from a collection of data points. The estimated line is derived by first performing a regression on a range of values and then calculating the slope of the resulting regression line. Dataset selection can be Simple Moving Average, Exponential Moving Average, Close Price, High/Low Price, which are automatically collected from MetaTrader charts. You simply select a type of data to collect. It supports multiple currencies.
iTSlope(asymbol,timeframe,regperiod,adataset,rmp,rtc,slope,line_nickname,enable_text,ashift); //This is the main function used in EA. Just enter your own parameters. //Manual traders can use this or use the indicator directly.
As usual this supports multiple currencies and I have included the "BreakPoint" tool here but it is not required for the indicator itself.
This is what a trendline looks like in a range market:
Now, this is what a trendline looks like in a trending market:
Here is a demo of Expert Advisor:
//+------------------------------------------------------------------+ //| demo.mq4 | //| Copyright 2020, Everyone Software Company | //| https://anywhere.com | //+------------------------------------------------------------------+ #Property Copyright "Copyright 2020, Everybody Software Corp." #property associated with "https://anywhere.com" # Property version "1.00" #propertystrict #include#Include <breakpoint.mqh> //<--- not required //+------------------------------------------------------------------+ //|Expert initialization function | //+------------------------------------------------------------------+ Integer initialization () { Return ( initialization successful ); } //+------------------------------------------------------------------+ //|Expert to initialize function | //+------------------------------------------------------------------+ Blank solution initialization ( constant integer reason) { } //+------------------------------------------------------------------+ //|Expert check function | //+------------------------------------------------------------------+ Blank check () { //---------These variables are created empty, but they will contain data after using iTSlop() below. -----// Double slope = 0 ; //Slope of the regression line. ENUM_TIMEFRAMES time range = 0 ; //This is the time range of the symbol. 0 represents the current chart time frame. Integer regular period = 20 , //Regression period. How many bars do you want to perform the regression on. shift = 1 ; //The offset of the bar where you want to draw the regression line. string unsigned = "" , //This is the symbol/currency pair on which you want to perform calculations. "" indicates the current symbol. Dataset = "ema_off" , //The data type to perform regression. Line Nickname = "Anything goes here" , Rotate MP, //The calculated "Market Phase", which is a specific description of the market Real Time Clock; //The calculated "Market Trend", which is a general description of the market. Boolean enabled text = true ; //When set = true, text data is displayed on the current chart. iTSlope(asymbol,timeframe,regperiod,adataset,rmp,rtc,slope,line_nickname,enable_text,ashift);//Single currency//if(rmp == "trend")BreakPoint("","","",true,"rmp",rmp,"rtc",rtc,"asymbol",asymbol); } //+------------------------------------------------------------------+
Special thanks to whroeder and others who helped clarify this concept.
Attachment download
📎 theilsen_indicator_free.mqh (14.67 KB)
📎 breakpoint.mqh (9.69 KB)
📎 theilsen_gradient.mq4 (20.4 KB)
Source: MQL5 #30810
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •