Your problem is that your code is executed every tick, and that you are getting
the MACD value of the previous bar, not the previous tick. Change it to this:
double MACDPrevious = 0; int start() { //---- double MACDCurrent; MACDCurrent = iMACD(NULL,0,5,13,1,PRICE_CLOSE,MODE_MAIN,0); Print("MACDCurrent is " + MACDCurrent + " and MACDPrevious is " + MACDPrevious); MACDPrevious = MACDCurrent; //---- return(0); }
Thanks.
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
As you can see, I am printing the values in order. But when i look at logs, MACDPrevious value doesn't match the previous MACDCurrent... How can i take the value of previous MACD? I think my problem is clear.
If it is important i use the following
Symbol: EURUSD
Period: H4
Model: Open prices only (I tried others)
Use date: From 2007.02.01 to 2007.02.07
Thanks...
PS:I looked "MACD Sample" EA that comes with setup and it has the same usage...