tzm:
"Always in motion the future is."
Dear all,
I have write a simplified version of MACD to show the rise and fall of the MACD historgram(the difference of the MACD line and the macd signal line). I use the following code to show a 1 to indicate the historgram is rising , a -1 to indicate the historgram value is falling.the histupdn[] is the buffer used to be shown
But the result it not as what I expected whatever I expected no matter how hard I tried. As shown in the figured below, the histogram value is falling, but the histupdn[] value is always 1.
the code that I used to show the MACD histogram is attached for some nice man to check it up....
Many thanks for your time and efforts, and your prompt reply.
tzm: But the result it not as what I expected
ArrayResize(diff,limit+2); ArrayResize(dea,limit+2); ArrayResize(hist,limit+2); for(int i=0; i<limit; i++) diff[i]=iMA(.. for(i=0; i<limit; i++) dea[i]=iMAOnArray(diff,Bars,SignalSMA,0,MODE_SMA,i);
- After the first time, limit is 1, so diff is 3 elements. How can you do a SignalSMA (9) period SMA on 3 elements?
- Drop those arrayResize's and make them indicator buffers.
- The decrement counted is not necessary
- Don't look at the future
for(i=1; i<limit; i++){ if(hist[i]>hist[i-1]) histupdn[i]=1; if(hist[i]<hist[i-1]) histupdn[i]=-1;
for(i=0; i<limit; i++){ if(hist[i]>hist[i+1]) histupdn[i]=1; else histupdn[i]=-1;
- Get in the habit of counting down.
WHRoeder:
- After the first time, limit is 1, so diff is 3 elements. How can you do a SignalSMA (9) period SMA on 3 elements?
- Drop those arrayResize's and make them indicator buffers.
- The decrement counted is not necessary
- Don't look at the future
- Get in the habit of counting down.
Dear WHRoeder:
Thank you for your prompt reply. After following the instructions in your reply. I got the expected result.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
But the result it not as what I expected whatever I expected no matter how hard I tried. As shown in the figure below, the histogram value is falling, but the histupdn[] value is always 1.The upper part is a normal chart. the middle part of the figure is the output of a normal MACD indicator. The lower part of the figure is the output to indicate the rise and fall of the MACD histogram.