Hi! Can anybody turn this MQL4 indicator called Fractals into an AFL for Amibroker?

#1
Hi! Friends i am a successful trader & i have been trading for past 5 years and since i am getting too old for a visual method, i want to make my strategy completely mechanical so that i could trade my method(Strategy) easily.
To Achieve this goal i will be needing four Indicators, i have already found all the indicators in Amibroker but this Indicator called "Fractals" is not available in Amibroker, but its available in MT4.
So can anyone of you code this MQL4 Indicator in AFL?
i'l be very thankful & i'l also share my successful strategy with the person who will code this AFL.
Thanks.
 
#2
Re: Hi! Can anybody turn this MQL4 indicator called Fractals into an AFL for Amibroke

Here is the snapshot of Fractals Indicator in MT4, this is how it looks in MT4:
fractal.PNG
 
#3
Re: Hi! Can anybody turn this MQL4 indicator called Fractals into an AFL for Amibroke

And here is the MQL4 code of MT4, we need to convert this code into an AFL:




#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters

//---- buffers
double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,ExtUpFractalsBuffer);
SetIndexBuffer(1,ExtDownFractalsBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,119);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,119);
//----
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
SetIndexLabel(0,"Fractal Up");
SetIndexLabel(1,"Fractal Down");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i,nCountedBars;
bool bFound;
double dCurrent;
nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
if(nCountedBars<=2)
i=Bars-nCountedBars-3;
if(nCountedBars>2)
{
nCountedBars--;
i=Bars-nCountedBars-1;
}
//----Up and Down Fractals
while(i>=2)
{
//----Fractals up
bFound=false;
dCurrent=High;
if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i-1] && dCurrent>High[i-2])
{
bFound=true;
ExtUpFractalsBuffer=dCurrent;
}
//----6 bars Fractal
if(!bFound && (Bars-i-1)>=3)
{
if(dCurrent==High[i+1] && dCurrent>High[i+2] && dCurrent>High[i+3] &&
dCurrent>High[i-1] && dCurrent>High[i-2])
{
bFound=true;
ExtUpFractalsBuffer=dCurrent;
}
}
//----7 bars Fractal
if(!bFound && (Bars-i-1)>=4)
{
if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent>High[i+3] && dCurrent>High[i+4] &&
dCurrent>High[i-1] && dCurrent>High[i-2])
{
bFound=true;
ExtUpFractalsBuffer=dCurrent;
}
}
//----8 bars Fractal
if(!bFound && (Bars-i-1)>=5)
{
if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent==High[i+3] && dCurrent>High[i+4] && dCurrent>High[i+5] &&
dCurrent>High[i-1] && dCurrent>High[i-2])
{
bFound=true;
ExtUpFractalsBuffer=dCurrent;
}
}
//----9 bars Fractal
if(!bFound && (Bars-i-1)>=6)
{
if(dCurrent>=High[i+1] && dCurrent==High[i+2] && dCurrent>=High[i+3] && dCurrent==High[i+4] && dCurrent>High[i+5] &&
dCurrent>High[i+6] && dCurrent>High[i-1] && dCurrent>High[i-2])
{
bFound=true;
ExtUpFractalsBuffer=dCurrent;
}
}
//----Fractals down
bFound=false;
dCurrent=Low;
if(dCurrent<Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i-1] && dCurrent<Low[i-2])
{
bFound=true;
ExtDownFractalsBuffer=dCurrent;
}
//----6 bars Fractal
if(!bFound && (Bars-i-1)>=3)
{
if(dCurrent==Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i+3] &&
dCurrent<Low[i-1] && dCurrent<Low[i-2])
{
bFound=true;
ExtDownFractalsBuffer=dCurrent;
}
}
//----7 bars Fractal
if(!bFound && (Bars-i-1)>=4)
{
if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<Low[i+3] && dCurrent<Low[i+4] &&
dCurrent<Low[i-1] && dCurrent<Low[i-2])
{
bFound=true;
ExtDownFractalsBuffer=dCurrent;
}
}
//----8 bars Fractal
if(!bFound && (Bars-i-1)>=5)
{
if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent==Low[i+3] && dCurrent<Low[i+4] && dCurrent<Low[i+5] &&
dCurrent<Low[i-1] && dCurrent<Low[i-2])
{
bFound=true;
ExtDownFractalsBuffer=dCurrent;
}
}
//----9 bars Fractal
if(!bFound && (Bars-i-1)>=6)
{
if(dCurrent<=Low[i+1] && dCurrent==Low[i+2] && dCurrent<=Low[i+3] && dCurrent==Low[i+4] && dCurrent<Low[i+5] &&
dCurrent<Low[i+6] && dCurrent<Low[i-1] && dCurrent<Low[i-2])
{
bFound=true;
ExtDownFractalsBuffer=dCurrent;
}
}
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
 

colion

Active Member
#4
Re: Hi! Can anybody turn this MQL4 indicator called Fractals into an AFL for Amibroke

There are several fractal codes in the AmiBroker library on the members page.
 

Similar threads