Vinay, after setting variables in the first 3 lines, try with this buy/sell formulae
KStoch = StochK(Periods,KSmooth); DStoch = StochD(Periods,DSmooth); BuyStoch = Cross(KStoch, DStoch) and KStoch > 20; SellStoch = Cross(DStoch, KStoch) and KStoch < 80; UMR Perumal --- In [email protected], "Vinay Gakkhar." <vgakk...@...> wrote: > > Learned senior members, > > I need help with the Stochastic function. > > I want a buy signal when Stochastic %K has crossed % D while going up after > crossing 20, and a sell signal when stochastic %K crosses %D while coming > down after crossing 80. > > periods = Param( "Periods", 15, 1, 200, 1 ); > Ksmooth = Param( "%K avg", 3, 1, 200, 1 ); > Dsmooth = Param( "%D avg", 3, 1, 200, 1 ); > BuyStochastic1 = Cross( (StochK( periods , Ksmooth)), 20 ) ; > SellStochastic1 = Cross( 80, (StochK( periods , Ksmooth)) ) ; > BuyStochastic2 = Cross( (StochK( periods , Ksmooth)), (StochD( periods , > Ksmooth, DSmooth )) ) ; > SellStochastic2 = Cross( (StochD( periods , Ksmooth, DSmooth )), (StochK( > periods , Ksmooth)) ) ; > > Can someone please tell me what is wrong here, and how to correct it. > > Many thanks. > > vgakkhar >
