Hi, the problem is probably not the zero crossing but the crossing from one buffer to another. At one bar the signal ends and at the next bar the signal is already in another buffer, what colour would you like to see between the two adjacent bars? It is not clear.
If you want to make a third buffer with a yellow line and put it under these two, it would be beautiful!
Hi, the problem is probably not the zero crossing but the crossing from one buffer to another. At one bar the signal ends and at the next bar the signal is already in another buffer, what colour would you like to see between the two adjacent bars? It is not clear.
If you want, make a third buffer with a yellow line and put it under these two, it will be beautiful!
Alexey, thanks for the help.
I don't need three colours, two is quite enough. I would like the empty spaces to be drawn with a line of the previous colour. I do not understand what you mean by " On one bar the signal is over, and on the next bar the signal is in a different buffer". At each bar, there is a value in one of the buffers, so it should also be displayed on the chart, or am I missing something?
Well look, time is discrete on the chart, the minimum unit is 1 bar. That is, there is no partial time between bars, as it were. If you replace the rendering with a bar chart, you have two bars - two bars of different colours. But there is nothing between them. And the line is drawn in such a way (such a property is made) that it connects values of the same buffer, but not different ones. That's why there are holes.
If you want it for beauty, then you can try giving the end values overlapping on both buffers. You signal to the new buffer, but still signal to the old one bar.
But if you then take the signal from such indicator into Expert Advisor, it will be inaccurate.
Or a histogram is a good option without any extra hassle. I vote for the bar chart.
I don't need three colours, two is quite enough. I would like the empty spaces to be drawn with a line of the previous colour. I don't understand what you mean by " At one bar the signal ends, and at the next bar the signal is already in another buffer". At each bar, there is a value in one of the buffers, it means that it should be displayed on the chart, or am I missing something?
leave one buffer without conditions and overlay the second one with conditions on the first one
#property strict#property indicator_separate_window#property indicator_buffers2#property indicator_color1clrGreen#property indicator_color2clrRed//---- input parametersexternint FastEMA=12;
externint SlowEMA=26;
externint Signal=9;
//---- buffersdouble DiffBuffer_up[];
double DiffBuffer_dn[];
//double MainBuffer[];
double SignalBuffer[];
ENUM_TIMEFRAMES TimeFrame;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
int draw_begin=MathMax(FastEMA,SlowEMA);
string short_name="MACD Stephen";
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,DiffBuffer_up);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,DiffBuffer_dn);
short_name=StringConcatenate(short_name," ("+(string)FastEMA+","+(string)SlowEMA+","+(string)Signal+")");
IndicatorShortName(short_name);
SetIndexDrawBegin(0,draw_begin);
SetIndexDrawBegin(1,draw_begin);
SetIndexLabel(0,"Up");
SetIndexLabel(1,"Down");
IndicatorDigits(6);
SetLevelValue(0,0);
TimeFrame=GetTF();
return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start()
{
int limit, iChart, iTF, delta=0;
datetime TimeArray[];
//if(TimeFrame>Period()) delta=(int)MathCeil(TimeFrame/Period());int counted_bars=IndicatorCounted();
//---- check for possible errorsif(counted_bars<0) return(-1);
//---- the last counted bar will be recountedif(counted_bars>0) counted_bars--;
limit=Bars-counted_bars+delta;
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
ArraySetAsSeries(MainBuffer,true);
ArraySetAsSeries(SignalBuffer,true);
ArrayResize(MainBuffer, 100000);
ArrayResize(SignalBuffer,100000);
iTF=0;
for(iChart=0; iChart<limit; iChart++)
{
while(Time[iChart]<TimeArray[iTF]) iTF++;
MainBuffer[iChart]=EMPTY_VALUE;
SignalBuffer[iChart]=EMPTY_VALUE;
MainBuffer[iChart] =iMACD(Symbol(),TimeFrame,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_MAIN,iTF);
SignalBuffer[iChart]=iMACD(Symbol(),TimeFrame,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_SIGNAL,iTF);
double diff=MainBuffer[iChart]-SignalBuffer[iChart];
DiffBuffer_up[iChart]=diff;
if (diff>0) //{
DiffBuffer_dn[iChart]=diff;
//DiffBuffer_dn[iChart]=EMPTY_VALUE;//}//else {//DiffBuffer_up[iChart]=EMPTY_VALUE;//}
}
return(0);
}
Well look, time is discrete on the chart, the minimum unit is 1 bar. That is, there is no partial time between bars, as it were. If you replace the rendering with a bar chart, you have two bars - two bars of different colours. But there is nothing between them. And the line is drawn in such a way (such a property is made) that it connects values of the same buffer, but not different ones. That's why there are holes.
If you want it for beauty, then you can try giving the end values overlapping on both buffers. You signal to the new buffer, but still signal to the old one bar.
But if you then take the signal from such indicator into Expert Advisor, it will be inaccurate.
Or a histogram is a good option without any extra hassle. I vote for the bar chart.
My sincere thanks Aleksey.
Now even my head is all sorted out. I could have done it myself, but not as short and elegant as Yuri's subsequent advice.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi, the problem is probably not the zero crossing but the crossing from one buffer to another. At one bar the signal ends and at the next bar the signal is already in another buffer, what colour would you like to see between the two adjacent bars? It is not clear.
If you want to make a third buffer with a yellow line and put it under these two, it would be beautiful!
Hi, the problem is probably not the zero crossing but the crossing from one buffer to another. At one bar the signal ends and at the next bar the signal is already in another buffer, what colour would you like to see between the two adjacent bars? It is not clear.
If you want, make a third buffer with a yellow line and put it under these two, it will be beautiful!
Alexey, thanks for the help.
I don't need three colours, two is quite enough. I would like the empty spaces to be drawn with a line of the previous colour. I do not understand what you mean by " On one bar the signal is over, and on the next bar the signal is in a different buffer". At each bar, there is a value in one of the buffers, so it should also be displayed on the chart, or am I missing something?
Well look, time is discrete on the chart, the minimum unit is 1 bar. That is, there is no partial time between bars, as it were. If you replace the rendering with a bar chart, you have two bars - two bars of different colours. But there is nothing between them. And the line is drawn in such a way (such a property is made) that it connects values of the same buffer, but not different ones. That's why there are holes.
If you want it for beauty, then you can try giving the end values overlapping on both buffers. You signal to the new buffer, but still signal to the old one bar.
But if you then take the signal from such indicator into Expert Advisor, it will be inaccurate.
Or a histogram is a good option without any extra hassle. I vote for the bar chart.
Alexei, thank you for your help.
I don't need three colours, two is quite enough. I would like the empty spaces to be drawn with a line of the previous colour. I don't understand what you mean by " At one bar the signal ends, and at the next bar the signal is already in another buffer". At each bar, there is a value in one of the buffers, it means that it should be displayed on the chart, or am I missing something?
leave one buffer without conditions and overlay the second one with conditions on the first one
Well look, time is discrete on the chart, the minimum unit is 1 bar. That is, there is no partial time between bars, as it were. If you replace the rendering with a bar chart, you have two bars - two bars of different colours. But there is nothing between them. And the line is drawn in such a way (such a property is made) that it connects values of the same buffer, but not different ones. That's why there are holes.
If you want it for beauty, then you can try giving the end values overlapping on both buffers. You signal to the new buffer, but still signal to the old one bar.
But if you then take the signal from such indicator into Expert Advisor, it will be inaccurate.
Or a histogram is a good option without any extra hassle. I vote for the bar chart.
My sincere thanks Aleksey.
Now even my head is all sorted out. I could have done it myself, but not as short and elegant as Yuri's subsequent advice.
leave one buffer unconditional, and overlay the second with conditions on the first
Hats off to you, Yuri.
Such an elegant and concise solution I couldn't have imagined.
Hats off to you, Yuri.
I couldn't have imagined such an elegant and concise solution.
it was not my idea, here on the forum, just like you found out
there are a lot of solutions in the code base, and not only that
Thanks for the thanks!
Why do my questions keep getting ignored?
depends on the questions...