[Archive!] I will write any expert or indicator for free. - page 89

 
Vinin:
Not easier. Not enough buffers.
There wouldn't be enough buffers. But the author only wanted histograms :))
"I mean 3 histograms with different values"
 
granit77:
It's not good enough. But the author only wanted histograms :))
"I mean 3 histograms with different values"

So it's not realistic to make 3 histograms? Am I just wasting my time with the code?
 
I've used this one as a base. I can't figure out how to add a third histogram. I don't know what to do. Except standing on my head.
 
alkeon:
So it's not realistic to make 3 histograms? Did I just go through all that trouble to break the code for nothing?
Nothing is for nothing. Experience is more valuable than the result.
In this particular case, it depends on the number of MACD copies you need. One copy requires two buffers (histogram and signal line), you need eight buffers in total. That is, three copies will take six buffers and still have some left over.
How's your agony? Where is the code?

P.S.
I don't like your prototype. It's not two MACDs, it's sequential smoothing. Better take a simple classic MACD and triple it.
Files:
macd.mq4  3 kb
 
The main bullying lies at work on the computer. But that's no problem, I've tormented him so much already that I can remember by heart what to repeat.
 
It's just that it's easier (as I thought). Thanks for the indicator, I'll now start to get the hang of it.
 

Here's where I left off. Totally confused about the formulas. What's wrong?

This is the latest version with no errors. But it's also a mess.

Files:
macd_3.mq4  5 kb
 
In general, the direction is right, fix the mistakes and it will work. I will not correct it, I will explain it in words.

//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 6
#property  indicator_color1  Silver
#property  indicator_color2  Red
#property  indicator_color3  Silver
#property  indicator_color4  Red
#property  indicator_color5  Silver
#property  indicator_color6  Red
#property  indicator_width1  2
//---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern int FastEMA1=12;
extern int SlowEMA1=26;
extern int SignalSMA1=9;
extern int FastEMA2=12;
extern int SlowEMA2=26;
extern int SignalSMA2=9;
//---- indicator buffers
double     MacdBuffer[]; //Проверить соответствие нумерации
double     SignalBuffer[];
double     MacdBuffer1[];
double     SignalBuffer2[];
double     MacdBuffer3[];
double     SignalBuffer4[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);// нумерация буферов должна идти подряд от 0 до 6
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(Digits+1);
    SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(Digits+1);
    SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,SignalSMA);
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+","+FastEMA1+","+SlowEMA1+","+SignalSMA1+","+FastEMA2+","+SlowEMA2+","+SignalSMA2+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
   // Эта часть пишется только 1 раз
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   //-------------------------------  
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
      SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
      
      
      int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      MacdBuffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
      SignalBuffer2[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
      
      
      int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st buffer
   for(int i=0; i<limit; i++)
      MacdBuffer3[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//---- signal line counted in the 2-nd buffer
   for(i=0; i<limit; i++)
      SignalBuffer4[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
      
//---- done
   return(0);
  }
//+------------------------------------------------------------------+
 

Good day dear kubodel, please correct the adviser to open a deal not at 00 minutes of each timeframe

and after 30 seconds from the start of the candle timeframe

 
abolk:

tweaked the buffer numbers to a first approximation - then it's up to you:

Andrey Nikolaevich, what's your hurry! He would have figured it out himself, but he would have remembered it better.
Reason: