This is trend manager indicator of meta trader can any1 covert into afl ???

rocky01

Active Member
#1
Hi friends
trend manager indicator of meta trader and amibroker..!!!!

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int TM_Period = 7;
extern int TM_Shift = 2;

double SpanA_Buffer[];
double SpanB_Buffer[];
int a_begin;

int init()
{
a_begin=TM_Shift;
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(0,SpanB_Buffer);
SetIndexDrawBegin(0,TM_Period+a_begin-1);
SetIndexLabel(0,"TM_Period+");
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
SetIndexBuffer(1,SpanA_Buffer);
SetIndexDrawBegin(1,TM_Period+a_begin-1);
SetIndexLabel(1,"TM_Period");

return(0);
}

int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double high,low,price;

if(Bars<=TM_Period) return(0);
if(counted_bars<1)
{
for(i=1;i<=TM_Period;i++)
{
SpanA_Buffer[Bars-i]=0;
SpanB_Buffer[Bars-i]=0;
}
}

i=Bars-TM_Period;
if(counted_bars>TM_Period) i=Bars-counted_bars-1;
while(i>=0)
{
high=High; low=Low; k=i-1+TM_Period;
while(k>=i)
{
price=High[k];
if(high<price) high=price;
price=Low[k];
if(low>price) low=price;
k--;
}
SpanA_Buffer = (high+low)/2.0;
SpanB_Buffer = SpanA_Buffer[i+TM_Shift];
i--;
}

return(0);
}
 
Last edited:

rocky01

Active Member
#2
ITS A GREAT INDICATOR,IT CAN BE HELPFULL A LOT IF ANY ONE CAN CONVERT INTO AFL.IS THERE ANY ONE WHO CAN MAKE THIS POSSIBLE?:confused::confused::confused:
 

leo_3455

Active Member
#3
Mr. Karthikmarar has posted the AFL in another forum. I leave it to him to post the AFL here. :thumb:
 

rocky01

Active Member
#5
HEY GUYES HERE R D NICE INDICATOR FOR YOU ALL.........SIMPLY NJOY..

_SECTION_BEGIN("Trend manager");

//AFL works on amibroker version 5.20 and above
SetChartBkColor(colorpaleblue);
p=Param("period",7,3,20,1);
pl1=ParamToggle("Plot Stoploss line","No,Yes",0);
pl2=ParamToggle("Plot Setup signals","No,Yes",0);


Hx=IIf(H<Ref(H,-p),Ref(H,-p),H);
Lx=IIf(L>Ref(L,-p),Ref(L,-p),L);

Hxl=IIf(H<Ref(H,-p),Ref(H,-p),H);
Lxl=IIf(L>Ref(L,-p),Ref(L,-p),L);
spana=(Hx+Lx)/2;
spanb=Ref(spana,-2);
for( i = p; i < BarCount; i++ )
{
if (spana>spanb)
{
H1=spana;
L1=spanb;
O1=L1;
C1=H1;
}
else
{
H1=spanb;
L1=spana;
O1=H1;
C1=L1;
}
}

PlotOHLC(O1,H1,L1,C1,"",IIf(C>spanb,colorBlue,colorRed),ParamStyle("Plot Style",styleBar,maskPrice));
Plot(C,"",ParamColor("Bar Color",colorLime),128+4);
pd=(C>spanb AND Ref(C,-1)>Ref(spanb,-1));
nd=(C<spana AND Ref(C,-1)<Ref(spana,-1));
Buysetup= PD;
Shortsetup=nd;
Buysetupvalid=Flip (Buysetup, Shortsetup);
Shortsetupvalid=Flip (Shortsetup, Buysetup);
Buy=Cover= Ref (Buysetupvalid, - 1) ==1 AND H>ValueWhen (buysetup, H) +0.01;
Short=Sell=Ref (Shortsetupvalid, - 1) ==1 AND L<ValueWhen (Shortsetup, L) - 0.01;
Buy=ExRem (Buy, Sell);
Sell=ExRem (Sell, Buy);
Short=ExRem (Short, Cover);
Cover=ExRem (Cover, Short);
inlong=Flip(Buy,Sell);
inshort=Flip(Sell,Buy);
Plot(IIf(Buysetup AND pl1,spanb,Null),"",colorRed,styleDashed);
Plot(IIf(shortsetup AND pl1,spanb,Null),"",colorRed,styleDashed);
shortsetupvalid=ExRem (shortsetupvalid, buysetupvalid);
buysetupvalid=ExRem (buysetupvalid, shortsetupvalid);
PlotShapes (IIf (shortsetupvalid AND pl2,shapeDownTriangle, shapeNone), colorRed, 0, H, - 40);
PlotShapes (IIf (buysetupvalid AND pl2,shapeUpTriangle, shapeNone), colorGreen, 0, L, - 40);


SetChartOptions(0,chartShowArrows|chartShowDates);
Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )+
"\n"+"tm High = "+WriteVal(spana,1.4)
+ "\n"+"tm Low = "+WriteVal(spanb,1.4);
_SECTION_END();


ready for your reactions.....!!
 

karthikmarar

Well-Known Member
#9
Please note that the afl works only on Amibroker version 5.10 and above.

Following is the code for lower versions

_SECTION_BEGIN("Trend manager");
//Trend Manager- Translated by karthikmarar from MT4 code
//AFL works on amibroker version 5.20 and above
SetChartBkColor(colorBlack);
p=Param("period",7,3,20,1);
pl1=ParamToggle("Plot Stoploss line","No,Yes",0);
pl2=ParamToggle("Plot Setup signals","No,Yes",0);


Hx=IIf(H<Ref(H,-p),Ref(H,-p),H);
Lx=IIf(L>Ref(L,-p),Ref(L,-p),L);

Hxl=IIf(H<Ref(H,-p),Ref(H,-p),H);
Lxl=IIf(L>Ref(L,-p),Ref(L,-p),L);
spana=(Hx+Lx)/2;
spanb=Ref(spana,-2);
for( i = p; i < BarCount; i++ )
{
if (spana>spanb)
{
H1=spana;
L1=spanb;
O1=L1;
C1=H1;
}
else
{
H1=spanb;
L1=spana;
O1=H1;
C1=L1;
}
}

PlotOHLC(O1,H1,L1,C1,"",IIf(C>spanb,colorBlue,colorRed),ParamStyle("Plot Style",styleBar,maskPrice));
Plot(C,"",ParamColor("Bar Color",colorLime),128+4);
pd=(C>spanb AND Ref(C,-1)>Ref(spanb,-1));
nd=(C<spana AND Ref(C,-1)<Ref(spana,-1));
Buysetup= PD;
Shortsetup=nd;
Buysetupvalid=Flip (Buysetup, Shortsetup);
Shortsetupvalid=Flip (Shortsetup, Buysetup);
Buy=Cover= Ref (Buysetupvalid, - 1) ==1 AND H>ValueWhen (buysetup, H) +0.01;
Short=Sell=Ref (Shortsetupvalid, - 1) ==1 AND L<ValueWhen (Shortsetup, L) - 0.01;
Buy=ExRem (Buy, Sell);
Sell=ExRem (Sell, Buy);
Short=ExRem (Short, Cover);
Cover=ExRem (Cover, Short);
inlong=Flip(Buy,Sell);
inshort=Flip(Sell,Buy);
Plot(IIf(Buysetup AND pl1,spanb,Null),"",colorRed,styleDashed);
Plot(IIf(shortsetup AND pl1,spanb,Null),"",colorRed,styleDashed);
shortsetupvalid=ExRem (shortsetupvalid, buysetupvalid);
buysetupvalid=ExRem (buysetupvalid, shortsetupvalid);
PlotShapes (IIf (shortsetupvalid AND pl2,shapeDownTriangle, shapeNone), colorRed, 0, H, - 40);
PlotShapes (IIf (buysetupvalid AND pl2,shapeUpTriangle, shapeNone), colorGreen, 0, L, - 40);


SetChartOptions(0,chartShowArrows|chartShowDates);
Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )+
"\n"+"tm High = "+WriteVal(spana,1.4)
+ "\n"+"tm Low = "+WriteVal(spanb,1.4);
_SECTION_END();
 

karthikmarar

Well-Known Member
#10
Also please note this system is under discussion and evaluation elsewhere...

This is system is prove to whipsaws and I would suggest people to wait till we get a good workable system out of this.

Not all Metatrader indicators work well on stocks. There has to be some tweaks to make them work with stocks..
 

Similar threads