# Buy and sell crossover signals reqd

#### esconindia

##### New Member
Dear experts
I have visited hundred of forum but this is the only forum where i find real programmers and people who are always ready to help . Again i have come here to find solutions to a problem.

Thanks a lot to all exerts and genius people .

This is a hull moving average with 60 period. In this afl code buy and sell signals are as per hull formula but i need buy and sell signals when hull line crosses up and down. I have tried it but i am not able to get alert signals. please help me to get alert signals as per crossovers.

Here is the original afl code :
_SECTION_BEGIN("Unnamed 155");
/***************************************/
/* Hull Moving Average version 1.0 */
/* by Avi b a */
/* The Hull Moving Average solves the age
old dilemma of making a moving average more
responsive to current price activity whilst maintaining curve smoothness...
/***************************************/

SetChartBkColor(16);

Period = Param("Period",26,1,100,1);
Hull = WMA( 2*WMA(C,int(Period/2))- WMA(C,Period),int(sqrt(Period)));

Plot(C,"close",6,128);

for( i = 1 ; i < BarCount-2; i++ )
{
if (hull <hull[i-1] && hull <hull[i+1])
Lpml=1;
else
Lpml =0;

if (hull >hull[i-1] && hull >hull[i+1])
Lpmh=1;
else
Lpmh =0;
}

GR =ExRem(LpmH,Lpmh);
RD =ExRem(Lpml,Lpml);
Sell=RD;
Short=Sell;
PlotShapes(IIf(GR!=0,shapeSmallCircle,shapeNone),colorRed,0,hull,0);
PlotShapes(IIf(RD!=0,shapeSmallCircle,shapeNone),colorGreen,0,hull,0);
Plot(Hull,"Hull "+Period+" days",2,1);
_SECTION_END();

Modified code giving crossover signals but sound alert systems are not generated and in back test it shows zero row.I want crossover sound alerts for the same
_SECTION_BEGIN("Unnamed g");
/***************************************/
/* Hull Moving Average version 1.1 */
/* by Avi b a */
/* The Hull Moving Average solves the age
old dilemma of making a moving average more
responsive to current price activity whilst maintaining curve smoothness...
*/
/***************************************/
bc = Param("background color",2,1,55,1);
use_your_color=IIf(ParamList("use_your_color?","no|yes")=="yes",1,0);
SetChartBkColor(bc);

Period = Param("Period",60,1,150,1);
Hull = WMA( 2*WMA(C,int(Period/2))- WMA(C,Period),int(sqrt(Period)));

pc[0]=0;
for( i = 1 ; i < BarCount-1; i++ )
{
pc = pc[i-1];
if (hull <hull[i-1] && hull <hull[i+1])
{Lpml=1;pc=6;}
else
Lpml=0;

if (hull >hull[i-1] && hull >hull[i+1])
{Lpmh=1;pc=4;}
else
Lpmh=0;
}
GR =ExRem(LpmH,Lpmh);
RD =ExRem(Lpml,Lpml);

Sell=RD;

gr = Cross( C, Hull);
rd = Cross( Hull, C );
Sell=Cross(Hull,Hull);
Short=Sell;

Plot( Hull, "hull", styleDots + styleLine| styleStaircase);
PlotShapes(IIf(gr!=0,shapeStar,shapeNone),colorBlue,0,hull,0);
PlotShapes(IIf(rd!=0,shapeStar,shapeNone),colorRed,0,hull,0);
Plot(Hull,"Hull "+Period+" days",2,1);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\ringin.wav", "sell @" + C, 2 ) ;
if (use_your_color)
pc = Param("plot color",6,1,55,1);"pc ="+gr;
Plot(C,"close",pc,styleCandle);
_SECTION_END();