<Deleted>
This is making so much more sense. thanks.
This is what i have brother, seems to be working quite well
if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)<iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0))||(iMACD(NULL,0,13,26,9,PRICE_CLOSE,MODE_MAIN,0)<iMACD(NULL,0,13,26,9,PRICE_CLOSE,MODE_SIGNAL,0))
^That's the buy
if((iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0))||(iMACD(NULL,0,13,26,9,PRICE_CLOSE,MODE_MAIN,0)>iMACD(NULL,0,13,26,9,PRICE_CLOSE,MODE_SIGNAL,0))
^ and that's the sell
Mind you there is more to it in order for it to work 100% with the use of other indicators
Moving average is OK but it isn't enough for 100% confirmation.
You really should add Stochastic in conjunction with it, i use a few other indicators but no offense i really don't want to give away all my secrets because i plan on selling my bot once I work out the few small bugs it is currently plagued with
- WindmillMQL: You are using iMA and IMACD incorrectly. you have to create a handle …No he's not; he just posted MT4 code in the wrong place. (The zero is the shift.)
double MyMovingAverage = iMA(_Symbol, _Period, 200, 0, MODE_EMA, PRICE_CLOSE, 0); double MACD = iMACD (_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
- xanderh: How can i get a MACD line and the Signal line alert at cross over?
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time post in the correct place. The moderators will likely move this thread there soon. -
You've got the current values. Get the previous ones and check for a cross.
double aPrev = …, aCurr = …, bPrev = …, bCurr = …; bool wasUp = aPrev > bPrev, isUp = aCurr > bCurr, isCross = isUp != wasUp;
- Colin Lundrigan: This is what i have brother, seems to be working quite wellOP asked for a cross, your code just returns a trend.
Please edit your post and use the code button(Alt+S) to paste code.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hiya,
i'm new to this, so please forgive me if its obvious :)
If i write the MACD code, double MACD = iMACD (_Symbol, _Period, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
How can i get a MACD line and the Signal line alert at cross over?
What i would like to make is,
When the price is Above the 200EMA and the MACD line crosses the Signal line to make a buy comment,
When the price is Below the 200EMA and the MACD line crosses the Signal line to make a sell comment.
So it would only Buy when above 200ema and only sell when below..
I've gotten this far;
But now i'm stuck haha