the code is
it will place the val at the crossover
Code:
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
st1=StochK( periods , Ksmooth);
st2=MA(st1,5);
Plot( st1, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
Plot(st2,"",3,1);
Buy=Cross(st1,st2);
Sell=Cross(st2,st1);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
//val1=ValueWhen(Buy,st1,1);
//val2=ValueWhen(Buy,st1,2);
val1=ValueWhen(Buy,C,1);
val2=ValueWhen(Buy,C,2);
xx=BarIndex();x=xx;Lx=LastValue(x);
fvb=Status("firstvisiblebarindex");
lvb=Min(Lx,Status("lastvisiblebarindex"));
for(i=fvb;i<lvb;i++)
{
if(Buy[i]) PlotText(""+Val1[i],i,st2[i],colorBrightGreen,colorDefault);
//if(Sell[i]) PlotText(""+Val1[i],i,st2[i],colorOrange,colorDefault);
}
Title=Name()+
"\n1st buy : "+ val1+ "\n" +"2st buy : "+ val2;