Code Library / Fibonacci
MQL4 Fibonacci Extensions
Calculate Fibonacci extension TP targets.
Language: MQL4 · Category: Fibonacci · Tags: Fibonacci, extension, MQL4, take profit, targets
Source code
struct FibExt { double ratio; double price; };
void CalcExt(FibExt &e[],double lo,double hi,double retrace) {
double imp=hi-lo;
double r[]={0.618,1.0,1.272,1.618,2.0,2.618};
ArrayResize(e,6);
for(int i=0;i<6;i++){e[i].ratio=r[i];e[i].price=retrace+imp*r[i];}
}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.