how to read MACD indicator data when applied to renko chart

 

hello coder's. please am following a strategy that applied the Macd indicator on 10pips renko chart on tradingview.

So now am trying to build an MT5 EA for the strategy, but unfortunately there's no Renko chart on MT5, However, I downloaded a Renko indicator from https://indicatorspot.com/indicator/renko-charts-indicator/ and I applied it to the chart but it appear as an indicator at the bottom it's not a chart type. so I drag and drop Macd from the left pane navigation on top of the Renko indicator and select add to previous indicator data, and i can see some price from the macd indicator written on the top left corner of the renko indicator window.

macd applied to renko indicator

So in my Ea i create an handle for both renko and macd indicator and instead of applying Macd to price I instead applied it to the handle of Renko. and am actually getting the data which the macd display on the renko indicator window.

int renkoHandle = iCustom(_symbol,PERIOD_CURRENT,"IndicatorSpot\\renko.ex5", 50);

int macdHandle = iMACD(_Symbol,PERIOD_CURRENT,macdFastEmaPeriod,macdSlowEmaPeriod,macdSmaPeriod,renkoHandle);

But i read an article on a blog that says using this approach only work with base indicators that has only one buffer, he also said the second indicator will only use the buffer 0 of the base indicator in it calculation whereas the Renko indicator i am using has four buffers which is the open, high, low and close of each brick. so am confuse here. does it means the price data that am getting from the macd indicator that i applied to the renko indicator is not correct ??. because the macd indicator does not appear on the renko indicator for me to confirm, only the price value appears at the top.

any if anybody have a better solution please provide, thank you.

 

The Renko indicator is usually a multi-buffer indicator displayed as histogram or candles plot, and as such, cannot be used as the "applied price" for another indicator.

The solution is to either calculate the MACD yourself in the code or to use a Renko generator that produces a Custom Symbol and then apply the MACD to it instead.

Forum on trading, automated trading systems and testing trading strategies

Using Moving Avereage with custom ENUM_APPLIED_PRICE variable for Heiken Ashi based MA calulation

Fernando Carreiro, 2023.10.25 14:51

Usually the Heiken Ashi is a multi-buffer indicator displayed as candles plot, and as such, cannot be used as the "applied price" for another indicator.


Forum on trading, automated trading systems and testing trading strategies

How to code Moving Average applied on Bollinger Bands

Fernando Carreiro, 2023.10.11 22:34

To summarise the issue ...

Currently MQL5 does not offer a method to redirect secondary plots to the "applied price" parameter of an indicator function. It only works with the primary plot.

Possible work-arounds (can't be classified as solutions) ...

  • To collect the data from the secondary plots via the CopyBuffer function and then apply a moving average using the functions in in "MovingAverages.mqh" (for the moving average example).
  • To break-down the calculations of the original multi-plot indicator, and then use the "applied price" method on the elementary indicator functions.

Also, neither of the above two work-around are ideal, or efficient or even generic.

There may be other work-arounds that have not yet been proposed or discussed.

 
Fernando Carreiro #: The Renko indicator is usually a multi-buffer indicator displayed as histogram or candles plot, and as such, cannot be used as the "applied price" for another indicator. The solution is to either calculate the MACD yourself in the code or to use a Renko generator that produces a Custom Symbol and then apply the MACD to it instead.

Where can i get a Renko generator that produces a Custom Symbol?

and also Please how can I calculate the MACD myself in the code?

 
Bill Mayheptad #:   Please where can i get a Renko generator that produces a Custom Symbol. ??

Search the CodeBase. There are a few, but here is one of them ...

Code Base

Renko 2.0 Offline

Guilherme Santos, 2018.03.28 12:54

This non-trading utility generates custom symbol information on 1M chart. Configure using Tick Size, Pip Size, Points or R. Now with Asymetric Reversals!

Bill Mayheptad #: and also Please how can I calculate the MACD myself in the code ??

By using CopyBuffer to get the indicator values and then applying the maths for MACD calculations.

MACD - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
Moving Average Convergence/Divergence (MACD) is a trend-following dynamic indicator. It indicates the correlation between two Moving Averages of a...
 
Bill Mayheptad #: i have downloaded the renko 2.0 offline but dont know how to apply it to the chart

It is an EA, not an Indicator. Please read the publication description.

Also, please do some research on Custom Symbols and how they work.

 
Fernando Carreiro #: Search the CodeBase. There are a few, but here is one of them ... By using CopyBuffer to get the indicator values and then applying the maths for MACD calculations.

thank you @Fernando Carreiro after reading the article about macd calculation, so I wrote a pseudo code of how i understand the article, please correct me if am wrong, or i understand the article wrongly

i . get the close price of renko lastbar using copybuffer

int renkoHandle = iCustom(Symbol,TimeFrame,"IndicatorSpot.com\\renko.ex5",100);
double renkoDataArr[];
CopyBuffer(renkoHandle,3,0,1,renkoDataArr);

ii. then pass the renko last brick closed price to ema handle

int ema12handle = iMA(symbol,timeframe,12,0,exponential,renkoDataArr[0])
double ema12DataArr[];
CopyBuffer(ema12handle,0,0,1, ema12DataArr );

int ema26handle = iMA(symbol,timeframe,26,0,exponential,renkoDataArr[0])
double ema26DataArr[];
CopyBuffer(ema26handle,0,0,1,ema26DataArr);

iii.then subtract ema12price from ema26price to get macd mainline

double macdMainline = ema12DataArr[0] - ema26DataArr[0];

Improperly formatted code edited by moderator.

 

Improperly formatted code edited by moderator. In the future, please use the CODE button (Alt-S) when inserting code.

Code button in editor

 

Bill Mayheptad #: thank you @Fernando Carreiro after reading the article about macd calculation, so I wrote a pseudo code of how i understand the article, please correct me if am wrong, or i understand the article wrongly

i . get the close price of renko lastbar using copybuffer
ii. then pass the renko last brick closed price to ema handle
iii.then subtract ema12price from ema26price to get macd mainline

Unfortunately the iMA() function cannot be used on an array of data. Instead include the "MovingAverages.mqh" file and call the functions there.

As for your pseudo code, yes I think it is valid. I personally would do it differently, but each programmer has their own way of looking at things.

The next step, is for you to implement it and see if it works for you.

 
Fernando Carreiro #:
MovingAverages.mqh

@Fernando Carreiro pls how do i use the MovingAverage.mqh library, i have included the library, and i don't really know which function to call, however i called the 

double ExponentialMA(const int position,const int period,const double prev_value,const double &price[])

but i don't understand what vaues to pass into it parameter;
what is the position, period,  prev_value, &price[]. pls guide me

 
Fernando Carreiro #:

Unfortunately the iMA() function cannot be used on an array of data. Instead include the "MovingAverages.mqh" file and call the functions there.

As for your pseudo code, yes I think it is valid. I personally would do it differently, but each programmer has their own way of looking at things.

The next step, is for you to implement it and see if it works for you.

can you please tell me your own way of doing it ?