Re: Already Converted TradingView Indicators to MT4 Indicators

241
dmnik wrote: Mon Feb 06, 2023 9:53 pm This is not an automatic indicator, it is a tool that allows you to analyze the SMC trading system, you must define Bos, CHoch, OB, etc. and so on. This indicator only helps you draw! After pressing the desired button, the object appears on the panel. You can move the object past the white dot by double-clicking on it.
Image

Image
haha thanks for sharing. how did you find this baby
Be patient therefore, brethren, until the coming of the Lord. Behold, the husbandman waiteth for the precious fruit of the earth: patiently bearing till he receive the early and latter rain.
Behold, we account them blessed who have endured. You have heard of the patience of Job, and you have seen the end of the Lord, that the Lord is merciful and compassionate.


Re: Already Converted TradingView Indicators to MT4 Indicators

242
RodrigoRT7 wrote: Mon Aug 08, 2022 7:21 am Good evening guys, how are you? sorry to insist so much on converting this indicator, but it's because I imagine it can assemble a good combination with some mt4 specifics within a renko matrix. In addition, I found a second indicator that seems to have a good synergy in keeping the trade within a continuity, that is, not to leave early. I'm sharing custom settings for everyone on the forum to review :D

Thank you very much in advance.

Code: Select all

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator("Three-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx]", 
     shorttitle = "TPSSEMADCS [Loxx]", 
     overlay = true, 
     timeframe="", 
     timeframe_gaps = true)
     
import loxx/loxxexpandedsourcetypes/3

greencolor = #2DD204
redcolor = #D2042D 

_ssf3(src, length) =>
    arg = math.pi / length
    a1 = math.exp(-arg)
    b1 = 2 * a1 * math.cos(1.738 * arg)
    c1 = math.pow(a1, 2)
    coef4 = math.pow(c1, 2)
    coef3 = -(c1 + b1 * c1)
    coef2 = b1 + c1
    coef1 = 1 - coef2 - coef3 - coef4
    src1 = nz(src[1], src)
    src2 = nz(src[2], src1)
    src3 = nz(src[3], src2)
    ssf = 0.0
    ssf := coef1 * src + coef2 * nz(ssf[1], src1) + coef3 * nz(ssf[2], src2) + coef4 * nz(ssf[3], src3)
    ssf
    
_corEmaDev(avg, price, period)=>
    ema0 = 0., ema1 = 0., corr = 0.
    alpha = 2.0 / (1.0 + period)
    ema0 := ta.ema(price, period)
    ema1 := ta.ema(price*price, period)
    _deviation = math.max(math.sqrt(period * (ema1 - ema0 * ema0) / math.max(period - 1, 1)), 0.0)
    v1 = math.pow(_deviation, 2)
    v2 = math.pow(nz(corr[1]) - avg, 2) 
    c = (v2 < v1 or v2 == 0) ? 0 : 1 - v1 / v2
    corr := nz(corr[1]) + c * (avg - nz(corr[1]))
    corr

smthtype = input.string("Kaufman", "Heiken-Ashi Better Smoothing", options = ["AMA", "T3", "Kaufman"], group=  "Source Settings")

srcoption = input.string("Close", "Source", group= "Source Settings", 
     options = 
     ["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)", 
     "HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)",
     "HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"])

per = input.int(14, "Period", group= "Basic Settings")
colorbars = input.bool(false, "Color bars?", group= "UI Options")

kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs")
ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs")
amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs")
amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs")

haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close)
haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open)
hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high)
halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)
hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2)
hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3)
haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4)
haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4)


float src = switch srcoption
	"Close" => loxxexpandedsourcetypes.rclose()
	"Open" => loxxexpandedsourcetypes.ropen()
	"High" => loxxexpandedsourcetypes.rhigh()
	"Low" => loxxexpandedsourcetypes.rlow()
	"Median" => loxxexpandedsourcetypes.rmedian()
	"Typical" => loxxexpandedsourcetypes.rtypical()
	"Weighted" => loxxexpandedsourcetypes.rweighted()
	"Average" => loxxexpandedsourcetypes.raverage()
    "Average Median Body" => loxxexpandedsourcetypes.ravemedbody()
	"Trend Biased" => loxxexpandedsourcetypes.rtrendb()
	"Trend Biased (Extreme)" => loxxexpandedsourcetypes.rtrendbext()
	"HA Close" => loxxexpandedsourcetypes.haclose(haclose)
	"HA Open" => loxxexpandedsourcetypes.haopen(haopen)
	"HA High" => loxxexpandedsourcetypes.hahigh(hahigh)
	"HA Low" => loxxexpandedsourcetypes.halow(halow)
	"HA Median" => loxxexpandedsourcetypes.hamedian(hamedian)
	"HA Typical" => loxxexpandedsourcetypes.hatypical(hatypical)
	"HA Weighted" => loxxexpandedsourcetypes.haweighted(haweighted)
	"HA Average" => loxxexpandedsourcetypes.haaverage(haaverage)
    "HA Average Median Body" => loxxexpandedsourcetypes.haavemedbody(haclose, haopen)
	"HA Trend Biased" => loxxexpandedsourcetypes.hatrendb(haclose, haopen, hahigh, halow)
	"HA Trend Biased (Extreme)" => loxxexpandedsourcetypes.hatrendbext(haclose, haopen, hahigh, halow)
	"HAB Close" => loxxexpandedsourcetypes.habclose(smthtype, amafl, amasl, kfl, ksl)
	"HAB Open" => loxxexpandedsourcetypes.habopen(smthtype, amafl, amasl, kfl, ksl)
	"HAB High" => loxxexpandedsourcetypes.habhigh(smthtype, amafl, amasl, kfl, ksl)
	"HAB Low" => loxxexpandedsourcetypes.hablow(smthtype, amafl, amasl, kfl, ksl)
	"HAB Median" => loxxexpandedsourcetypes.habmedian(smthtype, amafl, amasl, kfl, ksl)
	"HAB Typical" => loxxexpandedsourcetypes.habtypical(smthtype, amafl, amasl, kfl, ksl)
	"HAB Weighted" => loxxexpandedsourcetypes.habweighted(smthtype, amafl, amasl, kfl, ksl)
	"HAB Average" => loxxexpandedsourcetypes.habaverage(smthtype, amafl, amasl, kfl, ksl)
    "HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(smthtype, amafl, amasl, kfl, ksl)
	"HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(smthtype, amafl, amasl, kfl, ksl)
	"HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(smthtype, amafl, amasl, kfl, ksl)
	=> haclose

avg2 = _ssf3(src, per)
val = _corEmaDev(avg2, src, per)

goLong_pre = ta.crossover(val, val[1])
goShort_pre = ta.crossunder(val, val[1])

contSwitch = 0
contSwitch := nz(contSwitch[1])
contSwitch := goLong_pre ? 1 : goShort_pre ? -1 : contSwitch

goLong = goLong_pre and ta.change(contSwitch)
goShort = goShort_pre and ta.change(contSwitch)

plot(val,"Corrected super smoother", color = contSwitch == 1  ? greencolor : redcolor, linewidth = 3)

barcolor(colorbars ? contSwitch == 1 ? greencolor : redcolor : na)

Code: Select all

//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader

study("Comp_Ratio_MA", shorttitle = "CoRa Wave", overlay = true, resolution ="")

// ======================================================================    
// Compound Ratio Weight MA function
// Compound Ratio Weight is where the weight increases in a "logarithmicly linear" way (i.e., linear when plotted on a log chart) - similar to compound ratio
// the "step ratio" between weights is consistent - that's not the case with linear-weight moving average (WMA), or EMA 
// another advantage is we can significantly reduce the "tail weight" - which is "relatively" large in other MAs and contributes to lag
//
// Compound Weight ratio     r = (A/P)^1/t - 1
// Weight at time t         A = P(1 + r)^t 
//                            = Start_val * (1 + r) ^ index
// Note: index is 0 at the furthest point back -- num periods = length -1
//
f_adj_crwma(source, length, Start_Wt, r_multi) =>
    numerator = 0.0, denom = 0.0, c_weight = 0.0
    //Start_Wt = 1.0    // Start Wight is an input in this version - can also be set to a basic value here.
    End_Wt = length     // use length as initial End Weight to calculate base "r"
    r = pow((End_Wt / Start_Wt),(1 / (length - 1))) - 1
    base = 1 + r * r_multi
    for i = 0 to length -1
        c_weight    := Start_Wt * pow(base,(length - i))
        numerator   := numerator + source[i] * c_weight 
        denom       := denom + c_weight
    numerator / denom    
// ====================================================================== ==   

data        = input(title = "Source",                 type = input.source,      defval = hlc3)
length      = input(title = "length",                 type = input.integer,     defval = 20,  minval = 1)
r_multi     = input(title = "Comp Ratio Multiplier",  type = input.float,       defval = 2.0, minval = 0, step = .1)
smooth      = input(title = "Auto Smoothing",         type = input.bool,        defval = true,                    group = "Smoothing")
man_smooth  = input(title = "Manual Smoothing",       type = input.integer,     defval = 1, minval = 1, step = 1, group = "Smoothing")

s           = smooth ? max(round(sqrt(length)),1) : man_smooth
cora_raw    = f_adj_crwma(data, length, 0.01, r_multi)    
cora_wave   = wma(cora_raw, s)

c_up        = color.new(color.aqua, 0)
c_dn        = color.new(#FF9800   , 0)
cora_up     = cora_wave > cora_wave[1]
plot(cora_wave, title="Adjustible CoRa_Wave", color = cora_up ? c_up : c_dn, linewidth = 3)
Image

Image
Hello my friends! all good? Sorry to go back to this topic about this indicator, but it's the ones I liked the most that are not available for MT4, if anyone has the expertise to convert from Tradingview to MT4, I would be deeply grateful.

Thanks a lot, in advance. s2

NOTE: I am referring to cora wave :D
These users thanked the author RodrigoRT7 for the post:
sylvester21

Re: Already Converted TradingView Indicators to MT4 Indicators

244
juniobttbh wrote: Fri Feb 17, 2023 6:24 am Good afternoon friend, could you tell me what is this indicator that marks the Bos and ChoCH?
Market structures allows to determine trend continuations as well as trend reversals in the market trough two distinct structures:

Change of Character (CHoCH)
Break of Structure (BOS)
Be patient therefore, brethren, until the coming of the Lord. Behold, the husbandman waiteth for the precious fruit of the earth: patiently bearing till he receive the early and latter rain.
Behold, we account them blessed who have endured. You have heard of the patience of Job, and you have seen the end of the Lord, that the Lord is merciful and compassionate.


Re: Already Converted TradingView Indicators to MT4 Indicators

247
is there a way in mt5 and mt4 to have array.push and array.shift like in tradingview ?

I want to convert this function

Code: Select all

// @function        Sums values of `src` when `cond` is true, over a moving window of length `ms` milliseconds. 
// @param src       (series int/float) The source of the values to be summed. 
// @param ms        (simple int) The time duration in milliseconds defining the size of the moving window.
// @param cond      (series bool) The condition determining which values are included. Optional.
// @param minBars   (simple int) The minimum number of values to keep in the moving window. Optional.
// @returns         (float) The sum of `src` when `cond` is true in the moving window.
export totalForTimeWhen(series float src, simple int ms, series bool cond = true, simple int minBars = 1) =>
    var float[] sources = array.new_float(0)
    var int[]   times   = array.new_int(0)
    if cond
        array.push(sources, src)
        array.push(times,   time)
    if array.size(sources) > 0
        while time - array.get(times, 0) >= ms and array.size(sources) > minBars
            array.shift(sources)
            array.shift(times)
    float result = array.sum(sources)

Re: Already Converted TradingView Indicators to MT4 Indicators

249
Koalala wrote: Sun Feb 19, 2023 4:09 am another indicator to convert into mt4 and mt5, it uses also array.push and other array functions and I don't even understand the logic of the indicator.
Centered Moving Average by valiant hero
https://it.tradingview.com/script/EaAHVKaD/
causal centered MA ?
too good to be true ?

i'll code it tomorrow

EDIT : after looking at the code, it uses centered MA for past bars but the last data is computed differently so, it's not really real causal centered MA

Re: Already Converted TradingView Indicators to MT4 Indicators

250
ionone wrote: Sun Feb 19, 2023 4:54 am causal centered MA ?
too good to be true ?

i'll code it tomorrow

EDIT : after looking at the code, it uses centered MA for past bars but the last data is computed differently so, it's not really real causal centered MA
yes indeed. I am interested into his formula for the ''futur''. I don't understand his maths because I don't understand this part of the code.

Second question : after so many years of the new Metatrader, is there nobody who developed functions to manipulated arrays easily like in tradingview?


Who is online

Users browsing this forum: Amazon [Bot], Dinosatoshi, DotNetDotCom [Bot], Grapeshot [Bot], IBM oBot [Bot], knglerxst, levchuk, ParallelNative, Ruby [Bot], Tradehunter and 63 guests