Convertion need Mt4 into Afl - Demark Trendline Trader

#1
Please anybody convert demark trendline trader mt4 into afl

//+------------------------------------------------------------------+
//| Ind-TD-DeMark-3-1-LA-Mod-03B-AIME.mq4 |
//| Copyright 2005,Kara Software Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2005, Kara Software Corp."
#property link ""
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue /*Original #property indicator_color1 Red. Color of Upper TD Points*/
#property indicator_color2 Blue /*Original #property indicator_color2 Blue. Color of Lower TD Points*/
//---- input parameters
/* Mod 02: only one step, no back steps, only one target, no fractal trendlines,
no large arrow option for TD points, and added user changable colours and styles*/
/* Mod 03: Alerts Added. Horizontal Lines indicating where projections start from and
where alerts should be determined from re-enabled with Default of False.*/
/* Mod 03B: Bug where TD Points and TD Lines drawn in wrong place for
double, triple and quadruple tops or bottoms is fixed*/

extern bool AlertsOn = false; // Line added. Default is true.
extern bool Comments=true;/*Optional Comments. Default is false. Orginal variable called "Commen"*/
extern bool TrendLine=True;/*Default is true to draw current TD Lines*/
extern int TrendLineStyle=STYLE_DOT;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/
extern int TrendLineWidth=2;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5. Line of code added from original.*/
extern color UpperTrendLineColour=LimeGreen;/*Line of code added from original.*/
extern color LowerTrendLineColour=Red;/*Line of code added from original.*/
extern bool ProjectionLines=True;/*Default is True. These are the TD Price Projections. Original variable called "Take Prof"*/
extern int ProjectionLinesStyle=STYLE_SOLID;/*STYLE>_SOLID=0,DASH=1,_DOT=2,_DASHDOT=3,_DASHDDOTDOT=4. Line of code added from original.*/
extern int ProjectionLinesWidth=3;/*Thinnest or allow dots and dashes = 0 or 1, Thinner=2, Medium=3,Thicker=4,Thickest=5. Line of code added from original.*/
extern color UpperProjectionLineColour=Green;/*Line of code added from original.*/
extern color LowerProjectionLineColour=Crimson;/*Line of code added from original.*/
extern bool HorizontLine=False;/*Default is false. It seems the Horizontal Lines are were the code predicts price may cross TD line.*/

bool TD=true;/*Default is false. True setting draws up and down arrows instead of dots on TD Points creating more clutter.*/
int BackSteps=0;/*Used to be extern int now just int. Leave at 0*/
int ShowingSteps=1;/*Used to be extern int now just int. Leave at 1*/
bool FractalAsTD=true;/*Used to be extern bool now just bool. Leave at false, otherwise Trend Lines based on Fractal Points not TD Points*/


double TrendLineBreakUp=-1;//Line added.
bool TrendLineBreakUpFlag=False;//Line added.
double TrendLineBreakDown=-1;//Line added.
bool TrendLineBreakDownFlag=False;//Line added.

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//====================================================================
int init()
{
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,217);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,218);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
for (int i=1;i<=10;i++)
{
ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
ObjectDelete("HC1_"+i);
ObjectDelete("HC2_"+i);
ObjectDelete("HC3_"+i);
ObjectDelete("LC1_"+i);
ObjectDelete("LC2_"+i);
ObjectDelete("LC3_"+i);
}
Comment("");
return(0);
}
int deinit()
{
for (int i=1;i<=10;i++)
{
ObjectDelete("HHL_"+i);ObjectDelete("HL_"+i);
ObjectDelete("HLL_"+i);ObjectDelete("LL_"+i);
ObjectDelete("HC1_"+i);
ObjectDelete("HC2_"+i);
ObjectDelete("HC3_"+i);
ObjectDelete("LC1_"+i);
ObjectDelete("LC2_"+i);
ObjectDelete("LC3_"+i);
}
Comment("");
return(0);
}
//--------------------------------------------------------------------
int SetTDPoint(int B)//It seems B is the same as IndicatorCounted() function
{
int shift;
if (FractalAsTD==false)
{
//Print("B = ",B);
//Print("Bars = ",Bars);
//Print("IndicatorCounted() = ",IndicatorCounted());
for (shift=B;shift>1;shift--)
{
if (High[shift+1]<High[shift] && High[shift-1]<High[shift])// determine single top TD Point
ExtMapBuffer1[shift]=High[shift];// determine single top TD Point

if (High[shift+2]<High[shift] && High[shift+1]==High[shift]&& High[shift-1]<High[shift])//I added for double top
ExtMapBuffer1[shift]=High[shift];//I added for double top

if (High[shift+3]<High[shift] && High[shift+2]==High[shift]&& High[shift+1]==High[shift]//I added for triple top
&& High[shift-1]<High[shift])//I added for triple top
ExtMapBuffer1[shift]=High[shift];//I added for triple top

if (High[shift+4]<High[shift] && High[shift+3]==High[shift]&& High[shift+2]==High[shift]//I added for quadruple top
&& High[shift+1]==High[shift]//I added for quadruple top
&& High[shift-1]<High[shift])//I added for quadruple top
ExtMapBuffer1[shift]=High[shift];//I added for quadruple top

if (High[shift-1]>=High[shift])//I added for new way to determine Non-TD High Point
ExtMapBuffer1[shift]=0;//I added for new way to determine Non-TD High Point

//else ExtMapBuffer1[shift]=0;


if (Low[shift+1]>Low[shift] && Low[shift-1]>Low[shift])// determine single bottom TD Point
ExtMapBuffer2[shift]=Low[shift];// determine single bottom TD Point

if (Low[shift+2]>Low[shift] && Low[shift+1]==Low[shift] && Low[shift-1]>Low[shift])//I added for double bottom
ExtMapBuffer2[shift]=Low[shift];//I added for double bottom

if (Low[shift+3]>Low[shift] && Low[shift+2]==Low[shift] && Low[shift+1]==Low[shift]//I added for triple bottom
&& Low[shift-1]>Low[shift])//I added for triple bottom
ExtMapBuffer2[shift]=Low[shift];//I added for triple bottom

if (Low[shift+4]>Low[shift] && Low[shift+3]==Low[shift]&& Low[shift+2]==Low[shift] && Low[shift+1]==Low[shift]//I added for quadruple bottom
&& Low[shift-1]>Low[shift])//I added for quadruple bottom
ExtMapBuffer2[shift]=Low[shift];//I added for quadruple bottom

if (Low[shift-1]<=Low[shift])//I added
ExtMapBuffer2[shift]=0;//I added

//else ExtMapBuffer2[shift]=0;
}
ExtMapBuffer1[0]=0;
ExtMapBuffer2[0]=0;
ExtMapBuffer1[1]=0;
ExtMapBuffer2[1]=0;
}
else
{
for (shift=B;shift>3;shift--)
{
if (High[shift+1]<=High[shift] && High[shift-1]<High[shift] && High[shift+2]<=High[shift] && High[shift-2]<High[shift])
ExtMapBuffer1[shift]=High[shift];
else ExtMapBuffer1[shift]=0;
if (Low[shift+1]>=Low[shift] && Low[shift-1]>Low[shift] && Low[shift+2]>=Low[shift] && Low[shift-2]>Low[shift])
ExtMapBuffer2[shift]=Low[shift];
else ExtMapBuffer2[shift]=0;
}
ExtMapBuffer1[0]=0;
ExtMapBuffer2[0]=0;
ExtMapBuffer1[1]=0;
ExtMapBuffer2[1]=0;
ExtMapBuffer1[2]=0;
ExtMapBuffer2[2]=0;
}
return(0);
}
//--------------------------------------------------------------------
int GetHighTD(int P)
{
int i=0,j=0;
while (j<P)
{
i++;
while(ExtMapBuffer1==0)
{i++;if(i>Bars-2)return(-1);}
j++;
}
return (i);
}
//--------------------------------------------------------------------
int GetNextHighTD(int P)
{
int i=P+1;
while(ExtMapBuffer1<=High[P]){i++;if(i>Bars-2)return(-1);}
return (i);
}
//--------------------------------------------------------------------
int GetLowTD(int P)
{
int i=0,j=0;
while (j<P)
{
i++;
while(ExtMapBuffer2==0)
{i++;if(i>Bars-2)return(-1);}
j++;
}
return (i);
}
//--------------------------------------------------------------------
int GetNextLowTD(int P)
{
int i=P+1;
while(ExtMapBuffer2>=Low[P] || ExtMapBuffer2==0){i++;if(i>Bars-2)return(-1);}
return (i);
}
//--------------------------------------------------------------------
int TrendLineHighTD(int H1,int H2,int Step,int Col)/*Draw Upper Trend Line*/
{
ObjectSet("HL_"+Step,OBJPROP_TIME1,Time[H2]);ObjectSet("HL_"+Step,OBJPROP_TIME2,Time[H1]);
ObjectSet("HL_"+Step,OBJPROP_PRICE1,High[H2]);ObjectSet("HL_"+Step,OBJPROP_PRICE2,High[H1]);
ObjectSet("HL_"+Step,OBJPROP_COLOR,UpperTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
if (Step==1)ObjectSet("HL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
else ObjectSet("HL_"+Step,OBJPROP_WIDTH,1);
return(0);
}
//--------------------------------------------------------------------
int TrendLineLowTD(int L1,int L2,int Step,int Col)/*Draw Lower Trend Line*/
{
ObjectSet("LL_"+Step,OBJPROP_TIME1,Time[L2]);ObjectSet("LL_"+Step,OBJPROP_TIME2,Time[L1]);
ObjectSet("LL_"+Step,OBJPROP_PRICE1,Low[L2]);ObjectSet("LL_"+Step,OBJPROP_PRICE2,Low[L1]);
ObjectSet("LL_"+Step,OBJPROP_COLOR,LowerTrendLineColour);/*TEMP Original OBJPROP_COLOR,Col*/
if (Step==1)ObjectSet("LL_"+Step,OBJPROP_WIDTH,TrendLineWidth);/*Original OBJPROP_WIDTH,2*/
else ObjectSet("LL_"+Step,OBJPROP_WIDTH,1);
return(0);
}
//--------------------------------------------------------------------
int HorizontLineHighTD(int H1,int H2,int Step,double St,int Col)
{
ObjectSet("HHL_"+Step,OBJPROP_PRICE1,High[H2]-(High[H2]-High[H1])/(H2-H1)*H2);//HORIZONTAL HIGH LINE HEIGHT CALCULATION
ObjectSet("HHL_"+Step,OBJPROP_STYLE,St);
ObjectSet("HHL_"+Step,OBJPROP_COLOR,Col);
ObjectSet("HHL_"+Step,OBJPROP_BACK,True);//Line added
return(0);
}
//--------------------------------------------------------------------
int HorizontLineLowTD(int L1,int L2,int Step,double St,int Col)
{

ObjectSet("HLL_"+Step,OBJPROP_PRICE1,Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2);//HORIZONTAL LOW LINE HEIGHT CALCULATION
ObjectSet("HLL_"+Step,OBJPROP_STYLE,St);
ObjectSet("HLL_"+Step,OBJPROP_COLOR,Col);
ObjectSet("HLL_"+Step,OBJPROP_BACK,True);//Line added
return(0);
}
//--------------------------------------------------------------------
string TakeProfitHighTD(int H1,int H2,int Step,int Col)/*Draw Buy TD Price Projection(s)*/
{
int i,ii,j=0;
string Comm="";
double kH,HC1,HC2,HC3,k,St;
kH=(High[H2]-High[H1])/(H2-H1);
while (NormalizeDouble(Point,j)==0)j++;
k=0;
for(i=H1;i>0;i--)if(Close>High[H2]-kH*(H2-i)){k=High[H2]-kH*(H2-i);break;}
if (k>0)
{
Comm=Comm+"UTD_Line ("+DoubleToStr(High[H2]-kH*H2,j)+") broken at "+DoubleToStr(k,j)+", uptargets:\n";
ii=Lowest(NULL,0,MODE_LOW,H2-i,i);
HC1=High[H2]-kH*(H2-ii)-Low[ii];
HC2=High[H2]-kH*(H2-ii)-Close[ii];
ii=Lowest(NULL,0,MODE_CLOSE,H2-i,i);
HC3=High[H2]-kH*(H2-ii)-Close[ii];
St=TrendLineStyle;/*Original STYLE_SOLID*/
}
else
{
k=High[H2]-kH*H2;
Comm=Comm+"UTD_Line ("+DoubleToStr(k,j)+"), probable break-up targets:\n";
ii=Lowest(NULL,0,MODE_LOW,H2,0);
HC1=High[H2]-kH*(H2-ii)-Low[ii];
HC2=High[H2]-kH*(H2-ii)-Close[ii];
ii=Lowest(NULL,0,MODE_CLOSE,H2,0);
HC3=High[H2]-kH*(H2-ii)-Close[ii];
St=TrendLineStyle;/*Original STYLE_DASHDOT*/
}
ObjectSet("HL_"+Step,OBJPROP_STYLE,St);
Comm=Comm+"T1="+DoubleToStr(HC1+k,j)+" ("+DoubleToStr(HC1/Point,0)+"pts.)\n";//changed "pts.)" to "pts.)\n"
//Comm=Comm+" T2="+DoubleToStr(HC2+k,j)+" ("+DoubleToStr(HC2/Point,0)+"pts.)";
//Comm=Comm+" T3="+DoubleToStr(HC3+k,j)+" ("+DoubleToStr(HC3/Point,0)+"pts.)\n";
ObjectSet("HC1_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC1_"+Step,OBJPROP_TIME2,Time[0]);
ObjectSet("HC1_"+Step,OBJPROP_PRICE1,HC1+k);ObjectSet("HC1_"+Step,OBJPROP_PRICE2,HC1+k);
ObjectSet("HC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC1_"+Step,OBJPROP_STYLE,St);
//ObjectSet("HC2_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC2_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("HC2_"+Step,OBJPROP_PRICE1,HC2+k);ObjectSet("HC2_"+Step,OBJPROP_PRICE2,HC2+k);
//ObjectSet("HC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC2_"+Step,OBJPROP_STYLE,St);
//ObjectSet("HC3_"+Step,OBJPROP_TIME1,Time[H1]);ObjectSet("HC3_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("HC3_"+Step,OBJPROP_PRICE1,HC3+k);ObjectSet("HC3_"+Step,OBJPROP_PRICE2,HC3+k);
//ObjectSet("HC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("HC3_"+Step,OBJPROP_STYLE,St);
if (Step==1)
{
ObjectSet("HC1_"+Step,OBJPROP_WIDTH,ProjectionLinesWidth);/*Original OBJPROP_WIDTH,2*/
ObjectSet("HC1_"+Step,OBJPROP_STYLE,ProjectionLinesStyle);/*This Line of code added from original. TD Upper Projection Line Style*/
// ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
}
else
{
ObjectSet("HC1_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC2_"+Step,OBJPROP_WIDTH,2);
// ObjectSet("HC3_"+Step,OBJPROP_WIDTH,2);
}
return(Comm);
}
//--------------------------------------------------------------------
string TakeProfitLowTD(int L1,int L2,int Step,int Col)/*Draw Sell TD Price Projection(s)*/
{
int i,ii,j=0;
string Comm="";
double kL,LC1,LC2,LC3,k,St;
kL=(Low[L1]-Low[L2])/(L2-L1);
while (NormalizeDouble(Point,j)==0)j++;
k=0;
for(i=L1;i>0;i--)if(Close<Low[L2]+kL*(L2-i)){k=Low[L2]+kL*(L2-i);break;}
if (k>0)
{
Comm=Comm+"LTD_Line ("+DoubleToStr(Low[L2]+kL*L2,j)+") broken at "+DoubleToStr(k,j)+", downtargets:\n";
ii=Highest(NULL,0,MODE_HIGH,L2-i,i);
LC1=High[ii]-(Low[L2]+kL*(L2-ii));
LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
i=Highest(NULL,0,MODE_CLOSE,L2-i,i);
LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
St=TrendLineStyle;/*Original STYLE_SOLID*/
}
else
{
k=Low[L2]+kL*L2;
Comm=Comm+"LTD_Line ("+DoubleToStr(k,j)+"), probable downbreak targets:\n";
ii=Highest(NULL,0,MODE_HIGH,L2,0);
LC1=High[ii]-(Low[L2]+kL*(L2-ii));
LC2=Close[ii]-(Low[L2]+kL*(L2-ii));
ii=Highest(NULL,0,MODE_CLOSE,L2,0);
LC3=Close[ii]-(Low[L2]+kL*(L2-ii));
St=TrendLineStyle;/*Original STYLE_DASHDOT*/
}
ObjectSet("LL_"+Step,OBJPROP_STYLE,St);
Comm=Comm+"T1="+DoubleToStr(k-LC1,j)+" ("+DoubleToStr(LC1/Point,0)+"pts.)\n";//changed "pts.)" to "pts.)\n"
//Comm=Comm+" T2="+DoubleToStr(k-LC2,j)+" ("+DoubleToStr(LC2/Point,0)+"pts.)";
//Comm=Comm+" T3="+DoubleToStr(k-LC3,j)+" ("+DoubleToStr(LC3/Point,0)+"pts.)\n";
ObjectSet("LC1_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC1_"+Step,OBJPROP_TIME2,Time[0]);
ObjectSet("LC1_"+Step,OBJPROP_PRICE1,k-LC1);ObjectSet("LC1_"+Step,OBJPROP_PRICE2,k-LC1);
ObjectSet("LC1_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC1_"+Step,OBJPROP_STYLE,St);
//ObjectSet("LC2_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC2_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("LC2_"+Step,OBJPROP_PRICE1,k-LC2);ObjectSet("LC2_"+Step,OBJPROP_PRICE2,k-LC2);
//ObjectSet("LC2_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC2_"+Step,OBJPROP_STYLE,St);
//ObjectSet("LC3_"+Step,OBJPROP_TIME1,Time[L1]);ObjectSet("LC3_"+Step,OBJPROP_TIME2,Time[0]);
//ObjectSet("LC3_"+Step,OBJPROP_PRICE1,k-LC3);ObjectSet("LC3_"+Step,OBJPROP_PRICE2,k-LC3);
//ObjectSet("LC3_"+Step,OBJPROP_COLOR,Col);ObjectSet("LC3_"+Step,OBJPROP_STYLE,St);
if (Step==1)
{
ObjectSet("LC1_"+Step,OBJPROP_WIDTH,ProjectionLinesWidth);/*Original OBJPROP_WIDTH,2*/
ObjectSet("LC1_"+Step,OBJPROP_STYLE,ProjectionLinesStyle);/*This Line of code added from original. TD Lower Projection Line Style*/
//ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
//ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
}
else
{
ObjectSet("LC1_"+Step,OBJPROP_WIDTH,2);
//ObjectSet("LC2_"+Step,OBJPROP_WIDTH,2);
//ObjectSet("LC3_"+Step,OBJPROP_WIDTH,2);
}
return(Comm);
}
//--------------------------------------------------------------------
string TDMain(int Step)
{
int H1,H2,L1,L2;
string Comm="--- step "+Step+" --------------------\n";
int i,j; while (NormalizeDouble(Point,j)==0)j++;
double Style;
double Col[20];Col[0]=UpperProjectionLineColour/*Original Col[0]=Red, Colour for Current Upper TD Projection*/;Col[2]=Magenta;Col[4]=Chocolate;Col[6]=Goldenrod;Col[8]=SlateBlue;
Col[1]=LowerProjectionLineColour/*Original Col[1]=Blue, Colour for Current Lower TD Projection*/;Col[3]=FireBrick;Col[5]=Green;Col[7]=MediumOrchid;Col[9]=CornflowerBlue;
Col[10]=Red;Col[12]=Magenta;Col[14]=Chocolate;Col[16]=Goldenrod;Col[18]=SlateBlue;
Col[11]=Blue;Col[13]=FireBrick;Col[15]=Green;Col[17]=MediumOrchid;Col[19]=CornflowerBlue;
Step=Step+BackSteps;
H1=GetHighTD(Step);
H2=GetNextHighTD(H1);
L1=GetLowTD(Step);
L2=GetNextLowTD(L1);
TrendLineBreakUp=High[H2]-(High[H2]-High[H1])/(H2-H1)*H2;//added line
TrendLineBreakDown=Low[L2]+(Low[L1]-Low[L2])/(L2-L1)*L2;//added line
if (H1<0)Comm=Comm+"UTD no TD up-point \n";
else
if (H2<0)Comm=Comm+"UTD no TD point-upper then last one ("+DoubleToStr(High[H1],j)+")\n";
else Comm=Comm+"UTD "+DoubleToStr(High[H2],j)+" "+DoubleToStr(High[H1],j)+"\n";
if (L1<0)Comm=Comm+"LTD no TD down-point \n";
else
if (L2<0)Comm=Comm+"LTD no TD point-lower then last one ("+DoubleToStr(Low[L1],j)+")\n";
else Comm=Comm+"LTD "+DoubleToStr(Low[L2],j)+" "+DoubleToStr(Low[L1],j)+"\n";
//-----------------------------------------------------------------------------------
if (Step==1)Style=STYLE_SOLID;
else Style=STYLE_DOT;
if (H1>0 && H2>0)
{
if (TrendLine==1)
{
ObjectCreate("HL_"+Step,OBJ_TREND,0,0,0,0,0);
TrendLineHighTD(H1,H2,Step,Col[Step*2-2]);
}
else ObjectDelete("HL_"+Step);
if (HorizontLine==1 && Step==1)
{
ObjectCreate("HHL_"+Step,OBJ_HLINE,0,0,0,0,0);
ObjectSet("HHL_"+Step,OBJPROP_BACK,True);//Line added
HorizontLineHighTD(H1,H2,Step,Style,Col[Step*2-2]);
}
else ObjectDelete("HHL_"+Step);
if (ProjectionLines==1)
{
ObjectCreate("HC1_"+Step,OBJ_TREND,0,0,0,0,0);
ObjectCreate("HC2_"+Step,OBJ_TREND,0,0,0,0,0);
ObjectCreate("HC3_"+Step,OBJ_TREND,0,0,0,0,0);
Comm=Comm+TakeProfitHighTD(H1,H2,Step,Col[Step*2-2]);
}
else
{
ObjectDelete("HC1_"+Step);
ObjectDelete("HC2_"+Step);
ObjectDelete("HC3_"+Step);
}
}

//-----------------------------------------------------------------------------------
if (L1>0 && L2>0)
{
if (TrendLine==1)
{
ObjectCreate("LL_"+Step,OBJ_TREND,0,0,0,0,0);
TrendLineLowTD(L1,L2,Step,Col[Step*2-1]);
}
else ObjectDelete("LL_"+Step);
if (HorizontLine==1 && Step==1)
{
ObjectCreate("HLL_"+Step,OBJ_HLINE,0,0,0,0,0);
ObjectSet("HLL_"+Step,OBJPROP_BACK,True);//Line added
HorizontLineLowTD(L1,L2,Step,Style,Col[Step*2-1]);
}
else ObjectDelete("HLL_"+Step);
if (ProjectionLines==1)
{
ObjectCreate("LC1_"+Step,OBJ_TREND,0,0,0,0,0);
ObjectCreate("LC2_"+Step,OBJ_TREND,0,0,0,0,0);
ObjectCreate("LC3_"+Step,OBJ_TREND,0,0,0,0,0);
Comm=Comm+TakeProfitLowTD(L1,L2,Step,Col[Step*2-1]);
}
else
{
ObjectDelete("LC1_"+Step);
ObjectDelete("LC2_"+Step);
ObjectDelete("LC3_"+Step);
}
}
//--------------------------------------------------------------------
if(AlertsOn)//added this Alerts section
{
//Print("Alerts On");

if(Close[0]>TrendLineBreakUp && TrendLineBreakUpFlag==False)
{
//Print("Upper TrendLine Break ",Symbol()," ",Period()," ",Bid);
Alert("UTL Break>",TrendLineBreakUp," on ",Symbol()," ",Period()," @ ",Bid);
TrendLineBreakUpFlag=True;
}
if(Close[0]<TrendLineBreakDown && TrendLineBreakDownFlag==False)
{
//Print("Lower Trendline Break ",Symbol()," ",Period()," ",Bid);
Alert("LTL Break<",TrendLineBreakDown," on ",Symbol()," ",Period()," @ ",Bid);
TrendLineBreakDownFlag=True;
}
//--------------------------------------------------------------------
}
return(Comm);
}
//--------------------------------------------------------------------
int start()
{
string Comm="";
SetTDPoint(Bars-1);
if (TD==1)
{
SetIndexArrow(0,217);
SetIndexArrow(1,218);
}
else
{
SetIndexArrow(0,160);
SetIndexArrow(1,160);
}
if (ShowingSteps>10)
{
Comment("ShowingSteps readings 0 - 10");
return(0);
}
for (int i=1;i<=ShowingSteps;i++)Comm=Comm+TDMain(i);
Comm=Comm+"------------------------------------\nShowingSteps="+ShowingSteps+"\nBackSteps="+BackSteps;
if (FractalAsTD==true)Comm=Comm+"\nFractals";
else Comm=Comm+"\nTD point";
if (Comments==1)Comment(Comm);
else Comment("");
return(0);
}

//+------------------------------------------------------------------+
 

johnnypareek

Well-Known Member
#5
Hey,

Hm well its not the converted but I found it in my old pc.

HTML:
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	THIS SECTION DRAWS TD TREND LINES */

percent  = 0.5 * 1; /* Adjust this percent as necessary, I use .01 becauseFOREX is a 0.0000 number */
firstpointL = 2;
firstpointH = 2;

y0=LastValue(Trough(L,percent,firstpointL)); 
y1=LastValue(Trough(Ref(L,-1),percent,1));

for( i = 1; i < BarCount AND y0 >= y1; i++ )
{
		
		firstpointL++;	
		y0=LastValue(Trough(L,percent,firstpointL));		 
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL)); 
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1)); 
LineL = LineArray( x0, y0, x1, y1, 1 ); 

Plot(C, "C", colorBlack, styleCandle); 

Plot( LineL, " Support Trend line", colorWhite,4 +8 ); 


yt0=LastValue(Peak(H,percent,firstpointH)); 
yt1=LastValue(Peak(Ref(H,-1),percent,1));

for(i = 1; i < BarCount AND yt0 <= yt1; i++ )
{
		
		firstpointH++;		
		yt0=LastValue(Peak(H,percent,firstpointH)); 
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH)); 
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1)); 
LineH = LineArray( xt0, yt0, xt1, yt1, 1 ); 

Plot( LineH, "Resistance Trend line", colorBrown,4 + 8 ); 

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 
#7
Convertion need Mt4 into Afl - Freen wave FX

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 4.0
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 OrangeRed
#property indicator_color3 Lime
#property indicator_color4 OrangeRed
#property indicator_color5 Lime
#property indicator_color6 OrangeRed
#property indicator_color7 Lime
#property indicator_color8 OrangeRed

extern int price.x.offset = 0;
extern int price.y.offset = 0;
extern string myFont = "Arial Bold";
extern int myFontSize = 20;
extern int xStart = 0;
extern int xOffSet = 0;
extern int MAPeriod = 5;
extern int MAType = 1;
extern int BarWidth = 0;
extern color BarColorUp = Lime;
extern color BarColorDown = OrangeRed;
extern color TextColor = White;
extern int MaxBars = 500;
extern int myWingding = 110;
double gd_unused_136 = 1.0;
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
double g_ibuf_160[];
double g_ibuf_164[];
double g_ibuf_168[];
double g_ibuf_172[];
string gs_dummy_176;
double g_ima_184;
double g_ima_192;
string gs_unused_200 = "";
int gi_unused_208 = 888139;
string gs_212;
string gs_220;
int gi_unused_228;
int gi_236;
int gi_unused_240 = 255;
string gs_unused_244 = "Font Size";
int gi_unused_252 = 40;
string gs_unused_256 = "Font Type";
string gs_unused_264 = "Verdana";
string gs_unused_272 = ">>> CHECKING ACCOUNT <<<";
string gs_unused_280 = ">>> AUTHORIZATION <<<";
string g_name_288 = "cmtagtpbi01";
string g_name_296 = "cmtagtpbi02";

int init() {
gi_unused_228 = 1;
gs_220 = "GreenWaveFx " + Symbol() + Period();
gs_212 = gs_220 + "0";
IndicatorShortName(gs_220);
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorUp);
SetIndexArrow(0, myWingding);
SetIndexBuffer(0, g_ibuf_144);
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorDown);
SetIndexArrow(1, myWingding);
SetIndexBuffer(1, g_ibuf_148);
SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorUp);
SetIndexArrow(2, myWingding);
SetIndexBuffer(2, g_ibuf_152);
SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorDown);
SetIndexArrow(3, myWingding);
SetIndexBuffer(3, g_ibuf_156);
SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorUp);
SetIndexArrow(4, myWingding);
SetIndexBuffer(4, g_ibuf_160);
SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorDown);
SetIndexArrow(5, myWingding);
SetIndexBuffer(5, g_ibuf_164);
SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorUp);
SetIndexArrow(6, myWingding);
SetIndexBuffer(6, g_ibuf_168);
SetIndexStyle(7, DRAW_ARROW, STYLE_SOLID, BarWidth, BarColorDown);
SetIndexArrow(7, myWingding);
SetIndexBuffer(7, g_ibuf_172);
IndicatorDigits(0);
return (0);
}

int deinit() {
ObjectDelete(g_name_288);
ObjectDelete(g_name_296);
return (0);
}

int start() {
ObjectDelete(g_name_288);
ObjectDelete(g_name_296);
int li_0 = IndicatorCounted();
if (li_0 < 0) return (-1);
if (li_0 > 0) li_0--;
int li_4 = Bars - li_0;
if (gi_236 < Bars - 1) li_4 = Bars - 1;
for (int li_8 = 0; li_8 < li_4; li_8++) {
g_ibuf_148[li_8] = EMPTY_VALUE;
g_ibuf_144[li_8] = EMPTY_VALUE;
g_ibuf_156[li_8] = EMPTY_VALUE;
g_ibuf_152[li_8] = EMPTY_VALUE;
g_ibuf_164[li_8] = EMPTY_VALUE;
g_ibuf_160[li_8] = EMPTY_VALUE;
g_ibuf_172[li_8] = EMPTY_VALUE;
g_ibuf_168[li_8] = EMPTY_VALUE;
g_ima_184 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, li_8);
g_ima_192 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1);
if (g_ima_184 < g_ima_192) g_ibuf_148[li_8] = 2.5;
else g_ibuf_144[li_8] = 2.5;
g_ima_184 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_8);
g_ima_192 = iMA(NULL, 0, 10, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1);
if (g_ima_184 < g_ima_192) g_ibuf_156[li_8] = 2;
else g_ibuf_152[li_8] = 2;
g_ima_184 = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, li_8);
g_ima_192 = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1);
if (g_ima_184 < g_ima_192) g_ibuf_164[li_8] = 1.5;
else g_ibuf_160[li_8] = 1.5;
g_ima_184 = iMA(NULL, 0, 30, 0, MODE_EMA, PRICE_CLOSE, li_8);
g_ima_192 = iMA(NULL, 0, 30, 0, MODE_EMA, PRICE_CLOSE, li_8 + 1);
if (g_ima_184 < g_ima_192) g_ibuf_172[li_8] = 1;
else g_ibuf_168[li_8] = 1;
}
if (li_8 > gi_236) gi_236 = li_8;
return (0);
}
 
#8
Convertion need Mt4 into Afl - super scalper

/*
Generated by EX4-TO-MQ4 decompiler LITE V4.0.409.1e [-]
Website: https://purebeam.biz
E-mail : [email protected]
*/

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Yellow

extern int SignalPeriod = 144;
int gi_80 = 0;
extern int NR_SLIPE = 3;
int gi_88 = PRICE_CLOSE;
extern double FilterNumber = 1.0;
bool gi_100 = TRUE;
int gi_104 = 0;
extern int lineWidth = 3;
extern int barsToDrawLine = 300;
extern bool skipSingleBarSignal = FALSE;
extern int aTake_Profit = 500;
extern int aStop_Loss = 200;
extern bool aAlerts = TRUE;
extern bool EmailOn = TRUE;
datetime gt_136;
string gs_148;
string gs_156 = "fx_NR_Scalping";
double gda_164[];
double gda_168[];
double gda_172[];
double gda_176[];
int gi_180;
string gs_184;
int gi_192 = 0;

string GetTimeFrameStr() {
string ls_4;
switch (Period()) {
case PERIOD_M1:
ls_4 = "M1";
break;
case PERIOD_M5:
ls_4 = "M5";
break;
case PERIOD_M15:
ls_4 = "M15";
break;
case PERIOD_M30:
ls_4 = "M30";
break;
case PERIOD_H1:
ls_4 = "H1";
break;
case PERIOD_H4:
ls_4 = "H4";
break;
case PERIOD_D1:
ls_4 = "D1";
break;
case PERIOD_W1:
ls_4 = "W1";
break;
case PERIOD_MN1:
ls_4 = "MN1";
break;
default:
ls_4 = Period();
}
return (ls_4);
}

void DisplayAlert(string as_0, double ad_8, double ad_16, double ad_24) {
string ls_32;
string ls_40;
string ls_48;
string ls_56;
if (Time[0] != gt_136) {
gt_136 = Time[0];
if (gs_148 != as_0) {
gs_148 = as_0;
if (ad_8 != 0.0) ls_48 = " @ Price " + DoubleToStr(ad_8, 4);
else ls_48 = "";
if (ad_16 != 0.0) ls_40 = ", TakeProfit " + DoubleToStr(ad_16, 4);
else ls_40 = "";
if (ad_24 != 0.0) ls_32 = ", StopLoss " + DoubleToStr(ad_24, 4);
else ls_32 = "";
ls_56 = gs_184 + "Scalping " + aRperiodf() + " Alert " + as_0
+ "\n"
+ as_0 + ls_48 + ls_40 + ls_32
+ "\nDate & Time = " + TimeToStr(TimeCurrent(), TIME_DATE) + " " + TimeHour(TimeCurrent()) + ":" + TimeMinute(TimeCurrent()) + " ";
Alert(ls_56, Symbol(), ", ", Period(), " minutes chart");
PlaySound("alert.wav");
if (EmailOn) SendMail(gs_184, ls_56);
}
}
}

int init() {
IndicatorBuffers(4);
if ((!SetIndexBuffer(0, gda_164)) && !SetIndexBuffer(1, gda_168) && (!SetIndexBuffer(2, gda_172)) && (!SetIndexBuffer(3, gda_176))) Print("cannot set indicator buffers!");
if (gi_100) {
SetIndexStyle(0, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexStyle(1, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexStyle(2, DRAW_ARROW, EMPTY, lineWidth - 3);
SetIndexArrow(0, 159);
SetIndexArrow(1, 159);
SetIndexArrow(2, 159);
} else {
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
}
gi_180 = SignalPeriod + MathFloor(MathSqrt(SignalPeriod));
SetIndexDrawBegin(0, gi_180);
SetIndexDrawBegin(1, gi_180);
SetIndexDrawBegin(2, gi_180);
IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0);
IndicatorShortName("Scalping(" + SignalPeriod + ")");
SetIndexLabel(0, "Scalping");
gs_184 = Symbol() + " (" + GetTimeFrameStr() + "): ";
gs_148 = "";
ArrayInitialize(gda_164, EMPTY_VALUE);
ArrayInitialize(gda_172, EMPTY_VALUE);
ArrayInitialize(gda_168, EMPTY_VALUE);
return (0);
}

int deinit() {
DelObj();
return (0);
}

int start() {
double ld_20;
int li_28;
int li_8 = IndicatorCounted();
if (li_8 < 1) {
for (int li_4 = 0; li_4 <= gi_180; li_4++) gda_176[Bars - li_4] = 0;
for (li_4 = 0; li_4 <= SignalPeriod; li_4++) {
gda_164[Bars - li_4] = EMPTY_VALUE;
gda_168[Bars - li_4] = EMPTY_VALUE;
gda_172[Bars - li_4] = EMPTY_VALUE;
}
}
int li_0 = Bars - li_8;
for (li_4 = 1; li_4 < li_0; li_4++) gda_176[li_4] = 2.0 * iMA(NULL, 0, MathFloor(SignalPeriod / FilterNumber), gi_80, NR_SLIPE, gi_88, li_4) - iMA(NULL, 0, SignalPeriod, gi_80, NR_SLIPE, gi_88, li_4);
double ld_12 = iMAOnArray(gda_176, 0, MathFloor(MathSqrt(SignalPeriod)), 0, NR_SLIPE, 1);
for (li_4 = 2; li_4 < li_0 + 1; li_4++) {
ld_20 = iMAOnArray(gda_176, 0, MathFloor(MathSqrt(SignalPeriod)), 0, NR_SLIPE, li_4);
li_28 = 0;
if (ld_20 > ld_12) {
gda_172[li_4 - 1] = ld_12 - gi_104 * Point;
li_28 = 1;
} else {
if (ld_20 < ld_12) {
gda_164[li_4 - 1] = ld_12 + gi_104 * Point;
li_28 = 2;
} else {
gda_164[li_4 - 1] = EMPTY_VALUE;
gda_168[li_4 - 1] = ld_12;
gda_172[li_4 - 1] = EMPTY_VALUE;
li_28 = 3;
}
}
if (li_8 > 0) {
}
ld_12 = ld_20;
}
if (li_0 > barsToDrawLine) li_0 = barsToDrawLine;
for (li_4 = 2; li_4 <= li_0; li_4++) {
if (gda_164[li_4 - 1] != EMPTY_VALUE) {
if (gda_164[li_4] != EMPTY_VALUE) drawLineSegment(li_4 - 1, li_4, 1);
else drawLineSegment(li_4 - 1, li_4, 10);
}
if (gda_172[li_4 - 1] != EMPTY_VALUE) {
if (gda_172[li_4] != EMPTY_VALUE) {
drawLineSegment(li_4 - 1, li_4, -1);
continue;
}
drawLineSegment(li_4 - 1, li_4, -10);
}
}
if (aAlerts) {
if ((skipSingleBarSignal == FALSE && gda_172[1] != EMPTY_VALUE && gda_172[2] == EMPTY_VALUE) || (skipSingleBarSignal == TRUE && gda_172[1] != EMPTY_VALUE && gda_172[2] != EMPTY_VALUE &&
gda_172[3] == EMPTY_VALUE)) DisplayAlert("Sell signal", Close[1], aGetTPs(), aGetSLs());
if ((skipSingleBarSignal == FALSE && gda_164[1] != EMPTY_VALUE && gda_164[2] == EMPTY_VALUE) || (skipSingleBarSignal == TRUE && gda_164[1] != EMPTY_VALUE && gda_164[2] != EMPTY_VALUE &&
gda_164[3] == EMPTY_VALUE)) DisplayAlert("Buy signal", Close[1], aGetTPl(), aGetSLl());
}
return (0);
}

double aGetTPs() {
return (Bid - aTake_Profit * Point);
}

double aGetTPl() {
return (Ask + aTake_Profit * Point);
}

double aGetSLs() {
return (Bid + aStop_Loss * Point);
}

double aGetSLl() {
return (Ask - aStop_Loss * Point);
}

int aRperiodf() {
return (10000.0 * (SignalPeriod * Point));
}

void DelObj() {
string ls_0;
int li_12;
for (int li_8 = ObjectsTotal() - 1; li_8 >= 0; li_8--) {
ls_0 = ObjectName(li_8);
li_12 = StringLen(gs_156);
if (StringSubstr(ls_0, 0, li_12) == gs_156) ObjectDelete(ls_0);
}
}

void drawLineSegment(int ai_0, int ai_4, int ai_8) {
double ld_20;
double ld_28;
color li_36;
if (ai_8 > 0) {
ld_20 = gda_164[ai_0];
if (ai_8 == 1) ld_28 = gda_164[ai_4];
else ld_28 = gda_172[ai_4];
li_36 = Blue;
} else {
ld_20 = gda_172[ai_0];
if (ai_8 == -1) ld_28 = gda_172[ai_4];
else ld_28 = gda_164[ai_4];
li_36 = Yellow;
}
int li_12 = Time[ai_0];
int li_16 = Time[ai_4];
if (ld_20 == EMPTY_VALUE || ld_28 == EMPTY_VALUE) {
Print("Empty value for price line encountered!");
return;
}
string ls_40 = gs_156 + "_segment_" + li_36 + li_12 + "_" + li_16;
ObjectDelete(ls_40);
ObjectCreate(ls_40, OBJ_TREND, 0, li_12, ld_20, li_16, ld_28, 0, 0);
ObjectSet(ls_40, OBJPROP_WIDTH, lineWidth);
ObjectSet(ls_40, OBJPROP_COLOR, li_36);
ObjectSet(ls_40, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(ls_40, OBJPROP_RAY, FALSE);
}
 

Similar threads