# Effective AFL. Please, We need signals of buying and selling!!

#### NeSanches

##### New Member
Hello friends. Could someone please put signals of buying and selling in this formula so I can do backtests? It is an excellent formula and really effective!
Since already thank you very much,

// E.M.Pottasch, Jul 2010
// from Metastock formula, link: http://stocata.org/metastock/stop_trail_atr.html
// added separate parameters for upward and downward market environment

function vstop_func(trBull,trBear)
{
trailArray[ 0 ] = C[ 0 ]; // initialize
for( i = 1; i < BarCount; i++ )
{
prev = trailArray[ i - 1 ];

if (C[ i ] > prev AND C[ i - 1 ] > prev)
{
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
}
else if (C[ i ] < prev AND C[ i - 1 ] < prev)
{
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
}
else if (C[ i ] > prev)
{
trailArray[ i ] = C[ i ] - trBull[ i ];
}
else
{
trailArray[ i ] = C[ i ] + trBear[ i ];
}
}
return trailArray;
}

per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);

trBull = multBull * ATR(per);
trBear = multBear * ATR(per);

trailArray = vstop_func(trBull,trBear);

SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(IIf(trailArray > C,trailArray,Null),"\ntrailShort",ParamColor("ColorTrailShort",ColorRGB(255,0,0)),styleStaircase);
Plot(IIf(trailArray < C,trailArray,Null),"\ntrailLong",ParamColor("ColorTrailLong",ColorRGB(0,255,0)),styleStaircase);
Plot( C, "\nCandle",colorWhite, styleCandle );

#### ford7k

##### Banned
hi
If you want to use it on intraday trading,
change settings in parameters for
multbull =1.5 (use 2 only for Eod based swing trading)
multbear =1.5 (use 2 only for daily basd swing trading)

CODE FOR BUY SELL ARROWS
//Buysell arrows(IF CHART IS BLACK BACKGROUND)

Sell = Cross(trailarray,C);
//shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
shape = Buy * shapeUpTriangle + Sell * shapeDownTriangle;

PlotShapes( shape, IIf( Buy, colorBrightGreen, colorYellow ), 0, IIf( Buy, Low, High ) );

WHAT DOES IT MEAN IF YOU SEE TOO MANY BUY AND SELL SIGNALS?
IT MEANS YOU CHOSE A WRONG TIMEFRAME & YOU ARE ONLY TRYING TO GET THINGS WRONG