Re: Already Converted TradingView Indicators to MT4 Indicators

361
RTI (Relative Trend Index) from TradingView for MT4

An early Christmas gift for everyone: the TradingView RTI in MT4

@mrtools @kvak
I have faith in you both.. please let us have your magic..
mrtools wrote: Mon Jul 31, 2023 5:27 am Coded a version, came out terrible, we have an ArraySort function in meta trader but no Array.new or Array.Push and no idea how to code around them, sorry!
kvak wrote: Sun Jul 30, 2023 7:01 pm I was trying it yesterday, but it is look that some lines in code Iam not able to convert....
TransparentTrader wrote: Wed Nov 22, 2023 7:42 am So what now? Still no chance of having this ported to MT4?
xard777 wrote: Sat Jul 29, 2023 8:47 am Have a great weekend everyone...
Xard777
Image



Re: Already Converted TradingView Indicators to MT4 Indicators

362
chris006 wrote: Mon Dec 11, 2023 9:20 am An early Christmas gift for everyone: the TradingView RTI in MT4

@mrtools @kvak
I have faith in you both.. please let us have your magic..


Image

I'll definitely have to test this out on TradingView and MT4 to see if it's the real deal, but this is an amazing gift if everything checks out.

How did you manage to port it to MT4? Did you do this yourself, or did another coder help you translate the code over?
These users thanked the author TransparentTrader for the post (total 2):
chris006, RodrigoRT7

Re: Already Converted TradingView Indicators to MT4 Indicators

363
chris006 wrote: Mon Dec 11, 2023 9:20 am An early Christmas gift for everyone: the TradingView RTI in MT4

@mrtools @kvak
I have faith in you both.. please let us have your magic..

Thanks mr.chris..
m1 chart combination with slope line breakout
These users thanked the author sal for the post (total 5):
Ricstar_8, chris006, Akela, ParallelNative, Jackson Doh
"There is NO GOD higher than TRUTH" - Mahatma Gandhi

Re: Already Converted TradingView Indicators to MT4 Indicators

364
The conversion is the work of a developer that has knowledge in both pine and mql4.

If anyone wants to do similar conversion from TradingView script to mql4 (paid job), I can pass on his details by personal message.

TransparentTrader wrote: Mon Dec 11, 2023 10:03 am I'll definitely have to test this out on TradingView and MT4 to see if it's the real deal, but this is an amazing gift if everything checks out.

How did you manage to port it to MT4? Did you do this yourself, or did another coder help you translate the code over?
These users thanked the author chris006 for the post (total 4):
TransparentTrader, RodrigoRT7, commodus, k_khan_bt

HappyRe: Already Converted TradingView Indicators to MT4 Indicators

365
@mrtools @kvak

Dear coders, could you please look to clean-up the code of Relative Trend Index?

Something has to be wrong because with only a blank chart and the indicator added in subwindow, the saved template files are huge.

Also, any improvements you could implement would be awesome (averages, arrows,mtf,slope,candles etc..), "please let us have your magic.."

chris006 wrote: Mon Dec 11, 2023 9:20 am RTI (Relative Trend Index) from TradingView for MT4

An early Christmas gift for everyone: the TradingView RTI in MT4

@mrtools @kvak
I have faith in you both.. please let us have your magic..


Re: Already Converted TradingView Indicators to MT4 Indicators

366
chris006 wrote: Wed Dec 13, 2023 12:27 am @mrtools @kvak

Dear coders, could you please look to clean-up the code of Relative Trend Index?

Something has to be wrong because with only a blank chart and the indicator added in subwindow, the saved template files are huge.

Also, any improvements you could implement would be awesome (averages, arrows,mtf,slope,candles etc..), "please let us have your magic.."
Hello.
I am not sure if I am able to do something with this code.....
These users thanked the author kvak for the post:
chris006

Re: Already Converted TradingView Indicators to MT4 Indicators

367
Hi!

Would it be possible to convert this RSI WITH BREAKOUTS indicator, which is free, from TradingView to MT4 format?
Thanks ..

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/
// © HoanGhetti

//@version=5
indicator("RSI Trendlines with Breakouts [HG]", precision = 2, max_labels_count = 500, max_lines_count = 500)
import HoanGhetti/SimpleTrendlines/3 as tl

g_trendlines    = 'Trendline Settings', g_conditions = 'Conditions',  g_styling = 'Styling', g_timeframe = 'Timeframe'
input_timeframe = input.timeframe(defval = '', title = 'Timeframe', group = g_timeframe)
input_pLen      = input.int(defval = 4, title = 'Lookback Range', minval = 1, group = g_trendlines, tooltip = 'How many bars to determine when a swing high/low is detected.')
input_rLen      = input.int(defval = 14, title = 'RSI Length' , minval = 1, group = g_trendlines)
input_rSrc      = input.source(defval = close, title = 'RSI Source', group = g_trendlines)
input_repaint   = input.string(defval = 'On', title = 'Repainting', group = g_conditions, options = ['On', 'Off: Bar Confirmation'], tooltip = 'Bar Confirmation: Generates alerts when candle closes. (1 Candle Later)')
input_rsiDiff   = input.int(defval = 3, title = 'RSI Difference', group = g_conditions, tooltip = 'The difference between the current RSI value and the breakout value.\n\nHow much higher in value should the current RSI be compared to the breakout value in order to detect a breakout?')
input_rsiCol    = input.color(defval = color.blue, title = 'RSI Color', group = g_styling)
input_width     = input.int(defval = 2, title = 'Line Width', minval = 1, group = g_styling)
input_lblType   = input.string(defval = 'Simple', title = 'Label Type', group = g_styling, options = ['Full', 'Simple'])
input_lblSize   = input.string(defval = size.small, title = 'Label Size', group = g_styling, options = [size.huge, size.large, size.normal, size.small, size.tiny])
input_pLowCol   = input.color(defval = color.red, title = 'Pivot Low', inline = 'col', group = g_styling)
input_pHighCol  = input.color(defval = #089981, title = 'Pivot High', inline = 'col', group = g_styling)
input_override  = input.bool(defval = false, title = 'Override Text Color', group = g_styling, inline = 'override')
input_overCol   = input.color(defval = color.white, title = ' ', group = g_styling, inline = 'override')

lblText = switch input_lblType
    'Simple' => 'Br'
    'Full'   => 'Break'
repaint = switch input_repaint
    'On' => true
    'Off: Bar Confirmation' => false

rsi_v = ta.rsi(input_rSrc, input_rLen) 
rsi = input_timeframe == '' ? rsi_v : request.security(syminfo.tickerid, input_timeframe, rsi_v, lookahead = barmerge.lookahead_on)

pl = fixnan(ta.pivotlow(rsi, 1, input_pLen))
ph = fixnan(ta.pivothigh(rsi, 1, input_pLen))

pivot(float pType) =>
    pivot = pType == pl ? pl : ph
    xAxis = ta.valuewhen(ta.change(pivot), bar_index, 0) - ta.valuewhen(ta.change(pivot), bar_index, 1)
    prevPivot = ta.valuewhen(ta.change(pivot), pivot, 1)
    pivotCond = ta.change(pivot) and (pType == pl ? pivot > prevPivot : pivot < prevPivot)
    pData = tl.new(x_axis = xAxis, offset = input_pLen, strictMode = true, strictType = pType == pl ? 0 : 1)
    pData.drawLine(pivotCond, prevPivot, pivot, rsi)
    pData

breakout(tl.Trendline this, float pType) =>
    var bool hasCrossed = false
    if ta.change(this.lines.startline.get_y1())
        hasCrossed := false
    this.drawTrendline(not hasCrossed)
    condType = (pType == pl ? rsi < this.lines.trendline.get_y2() - input_rsiDiff : rsi > this.lines.trendline.get_y2() + input_rsiDiff) and not hasCrossed
    condition = repaint ? condType : condType and barstate.isconfirmed
    if condition
        hasCrossed := true
        this.lines.startline.set_xy2(this.lines.trendline.get_x2(), this.lines.trendline.get_y2())
        this.lines.trendline.set_xy2(na, na)
        this.lines.startline.copy()
        label.new(
             bar_index, 
             this.lines.startline.get_y2(), 
             text = lblText, color = pType == pl ? color.new(input_pLowCol, 50) : color.new(input_pHighCol, 50), 
             size = input_lblSize, style = pType == pl ? label.style_label_lower_left : label.style_label_upper_left, 
             textcolor = pType == pl ? (input_override ? input_overCol : input_pLowCol) : input_override ? input_overCol : input_pHighCol)
    hasCrossed

method style(tl.Trendline this, color col) =>
    this.lines.startline.set_color(col)
    this.lines.startline.set_width(input_width)
    this.lines.trendline.set_color(col)
    this.lines.trendline.set_width(input_width)
    this.lines.trendline.set_style(line.style_dashed)

plData = pivot(pl)
phData = pivot(ph)
plData.style(input_pLowCol)
phData.style(input_pHighCol)
cu = breakout(plData, pl)
co = breakout(phData, ph)

hline(70, title = 'Overbought', color = input_pHighCol, linestyle = hline.style_dotted)
hline(30, title = 'Oversold', color = input_pLowCol, linestyle = hline.style_dotted)
plot(rsi, title = 'Relative Strength Index', linewidth = 2, color = input_rsiCol)
alertcondition(ta.change(plData.lines.startline.get_y1()), 'New Pivot Low Trendline')
alertcondition(ta.change(cu) and cu, 'Pivot Low Breakout')
alertcondition(ta.change(phData.lines.startline.get_y1()), 'New Pivot High Trendline')
alertcondition(ta.change(co) and co, 'Pivot High Breakout')

Re: Already Converted TradingView Indicators to MT4 Indicators

368
TransparentTrader wrote: Mon Dec 11, 2023 10:03 am I'll definitely have to test this out on TradingView and MT4 to see if it's the real deal, but this is an amazing gift if everything checks out.

How did you manage to port it to MT4? Did you do this yourself, or did another coder help you translate the code over?



Short of slight value discrepancies due to different values on the TradingView and MT4 charts, I can confirm these are effectively the same indicator on both platforms. Visuals are slightly different but not going to complain. I think this is as close of a faithful port as we are going to get.

The only question left is how we tweak and optimize this indicator to make it useful for trading!
These users thanked the author TransparentTrader for the post:
chris006

Re: Already Converted TradingView Indicators to MT4 Indicators

369
Would that be possible?
opita wrote: Fri Dec 08, 2023 11:35 am Request:
Engulfing Detector https://www.tradingview.com/script/ENKp ... nd-Demand/

This is a unique engulfing indicator, which I believe catches the essence of how to trade engulfing candles.
Creating this indicator can inspire additional indicators with similar strategies.

Image

Code: Select all

//@version=4
study("Engulfing Detector", overlay=true, max_bars_back=500)

maxBarsBack = 500

previousRange = open[1] - close[1]

line bullEngulfOpen = na
line bullEngulfLow = na

line bearEngulfOpen = na
line bearEngulfHigh = na

isBullEngulf = previousRange > 0 and close > open[1]
isBearEngulf = previousRange < 0 and close < open[1]

if isBullEngulf
    bullEngulfOpen := line.new(bar_index - 1, open[1], bar_index, open[1], extend=extend.right, color=color.green)
    bullEngulfLow := line.new(bar_index - 1, low < low[1] ? low : low[1], bar_index, low < low[1] ? low : low[1], extend=extend.right, color=color.red)

if isBearEngulf
    bearEngulfOpen := line.new(bar_index - 1, open[1], bar_index, open[1], extend=extend.right, color=color.green)
    bearEngulfHigh := line.new(bar_index - 1, high > high[1] ? high : high[1], bar_index, high > high[1] ? high : high[1], extend=extend.right, color=color.red)


var maxNumberOfEngulfings = 10
bullEngulfingCount = 0
for i = 1 to maxBarsBack
    if not na(bullEngulfOpen[i])
        if low < line.get_y1(bullEngulfLow[i])
            line.delete(bullEngulfOpen[i])
            line.delete(bullEngulfLow[i])
            continue
        if low < line.get_y1(bullEngulfOpen[i])
            //line.set_x2(bullEngulfOpen[i], bar_index)
            line.set_color(bullEngulfOpen[i], color.gray)
            //line.set_extend(bullEngulfOpen[i], extend.none)
            //line.set_x2(bullEngulfLow[i], bar_index)
            line.set_color(bullEngulfLow[i], color.gray)
            //line.set_extend(bullEngulfLow[i], extend.none)
            
        bullEngulfingCount := bullEngulfingCount + 1
        if bullEngulfingCount > maxNumberOfEngulfings
            line.delete(bullEngulfOpen[i])
            line.delete(bullEngulfLow[i])
            
bearEngulfingCount = 0
for i = 1 to maxBarsBack   
    if not na(bearEngulfOpen[i])
        if high > line.get_y1(bearEngulfHigh[i])
            line.delete(bearEngulfOpen[i])
            line.delete(bearEngulfHigh[i])
            continue
        
        if high > line.get_y1(bearEngulfOpen[i])
            //line.set_x2(bearEngulfOpen[i], bar_index)
            line.set_color(bearEngulfOpen[i], color.gray)
            //line.set_extend(bearEngulfOpen[i], extend.none)
            //line.set_x2(bearEngulfHigh[i], bar_index)
            line.set_color(bearEngulfHigh[i], color.gray)
            //line.set_extend(bearEngulfHigh[i], extend.none)
            
        bearEngulfingCount := bearEngulfingCount + 1
        if bearEngulfingCount > maxNumberOfEngulfings
            line.delete(bearEngulfOpen[i])
            line.delete(bearEngulfHigh[i])
Cheers,

Opita


Who is online

Users browsing this forum: alexm, Efegocmen, IBM oBot [Bot], NotInPortland, rudiarius, Trendiction [Bot], vova and 92 guests