Buy and sell crossover signals reqd

#1
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...
read more at- http://www.ensignsoftware.com/tips/tradingtips72.htm */
/***************************************/

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);
Buy =GR;
Sell=RD;
Short=Sell;
Cover=Buy;
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);

Buy =GR;
Sell=RD;


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

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( Buy, "SOUND C:\\Windows\\Media\\ringin.wav", "buy @" + C, 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();
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?