Re: Already Converted TradingView Indicators to MT4 Indicators

421
Hi. Can anyone convert sentiment range ma indicator to mt4 please?
Its a good signal indicator that allows us to see range market for filtering.

https://www.tradingview.com/script/LVsN ... hartPrime/

Code: Select all

//@version=5
indicator("Sentiment Range MA [ChartPrime]", overlay = true, timeframe = "", timeframe_gaps = false)

simple_filter(float source, int length, bool duel_filter)=>
    switch duel_filter
        false => ta.wma(source, length)
        true => ta.wma(ta.sma(source, length), length)

sr_ma(float source = close, int output_smoothing = 3, int trigger_smoothing = 1, int atr_length = 50, float multiplier = 1, string range_switch = "Body", bool duel_filter = false)=>
    candle_top = range_switch != "Body" ? high : math.max(open, close)
    candle_bottom = range_switch != "Body" ? low : math.min(open, close)

    smooth_top = ta.sma(candle_top, trigger_smoothing)
    smooth_bottom = ta.sma(candle_bottom, trigger_smoothing)

    tr = candle_top - candle_bottom
    atr = ta.sma(tr, atr_length)

    var float sr_ma = na
    var float current_range = na
    var float top_range = na
    var float bottom_range = na

    flag = smooth_top > top_range or smooth_bottom < bottom_range or na(current_range)

    if flag
        sr_ma := source
        current_range := atr * multiplier
        top_range := sr_ma + current_range
        bottom_range := sr_ma - current_range
        
    out = simple_filter(sr_ma, output_smoothing, duel_filter)
    smooth_top_range = simple_filter(top_range, output_smoothing, duel_filter)
    smooth_bottom_range = simple_filter(bottom_range, output_smoothing, duel_filter)

    [out, smooth_top_range, smooth_bottom_range]

source = input.source(close, "Source", group = "Settings")
output_smoothing = input.int(20, "Length", minval = 0, group = "Settings") + 1
use_double = input.bool(true, "Double Filter", group = "Settings")
smoothing = input.int(4, "Trigger Smoothing", minval = 0, group = "Settings") + 1
atr_length = input.int(200, "ATR Length", minval = 1, group = "Settings")
multiplier = input.float(6, "Range Multiplier", minval = 0, step = 0.125, group = "Settings")
range_switch = input.string("Body", "Range Style", ["Body", "Wick"], group = "Settings")

style = input.string("MA Direction", "Color Style", ["MA Direction", "MA Cross", "Solid"], group = "Color")
bullish_color = input.color(color.rgb(33, 255, 120), "Bullish Color", group = "Color")
bearish_color = input.color(color.rgb(255, 33, 33), "Bearish Color", group = "Color")

neutral_color = input.color(color.rgb(137, 137, 137), "Neutral Color", "This doubles as the solid color.", group = "Color")

[sr_ma, top_range, bottom_range] = sr_ma(source, output_smoothing, smoothing, atr_length, multiplier, range_switch, use_double)

var color ma_delta = na
var color ma_cross = na

plot_neutral = high > sr_ma and low < sr_ma
plot_bullish = low > sr_ma
plot_bearish = high < sr_ma

if plot_bullish 
    ma_cross := bullish_color

if plot_bearish
    ma_cross := bearish_color

if plot_neutral 
    ma_cross := neutral_color

ma_delta_neutral = sr_ma - nz(sr_ma[1]) == 0
ma_delta_bullish = sr_ma - nz(sr_ma[1]) > 0
ma_delta_bearish = sr_ma - nz(sr_ma[1]) < 0

if ma_delta_bullish
    ma_delta := bullish_color

if ma_delta_bearish
    ma_delta := bearish_color

if ma_delta_neutral 
    ma_delta := neutral_color

ma_color = style == "MA Cross"? ma_cross : style == "MA Direction" ? ma_delta : neutral_color

alpha = color.new(color.red, 100)

ma = plot(sr_ma, "SR MA", ma_color, 3)
top = plot(top_range, "Top Range", alpha)
bottom = plot(bottom_range, "Bottom Range", alpha)

fill(ma, top, top_value = top_range, bottom_value = sr_ma, bottom_color = color.new(ma_color, 82), top_color = alpha)
fill(ma, bottom, top_value = sr_ma, bottom_value = bottom_range, top_color = color.new(ma_color, 82), bottom_color = alpha)
These users thanked the author GaeBolg for the post (total 4):
moey_dw, TransparentTrader, stond, Jimmy


Re: Already Converted TradingView Indicators to MT4 Indicators

422
jeffx33 wrote: Sun Mar 31, 2024 1:38 am Hello dear coders, I hope everyone is having a good week end.
Could anyone please convert this awesome indicator from TV to mt4 that displays other time frame candle on the same chart?
Many thanks

https://www.tradingview.com/script/ZEzP ... e-Display/
There are mt4 variations of this indicator. Just search the forum. Talking from experience. I I have on my pc mt4. I'll post it, but I'm not with my pc at the moment
These users thanked the author A_5 for the post:
Banzai

Re: Already Converted TradingView Indicators to MT4 Indicators

423
jeffx33 wrote: Sun Mar 31, 2024 1:38 am Hello dear coders, I hope everyone is having a good week end.
Could anyone please convert this awesome indicator from TV to mt4 that displays other time frame candle on the same chart?
Many thanks

https://www.tradingview.com/script/ZEzP ... e-Display/
Go through them and hopefully you get what you needed
These users thanked the author A_5 for the post:
Banzai


CodeRe: Already Converted TradingView Indicators to MT4 Indicators

430
https://pl.tradingview.com/v/r6dAP7yi/

hello


Does anyone know and be able to convert this supertrend indicator from pinescript code to mql4 code?
This indicator is slightly different from the supertrend indicators on this website, mainly when it comes to ATR calculations on which the supertrend is based.

Code: Select all

//@version=4
study("Supertrend", overlay = true, format=format.price, precision=2, resolution="")

Periods = input(title="ATR Period", type=input.integer, defval=10)
src = input(hl2, title="Source")
Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true)
showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true)
highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true)
atr2 = sma(tr, Periods)
atr= changeATR ? atr(Periods) : atr2
up=src-(Multiplier*atr)
up1 = nz(up[1],up)
up := close[1] > up1 ? max(up,up1) : up
dn=src+(Multiplier*atr)
dn1 = nz(dn[1], dn)
dn := close[1] < dn1 ? min(dn, dn1) : dn
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0)
plotshape(buySignal and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0)
plotshape(sellSignal and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white
shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white
fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor)
alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!")
alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!")
changeCond = trend != trend[1]
alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
Image


Who is online

Users browsing this forum: Applebot [Crawler], ChatGPT [Bot], DotNetDotCom [Bot], IBM oBot [Bot], Mrtrader, TransparentTrader and 64 guests