Code Library / Candlestick Patterns
MQL4 Morning Star
Detect morning star three-candle reversal pattern.
Language: MQL4 · Category: Candlestick Patterns · Tags: morning star, evening star, candlestick, MQL4, three-candle
Source code
bool IsMorningStar(int s) {
double b1=Close[s+2]-Open[s+2];
double b2=MathAbs(Close[s+1]-Open[s+1]);
double b3=Close[s]-Open[s];
if(b1>=0||MathAbs(b1)<(High[s+2]-Low[s+2])*0.5) return false;
if(b2>MathAbs(b1)*0.3) return false;
if(b3<=0||b3<MathAbs(b1)*0.5) return false;
return Close[s]>(Open[s+2]+Close[s+2])/2;
}How to use this snippet
This is a building block, not a finished trading system. Paste it into your own MQL4 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.