Here is the Buy part with plot statements to help visualize what is
happening

---------------------------------

//    Buy20DayHigh.afl
//
//    Buy when ema(c,5) > ema(c,20)
//    and issue reached new 20 day high
//
//    Howard Bandy
//    June 2010
//
Cond1 = EMA( C, 5 ) > EMA( C, 20 );
Cond2 = H > Ref( HHV( H, 20 ), -1 );
Buy = Cond1 && Cond2;

Sell = 0;

shapes = Buy * shapeUpArrow + Sell * shapeDownArrow;
shapecolor = IIf( Buy, colorGreen, colorRed );
PlotShapes( shapes, shapecolor );

Plot ( Close, "C", colorBlack, styleLine );
Plot ( Cond1, "Cond1", colorGreen, styleLine | styleOwnScale, 0, 1.5 );
Plot( Cond2, "Cond2", colorBlue, styleLine | styleOwnScale, 0, 2 );

--------------------------------

Thanks,
Howard


On Fri, Jun 4, 2010 at 1:40 PM, abramway <abram...@yahoo.com> wrote:

>
>
> I'd just like to be able to get signals for
>
> Buy: When EMA(5)>EMA(20) AND Stock @ Fresh 20-Day Highs.
> Exit: When EMA(20)>EMA(5) OR Stock @ Fresh 10-Day Lows (haven't
> incorporated the second part yet)
>
> This is what my code reads now and its giving me the wrong signals. It
> gives me BUY signals before a new 20-Day high.
>
> Buy = EMA( Close , 5 ) > EMA( Close , 20 )
> AND High > Ref( HHV( High , 20 ) , -20 );
>
> Sell = EMA( Close , 20 ) > EMA( Close , 5 );
>
> Short = 0;
>
> Cover = 0;
>
> Thanks for the help
>
>  
>

Reply via email to