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

MQL5 指标

工作已完成

执行时间8 小时
客户反馈
Very smooth experience, great communication and professional.
员工反馈
Great and professional customer! Thanks so much! 🤝🤝🤝

指定

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])

反馈

1
开发者 1
等级
(845)
项目
1448
72%
仲裁
119
29% / 47%
逾期
355
25%
已载入
发布者: 3 文章
2
开发者 2
等级
(104)
项目
134
43%
仲裁
0
逾期
3
2%
工作中
相似订单
Would it be possible to connect Futures prop firm with Rithmic or Tradeovate platform to Ninjatrader automated trading ? If anyone can do this for me I will be happy to get started with the person right away
I have a open source Tradingview indicator that I want it to be converted to Ninja Trader8. I have attached it. Please let me know, if you can do it and for how muc
Looking for a momentum indicator that will show when market has momentum and is making the big moves will want to see screenshots of it before deposit so I know what I'm paying for. Of thr developer can bring a good strategy for the indicator I'll refer him other jobs and other traders. Please don't apply and than dissappear apply and tell me your approach to tackling this project
I need help in modifying an amibroker AFL indicator the indicator already works but I need per symbol static variable isolation, parameters persistence per symbol after restart, non declining trailing stop logic, parameter auto restore when switching symbols and a global reset function for static variables. For better understanding As discussed, this is the official offer for restructuring my RAD Chandelier stop loss
Hi , I have some indicators that I want set up on my TV chart and want to create one chart for some and another chart for some others. Plus I want to set up the brackets orders so I can trade from the chart. I have these set up somewhat but need it cleaned up and the way I want them. how much would something like this cost to do? I'm in California and would like you to show me so I can learn to do this when I want to
I would love to see most of my trades going well being in profits! & keep consistent trading without having to blow any accounts be able to identify right trades and have good trading strategy
hi, code me indicator based on 3 candles rejection - need the sourcecode - need to work on all timeframe - non repaint - alert and draws arrows on next candle - draw lines on previous candles - set time window (allowed time to show arrows+alert) - someone with good reputation and able to provide proof of the past works (devs with more than 100 jobs preferably) - you will need to provide sample before accepting u as
Martingale Strategy 50 - 70 USD
I need a gambling bot that implements the Martingale Strategy for betting on roulette. It will be used on platforms like Betcity and Unibet to manage bets effectively. Scope of work - Develop a bot that implements the Martingale Strategy for roulette. - Ensure compatibility with Betcity and Unibet platforms. - Include functionalities for adjusting bet size and managing losses. - Integrate platform-specific features
I need a hft bot that works well on live market. I have tested some bot and they only perform on demo market. If you have any one that is profitable in the live market, pls send a message. I will need to test it before paying. Pls make sure the bot is profitable in LIVE MARKET
Hello there Hpe you are doing good I am in search of a pine script expert developer who can build strategy in apudFlow in pinescript. Kinldy bid on this project if you can do this

项目信息

预算
30+ USD
截止日期
 1  5 天