Conversion of "Dynamic Linear Regression Channels" from TradingView to MQL5 Indicator

MQL5 Göstergeler

İş Gereklilikleri

I am looking to convert the "Dynamic Linear Regression Channels" indicator by Iravan, available on TradingView, into an MQL5 indicator. The original TradingView indicator plots new linear regression channels dynamically from points where a previous channel is broken, adjusting the length of bars in the trend. This is particularly useful for detecting trend changes, identifying support and resistance levels, and trading mean reversions.

The MQL5 indicator should replicate the following key features:

  1. Dynamic linear regression channels that reset from points where the previous channel is broken.
  2. Adjustable upper and lower deviation settings, with a note that higher values might lead to errors if the price never breaks the channel and references more bars than supported by the platform.
  3. Accurate plotting of channels to assist in trend analysis and mean reversion trading strategies.

Please ensure that the MQL5 version functions as closely as possible to the TradingView original, with considerations for any platform-specific limitations or optimizations.

Looking forward to your proposals and any recommendations you might have for enhancing the indicator’s performance on MQL5.


//Base source is cloned from built-in technicals - "Linear Regression Channel", v26


//@version=5

indicator("Dynamic Linear Regression Channels", overlay=true, max_lines_count=500, max_boxes_count=500)


upperMultInput = input.float(2.0, title="Upper Deviation", inline = "Upper Deviation")

colorUpper = input.color(color.new(color.blue, 85), "", inline = "Upper Deviation")

lowerMultInput = input.float(2.0, title="Lower Deviation", inline = "Lower Deviation")

colorLower = input.color(color.new(color.red, 85), "", inline = "Lower Deviation")


calcSlope(source, length) =>

    max_bars_back(source, 5000)

    if barstate.isfirst or length <= 1

        [float(na), float(na), float(na)]

    else

        sumX = 0.0

        sumY = 0.0

        sumXSqr = 0.0

        sumXY = 0.0

        for i = 0 to length - 1 by 1

            val = source[i]

            per = i + 1.0

            sumX += per

            sumY += val

            sumXSqr += per * per

            sumXY += val * per

        slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX)

        average = sumY / length

        intercept = average - slope * sumX / length + slope

        [slope, average, intercept]


var start_index = 1

lengthInput = bar_index -  start_index + 1

[s, a, i] = calcSlope(close, lengthInput)

startPrice = i + s * (lengthInput - 1)

endPrice = i


calcDev(source, length, slope, average, intercept) =>

    if barstate.isfirst or length <= 1

        [float(na), float(na), float(na), float(na)]

    else

        upDev = 0.0

        dnDev = 0.0

        stdDevAcc = 0.0

        dsxx = 0.0

        dsyy = 0.0

        dsxy = 0.0

        periods = length - 1

        daY = intercept + slope * periods / 2

        val = intercept

        for j = 0 to periods by 1

            price = high[j] - val

            if price > upDev

                upDev := price

            price := val - low[j]

            if price > dnDev

                dnDev := price

            price := source[j]

            dxt = price - average

            dyt = val - daY

            price -= val

            stdDevAcc += price * price

            dsxx += dxt * dxt

            dsyy += dyt * dyt

            dsxy += dxt * dyt

            val += slope

        stdDev = math.sqrt(stdDevAcc / (periods == 0 ? 1 : periods))

        pearsonR = dsxx == 0 or dsyy == 0 ? 0 : dsxy / math.sqrt(dsxx * dsyy)

        [stdDev, pearsonR, upDev, dnDev]

    

[stdDev, pearsonR, upDev, dnDev] = calcDev(close, lengthInput, s, a, i)

upperStartPrice = startPrice + upperMultInput * stdDev

upperEndPrice = endPrice + upperMultInput * stdDev

lowerStartPrice = startPrice - lowerMultInput * stdDev

lowerEndPrice = endPrice - lowerMultInput * stdDev


var baseLine = line.new(na, na, na, na, width=1, color=color.new(colorLower, 0))

var upper = line.new(na, na, na, na, width=1, color=color.new(colorUpper, 0))

var lower = line.new(na, na, na, na, width=1, color=color.new(colorUpper, 0))    

linefill.new(upper, baseLine, color = colorUpper)

linefill.new(baseLine, lower, color = colorLower)


if (close > upperEndPrice or close < lowerEndPrice) and (not barstate.islast or barstate.isconfirmed)

    _baseLine = line.new(bar_index - lengthInput + 1, startPrice[1], bar_index - 1, endPrice[1], width=1, color=color.new(colorLower, 0))

    _upper = line.new(bar_index - lengthInput + 1, upperStartPrice[1], bar_index - 1, upperEndPrice[1], width=1, color=color.new(colorUpper, 0))

    _lower = line.new(bar_index - lengthInput + 1, lowerStartPrice[1], bar_index - 1, lowerEndPrice[1], width=1, color=color.new(colorUpper, 0))    

    linefill.new(_upper, _baseLine, color = colorUpper)

    linefill.new(_baseLine, _lower, color = colorLower)

    start_index := bar_index

else if barstate.islast

    j = close > upperEndPrice or close < lowerEndPrice ? 1: 0

    line.set_xy1(baseLine, bar_index - lengthInput + 1, startPrice[j])

    line.set_xy2(baseLine, bar_index - j, endPrice[j])

    line.set_xy1(upper, bar_index - lengthInput + 1, upperStartPrice[j])

    line.set_xy2(upper, bar_index - j, upperEndPrice[j])

    line.set_xy1(lower, bar_index - lengthInput + 1, lowerStartPrice[j])

    line.set_xy2(lower, bar_index - j, lowerEndPrice[j])

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(803)
Projeler
1374
72%
Arabuluculuk
113
28% / 48%
Süresi dolmuş
342
25%
Çalışıyor
2
Geliştirici 2
Derecelendirme
(79)
Projeler
103
38%
Arabuluculuk
0
Süresi dolmuş
3
3%
Çalışıyor
Benzer siparişler
I need a programmer to help me change my entry to my existing EA if you do well for this job I am also looking for long term developers that can help me to complete more EAs. If you have read this description please reply with "Reset"
i want a robot and an indicator that uses macd..bolingerbands And emas As well as fibonacci retracement confirmation from SMC strategy , OB+CHoCH And RTO i want it to print SL and TP using High and Lows
2 indicators 30+ USD
Need 2 visual indicators. Visual examples under attachment. A) indicator shows a price on horizontal trendline and hides it from the price bar. 1)option to configure font size and trendline color; 2)option to choose trendline style; 3)option to choose on what timeframe/s trend lines will appear. B) indicator allows to represent a certain time period on a different background. 1)option to choose on what timeframe it
Hello! I want to convert an existing open source indicator for tradingview to mql5. Its an orderblock indicator also showing horizontal bullish/bearish volume. My expectation of this is the following: The orderblocks will apear on the chart at exactly the same place with top/bottom etc. The bullish and bearish volume is somehow displayed/indicated. (The values of the orderblocks are retrieveable to develop an EA in
Hi, Thanks for looking at my requirement. Here are the details of the job and right now, we do have 2 jobs to do in same file. The clear detailed explanation along with the pictures are in the google drive link : https://drive.google.com/drive/folders/14KMGzunkE-Hbg0eK6iUrs4DNvRetTJYc?usp=sharing Also, i am into this coding thing for more than 2 years now full time. I am a math guy and not a coder. So the
Hello, I need an expert that can help me to develop an EA. That can also work while I open trade on phone, can I get this done? I need video demo and work sample. Thanks
Convert Tradingview indicator Pine Script to MQL4 language ( indicator/EA) Hi , I need a script written for Auto trading bot to trade on Trading View. This is a simple strategy to trade Renko chart on Trading view. The trading bot will have rules for entry and exit. Stop loss and Take Profit. order size by x% of equity. Daily profit target in pips. I want an experienced Trading View Pine script coder please! Thanks
We have an existing EA which use specific strategy based on our propriety Indicator(Semaphores) and Stochastic. The EA is multi symbol and Multi timeframe. we need to fix it for following issues 1 - Check the Status on close of the Candle[1] or open of the Candle[0] 2 - open order with SL which meet specific requirement 3 - Amend order for TP when specific requirement meet. 4 - Update the Scanner as in the picture. 5
Sierrachart 60 - 100 USD
Hi everyone, I have a request for Sierra chart. I already have a number template and I want to know is it a way for you to make adjustments so that 3 vertical numbers that decrease or increase are highlighted
CPI ROBOKING 30+ USD
*Strategy: CPI-Based Trading* *Instruments:* XAUUSD (Gold), UsTech100 (Nasdaq 100), USDJPY *CPI Release:* 1. *Higher-than-expected CPI:* - XAUUSD: SELL (Gold prices may drop due to potential rate hike) - UsTech100: SELL (Tech stocks may drop due to potential rate hike) - USDJPY: BUY (USD may strengthen due to potential rate hike) 2. *Meets or lower-than-expected CPI:* - XAUUSD: BUY (Gold prices may rise due

Proje bilgisi

Bütçe
30+ USD
Son teslim tarihi
from 1 to 5 gün

Müşteri

(2)
Verilmiş siparişler6
Arabuluculuk sayısı0