Page 1893 of 2170

Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 2:14 pm
by sadd

Code: Select all

//------------------------------------------------------------------------------------------
// inputs

src0   = input(title = "Source Input"                    , defval = close)
ch     = input(title = "Oscillator Choice"               , defval="Fisher", options=["Fisher", "IFT", "RSI", "Stoch", "RSI Stoch", "TSI", "CCI", "CMO", "MFI", "MOM", "WPR"])
period = input(title = "Main Period"                     , defval = 13)
variab = input(title = "% Variability around Main Period", defval = 15)

//------------------------------------------------------------------------------------------
// calculation of 4 periods around the main one, considering the variability input

p1 = int(period * (100 - variab      ) / 100) < period - 2 ?  period - 2 : int(period * (100 - variab      ) / 100) 
p2 = int(period * (100 - 2*variab / 3) / 100) < period - 1 ?  period - 1 : int(period * (100 - 2*variab / 3) / 100) 
p3 = int(period * (100 - 2*variab / 3) / 100) < period + 1 ?  period + 1 : int(period * (100 - 2*variab / 3) / 100) 
p4 = int(period * (100 + variab      ) / 100) < period + 2 ?  period + 2 : int(period * (100 - variab      ) / 100) 

//------------------------------------------------------------------------------------------
// functions

// Fisher transform
fsh(_src, _p) =>
    high_ = highest(_src, _p)
    low_  = lowest (_src, _p)
    value = 0.0
    value := (.66 * ((_src - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1])) > .99 ? .999 : (.66 * ((_src - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1])) < -.99 ? -.999 : (.66 * ((_src - low_) / max(high_ - low_, .001) - .5) + .67 * nz(value[1]))
    value1 = 0.0
    value1 := .5 * log((1 + value) / max(1 - value, .001)) + .5 * nz(value1[1])

// Inverse Fisher transform of RSI
IFTRSI(_src, _p) =>
    v2 = ema(0.1 * (rsi(_src, _p) - 50), 3)
    IFT_rsi = 100* (exp(2 * v2) - 1) / (exp(2 * v2) + 1)

// RSI Stoch
rst(_src, _p) =>
    _r = rsi(_src, _p)
    rsistoch = 100*(_r - lowest(_r, _p)) / (highest(_r, _p) - lowest(_r, _p))

// Applying the oscillator of your choice    
Choose_Osc(_src, _p) =>
    ch == "Fisher" ? fsh(_src,_p)                                   :
         ch == "IFT" ? IFTRSI(_src, _p)                             :
             ch == "RSI" ? rsi(_src,_p)                             : 
                 ch == "Stoch"? stoch(_src,_src,_src,_p)            : 
                     ch == "RSI Stoch" ? rst(_src,_p)               : 
                         ch == "TSI"? tsi(_src,_p,_p)               :
                             ch == "CCI" ? cci(_src,_p)             : 
                                 ch == "CMO" ? cmo(_src,_p)         : 
                                     ch == "MFI" ? mfi(_src,_p)     :
                                         ch == "MOM" ? mom(_src,_p) : 
                                             ch == "WPR" ? wpr(_p)  : 
                                                 0  

//  Calculate upper/lower/midlines to plot dependind on the chosen oscillator                                             
Choose_Lns(_ch) =>
    _mid   = _ch == "Fisher" or _ch == "CMO" or _ch == "TSI" or _ch == "MOM" or _ch == "CCI"  or _ch == "IFT" ? 0 : _ch == "RSI" or _ch == "Stoch" or _ch == "RSI Stoch" or _ch == "MFI" ? 50 : _ch == "WPR" ? -50 : 0
    _lwlev = _ch == "Fisher" ? -2 : _ch == "CCI" ? -100 : _ch == "RSI" ? 30 : _ch == "Stoch" or _ch == "RSI Stoch" or _ch == "MFI" ? 20 : _ch == "WPR" ? -80 : 0
    _uplev = _ch == "Fisher" ?  2 : _ch == "CCI" ?  100 : _ch == "RSI" ? 70 : _ch == "Stoch" or _ch == "RSI Stoch" or _ch == "MFI" ? 80 : _ch == "WPR" ? -20 : 0
    _lwlim = _ch == "RSI" or _ch == "Stoch" or _ch == "RSI Stoch" or _ch == "MFI" ?   0 : _ch == "WPR" or _ch == "IFT" ? -100 : 0
    _uplim = _ch == "RSI" or _ch == "Stoch" or _ch == "RSI Stoch" or _ch == "MFI" ? 100 : _ch == "WPR" or _ch == "IFT" ?  100 : 0
    [_mid, _lwlev, _uplev, _lwlim, _uplim]
    
// Heikin Ashi function. All credits to allanster: https://www.tradingview.com/script/HtNYMuBO-Heikin-Ashi-Source-Function/, slightly modified to allow for different inputs
HA(_o, _h, _l, _c, _src)  => 
    Close  = (_o + _h + _l + _c) / 4
    Open   = float(na)
    Open  := na(Open[1]) ? (_o + _c) / 2 : (nz(Open[1]) + nz(Close[1])) / 2
    High   = max(_h, max(Open, Close))
    Low    = min(_l, min(Open, Close))
    HL2    = avg(High, Low)  
    HLC3   = avg(High, Low, Close) 
    OHLC4  = avg(Open, High, Low, Close)
    Price  = _src == 'close' ? Close : _src == 'open' ? Open : _src == 'high' ? High : _src == 'low' ? Low : _src == 'hl2' ? HL2 : _src == 'hlc3' ? HLC3 : OHLC4  
    
//------------------------------------------------------------------------------------------
// HeikinAshi calcs

heikinarray = array.new_float(0,0)

array.push(heikinarray, Choose_Osc(src0, p1))
array.push(heikinarray, Choose_Osc(src0, p2))
array.push(heikinarray, Choose_Osc(src0, p3))
array.push(heikinarray, Choose_Osc(src0, p4))
array.sort(heikinarray, order.descending)

//ohlc
h  = array.get(heikinarray,0)
c  = array.get(heikinarray,1)
o  = array.get(heikinarray,2)
l  = array.get(heikinarray,3)

hi = HA(o, h, l, c, 'high' )
cl = HA(o, h, l, c, 'close')
op = HA(o, h, l, c, 'open' )
lo = HA(o, h, l, c, 'low'  )

//------------------------------------------------------------------------------------------
// Plots

barColor   = cl > op ? #26a69a : #ef5350  

plotcandle(op, hi, lo, cl, title = "", color = barColor, wickcolor = barColor, bordercolor = barColor)  

[mid, lwlev, uplev, lwlim, uplim] = Choose_Lns(ch)

plot(mid  , color = color.silver)
plot(lwlev, color = color.silver)
plot(uplev, color = color.silver)
plot(lwlim, color = color.silver, linewidth = 2)
plot(uplim, color = color.silver, linewidth = 2)

//------------------------------------------------------------------------------------------

Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 2:52 pm
by Jedidiah
sadd wrote: Thu Jul 13, 2023 12:12 pm Okay, I'm using a translation that doesn't quite understand what it means
你如果不发源代码的话,我们的编码员无法确定是否帮你转化成MT4
If you don't send the source code, our coders can't determine whether to convert it to MT4 for you

如果你不积极的为论坛做贡献的话,你的账户存在永久禁止的风险

不分享的行为,违背了论坛宗旨。你了明白吗?
拒绝一切自私的行为。
世界上没有免费的午餐。
天上不会掉馅饼

viewtopic.php?f=579500&t=8472780

Members must make an effort to be active, contribute or share when possible.
Low-quality posts such as:
Spamming
"Begging"
Linking to outside file sources
Repeatedly requesting for free files and modifications without actively participating in other topics or contributing to the forum in other ways will result in your account being permanently banned. See: Why was I banned from Forex Station?

Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 3:19 pm
by ParallelNative
I wanted to share my favorite indicator on Trading View

Dynamic Linear Regression Channels

Image


Also has a setting to input what deviation you want to display.

Image


It would be amazing to see this on mt4 in addition to the already amazing indicators produced on this forum. Best wishes,

Code: Select all

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

Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 3:41 pm
by RplusT
ParallelNative wrote: Thu Jul 13, 2023 3:19 pm I wanted to share my favorite indicator on Trading View

Dynamic Linear Regression Channels

Image
[

There's something like this available here. You probably know it. It's not bad, but of what I can see on your chart, it would come close to what I actually want to see. Thanks for posting.



Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 7:41 pm
by ffsss
ParallelNative wrote: Thu Jul 13, 2023 3:19 pm I wanted to share my favorite indicator on Trading View

Dynamic Linear Regression Channels

Image


Also has a setting to input what deviation you want to display.

Image


It would be amazing to see this on mt4 in addition to the already amazing indicators produced on this forum. Best wishes,

Code: Select all

//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])
Does it repaint?

Re: MT4 Indicator requests and ideas

Posted: Thu Jul 13, 2023 11:43 pm
by halkinho
Hi, have way for get this indicator non repaint?

I mean appear the Box blue only when confirm the breakout on donchian, because i saw today appeared one box BLUE and after the movement go down its disappeared...

Only on box BLUE and RED i don't want to repaint will be good if have way...
Image

Re: MT4 Indicator requests and ideas

Posted: Fri Jul 14, 2023 1:51 am
by ffsss
mrtools wrote: Mon Jul 10, 2023 4:04 am Posted a version here
Hi, would it be possible to make a indicator similiar to this (this one only shows buy arrows and my terminal freezes.)
bilbao wrote: Fri Aug 23, 2019 6:44 pm arrow= WPR+RSI+CCI
Image

Image

Image

Image

Image
Image
There is a v5 version working correctly, but this one includes mfi, demarker etc and dont have a disalbe option for those ones.

Re: MT4 Indicator requests and ideas

Posted: Fri Jul 14, 2023 2:23 am
by sadd
mrtools wrote: Thu Jul 13, 2023 4:22 am Some stuff I am able to translate, some not, kind of depends on the code, you can post the code here, just make sure and put it in the code brackets.
Hi dear programmer, I have translated the source code using AI, but it still needs improvement. Can you help me

Re: MT4 Indicator requests and ideas

Posted: Fri Jul 14, 2023 4:02 am
by mrtools
ffsss wrote: Fri Jul 14, 2023 1:51 am Hi, would it be possible to make a indicator similiar to this (this one only shows buy arrows and my terminal freezes.)


Image
There is a v5 version working correctly, but this one includes mfi, demarker etc and dont have a disalbe option for those ones.
Would need more information about the code to be able to do that.

Re: MT4 Indicator requests and ideas

Posted: Fri Jul 14, 2023 4:47 am
by dmnik
mrtools wrote: Fri Jul 14, 2023 4:02 am Would need more information about the code to be able to do that.
maybe this source code will be helpful?