Converting a Tradingview indicator to MT4 (Rob Hoffman Overlay)

 

Hi


I need Rob Hoffman Overlay indicator for MT4. Here is the source code for Tradingview. Would you please tell me how to convert it for MT4?


Many thanks in advance.

study("Rob Hoffman - Overlay Set", shorttitle = "RH - MAs", overlay = true)

a = sma(close,3)
b = sma(close,5)

c = ema(close,18)
d = ema(close,20)

e = sma(close,50)
f = sma(close,89)
g = ema(close,144)
h = sma(close,200)

k = ema(close,35)
r = rma(tr,35)
ku = k + r*0.5
kl = k - r*0.5

plot(a, title = "Fast Speed Line", linewidth = 2, color = #0000FF)
plot(b, title = "Slow Speed Line", linewidth = 2, color = fuchsia)
plot(c, title = "Fast Primary Trend Line", linewidth = 3, color = #00FF00)
plot(d, title = "Slow Primary Trend Line", linewidth = 3, color = #000000)
plot(e, title = "Trend Line - 1", linewidth = 3, color = #0000FF, style = circles)
plot(f, title = "Trend Line - 2", linewidth = 3, color = #20B2AA)
plot(g, title = "Trend Line - 3", linewidth = 3, color = #FF4500)
plot(h, title = "Trend Line - 4", linewidth = 3, color = fuchsia)

plot(k, title = "No Trend Zone - Midline", linewidth = 2, color = #3CB371)
plot(ku, title = "No Trend Zone - Upperline", linewidth = 2, color = #3CB371)
plot(kl, title = "No Trend Zone - Lowerline", linewidth = 2, color = #3CB371)
 
S.ShojaEddin Rafieipour: Would you please tell me how to convert it for MT4?

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)

 
William Roeder #:

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. Or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)


Thank you William

I changed the code , and I have still a problem.

In the above Tradingview code we have:

r = rma(tr,35)  

And "tr" is a built-in variable in Tradingview that presents true range. I coded it in MQL :

 tr=MathMax(MathMax((High[i]-Low[i]),MathAbs(High[i]-Close[i+1])),MathAbs(Low[i]-Close[i+1]));


Also I searched (click here) and understood that "rma" in Tradingview is equal to iMA(SMMA Mode). But in iMA() function, we can only use some unchangeable Price Constants, and I want to use "tr" instead of any of price constants. Would you please help me how to do that?

Thank you before.


Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Price Constants - Indicator Constants - Constants, Enumerations and Structures - MQL4 Reference
 
S.ShojaEddin Rafieipour #:


Thank you William

I changed the code , and I have still a problem.

In the above Tradingview code we have:

And "tr" is a built-in variable in Tradingview that presents true range. I coded it in MQL :


Also I searched (click here) and understood that "rma" in Tradingview is equal to iMA(SMMA Mode). But in iMA() function, we can only use some unchangeable Price Constants, and I want to use "tr" instead of any of price constants. Would you please help me how to do that?

Thank you before.


https://docs.mql4.com/indicators/imaonarray

iMAOnArray - Technical Indicators - MQL4 Reference
iMAOnArray - Technical Indicators - MQL4 Reference
  • docs.mql4.com
iMAOnArray - Technical Indicators - MQL4 Reference
 
  1.  tr=MathMax(MathMax((High[i]-Low[i]),MathAbs(High[i]-Close[i+1])),MathAbs(Low[i]-Close[i+1]));

    You don't need the abs since H ≥ C ≥ L always. Switch last term to C-L.

  2. Simplified and easier to understand:

    tr=MathMax(High[i], Close[i+1)) - MathMin(Low[i], Close[i+1]);
  3. S.ShojaEddin Rafieipour #: "rma" in Tradingview is equal to iMA(SMMA Mode). 

    Never any reason to use the SMMA(L) it's equivalent to the EMA(2L-1).
              The Smoothed Moving Average or SMMA - How to Avoid It - NinjaTrader Programming | futures.io (2019)

  4. As Navdeep referenced, create a non-visual buffer with each TR and then compute the MA of it. You could also use iATR except that only uses SMA.