MT5 indicator wont plot on Main chart despite making so many changes

 

Here's a summary of all the changes I've made in an attempts to get the indicator to plot on the main chart:, i have attached the 2 indicators below, Despite these changes,  the indicator is still not plotting on the main chart, i'm just  4 weeks old in coding, i think that there is a deeper issue with my approach, or with how MetaTrader is handling the indicator or with the specific configurations in my environment.
Please can anyone guide me and tell me what precise changes i need to make on these 2 indicators plot on the Main chart . Thanks

1.Added #property indicator_chart_window to specify that the indicator should be plotted on the main chart window instead of a separate indicator window.
2.Set the plot types to DRAW_LINE for all three components (MACD line, Signal line, Histogram).
3.Used SetIndexBuffer for all three buffers ( MACDBuffer , SignBuffer , HistBuffer ) to ensure they are correctly associated with the plots.
4. Added PlotIndexSetInteger with PLOT_DRAW_BEGIN to control when the plotting starts on the chart.
5. Used PlotIndexSetDouble with PLOT_EMPTY_VALUE to define empty values that should not be plotted.
6. Used IndicatorSetString and PlotIndexSetString to set dynamic names and labels for the indicator and its components.
7. Adjusted the start index ( first ) in the OnCalculate function to ensure that calculations and plotting start from the correct position based on available data.
8 Suggested keeping the Histogram as DRAW_LINE instead of DRAW_HISTOGRAM to maintain consistency in plotting styles on the main chart.

Files:
colorxmacd.mq5  11 kb
jmacd.mq5  8 kb
 
Can anyone please advise me on how to make this indicators to plot on the main chart or at least tell me why all the steps i listed above didn't work
 
those indicators use SmoothAlgorithms.mqh, any indicator using this library will never appear on the chart window, not sure if it can be explained
 
Conor Mcnamara #:
those indicators use SmoothAlgorithms.mqh, any indicator using this library will never appear on the chart window, not sure if it can be explained

wow, thank you so much for that info, i never knew,
1.what if i just copy basic functions from the library into the indicator , instead of integrating the full library which(i  read that it is memory intensive) will it work ? 
2. what is the best way to make the indicators plot of main chart assuming i wont be adding the smoothing.

Thank you  so much for the response, i humbly appreciate 

 
Chike Kene Assuzu #:

wow, thank you so much for that info, i never knew,
1.what if i just copy basic functions from the library into the indicator , instead of integrating the full library which(i  read that it is memory intensive) will it work ? 
2. what is the best way to make the indicators plot of main chart assuming i wont be adding the smoothing.

Thank you  so much for the response, i humbly appreciate 

I'm sorry but I don't have all the answers. If I knew why some indicators won't work on the chart window, I would say, but I don't know what the reasoning is. You can rebuild the macd using less complex code. But never once have I seen a MACD working in the chart window, and if you try it won't work, you'll get a 4806 error. No point trying to do what the software doesn't want to do. Use macd in the separate window.

the reason why it won't work (I think) is because the macd is an oscillator unlike a moving average by itself which is directional with the chart (because the MA value is near the OHLC prices). The macd is calculating values of multiple moving averages, it's not directional with the chart candles. What you're trying to do is as crazy as plotting an RSI on the chart

 
Conor Mcnamara #:

I'm sorry but I don't have all the answers. If I knew why some indicators won't work on the chart window, I would say, but I don't know what the reasoning is. You can rebuild the macd using less complex code. But never once have I seen a MACD working in the chart window, and if you try it won't work, you'll get a 4806 error. No point trying to do what the software doesn't want to do. Use macd in the separate window.


Bro , I was able to make this one plot on screen and it has jjma, i dont even know what i did after several manipulation, 

Files:
 
Chike Kene Assuzu #:


Bro , I was able to make this one plot on screen and it has jjma, i dont even know what i did after several manipulation, 

ha ha, that's not a MACD anymore

thats 3 buffers which are 2 MAs, and the third buffer is the first MA minus the second MA. That's an MA cross indicator and not a macd. MACD fomula is more advanced.

 

this is actually the true macd calculation made to work on the chart:

https://www.mql5.com/en/code/41270


but as you can see it doesn't look that good when you try to put an oscillator on the chart

Chart Window MACD
Chart Window MACD
  • www.mql5.com
The indicator is an equivalent \"Chart Window\" version of MACD.
 
lol, thanks mate. i appreciate the information
 
Conor Mcnamara #:

this is actually the true macd calculation made to work on the chart:

https://www.mql5.com/en/code/41270


but as you can see it doesn't look that good when you try to put an oscillator on the chart

i actually came across that one, this guy own is much more profitable when used with a good trailing  https://www.mql5.com/en/code/20988

Reverse_MACD
Reverse_MACD
  • www.mql5.com
An information-forecast MACD on the price chart
 
Chike Kene Assuzu #:

i actually came across that one, this guy own is much more profitable when used with a good trailing  https://www.mql5.com/en/code/20988

I don't like that, reversing of the macd will make a very confusing plot, and macd tends to change its mind a lot on the trend direction