In my first indicator, I am attempting something very simple which I am having difficulties in getting it to work correctly.
I want to draw a Buy Arrow (UP Arrow ) on Chart just below the Candle whenever MACD's Signal Crosses above MACD.
Opposite end will be done once I get past this initial hurdles.
I've attempted all functions that I could find and all of them show zero in Macd Buffer and Signal Buffer.
<SNIP>
Please use this to post code . . . it makes it easier to read.
i-1 is the future, you can't trigger the future.
if you count down, you don't need 3 separate loops.
for(i=limit-1; i>=0; i--){ double fast = iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i), slow = iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i); Macd[i]=fast-slow; SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i); // you mean Macd[] bool wasAbove = Macd[i+] > SignalBuffer[i+], isAbove = Macd[i] > SignalBuffer[i], isCross = WasAbove != isAbove; // alternately //bool isCross = (Macd[i+] - SignalBuffer[i+]) * (Macd[i] - SignalBuffer[i]) < 0; }
Only MT4 provides a MACD with one line + histogram and that uses a SMA for the signal.
The other chart providers use a MACD with two lines + histogram and those use a EMA for the signal.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
In my first indicator, I am attempting something very simple which I am having difficulties in getting it to work correctly.
I want to draw a Buy Arrow (UP Arrow ) on Chart just below the Candle whenever MACD's Signal Crosses above MACD.
Opposite end will be done once I get past this initial hurdles.
I've attempted all functions that I could find and all of them show zero in Macd Buffer and Signal Buffer.
OR
Also attempted to compute MACD by steps of first computing difference of fast and slow MA
and then MA on difference
None of the methods produce expected result. What am I doing wrong?
Except for iMaOnArray, none of the function have even report error. iMaOnArray reported error in log file that it will not work on Series Array. At one point, I had tried to pass Close[] Array to the function.
To determine a Cross, I wrote this function
Should I use i-1 or i+1 in this function? Tried both and Neither works!!!