You are using the current bar in your calculation
The "close" price is the current and still changing price in the current bar, bar 0
Therefore, the calculation of the cross/no cross can change too
MacdCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,1);
MacdPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,2);
SignalCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,1);
SignalPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,2);
MacdHist = MacdCurrent - SignalCurrent;
if(MacdHist > 0 && MacdCurrent > SignalCurrent && MacdPrevious
< SignalPrevious)
-- Draw Arrow on bar 1
if(MacdHist < 0 && MacdCurrent < SignalCurrent && MacdPrevious
> SignalPrevious)
-- Draw Arrow on bar 1
The start of the current bar ( bar 0 ) is when you decide whether or not to take
a trade
based on the signal of the just completed bar
Ed
MacdCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,1);
MacdPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,2);
SignalCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,1);
SignalPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,2);
MacdHist = MacdCurrent - SignalCurrent;
if(MacdHist > 0 && MacdCurrent > SignalCurrent && MacdPrevious
< SignalPrevious)
-- Draw Arrow on bar 1
if(MacdHist < 0 && MacdCurrent < SignalCurrent && MacdPrevious
> SignalPrevious)
-- Draw Arrow on bar 1
The start of the current bar ( bar 0 ) is when you decide whether or not to take
a trade
based on the signal of the just completed bar
Not sure I follow this part:
"The start of the current bar ( bar 0 ) is when you decide whether or not to take a trade
based on the signal of the just completed bar". Can you explain?
Ed
Run the code on 1 minute chart and watch for a while.
There will never be a signal on the current bar.
If there is a new signal, it will appear on bar 1 as soon as a new bar 0 occurs.
Run the code on 1 minute chart and watch for a while.
There will never be a signal on the current bar.
If there is a new signal, it will appear on bar 1 as soon as a new bar 0 occurs.
Thanks,
Ed
Same.
I mentioned 1m chart so you could watch how it works in less than a week.
I give up. Anyone else care to comment?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Thanks very much in advance,
E
MacdCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,1);
MacdHist = MacdCurrent - SignalCurrent;
if(MacdHist > 0 && MacdCurrent > SignalCurrent && MacdPrevious < SignalPrevious)
-- Draw Arrow
if(MacdHist < 0 && MacdCurrent < SignalCurrent && MacdPrevious > SignalPrevious)
-- Draw Arrow