STOCH 5 / 50 system

#1
Hello Guys,

I found a pretty good trading stategy, but I am not familiar with AFL writing. I use an AFL created by Dimitris Tsokakis, called Slow Stochastic and Trendlines. I paste the code here:

_SECTION_BEGIN("sto");
/*Slow Stochastic and Trendlines
for Indicator Builder,
by Dimitris Tsokakis*/
D1=5;
MaxGraph=8;
ST3=StochK(D1);
ST33=StochD(D1);
Graph0=ST3;
Graph1=ST33;
Title=Name()+" - %K="+WriteVal(st3,FORMAT=1.2)+", %D="+
WriteVal(ST33,FORMAT=1.2)+
WriteIf(Cross(st3,st33)," POSITIVE CROSS"," ")+
WriteIf(Cross(ST33,ST3)," NEGATIVE CROSS","");
x = Cum(1);
per = 0.1;
s1=st33;
s11=st33;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
Graph6 = IIf(x>startt-1 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10);
Graph6Style = 1;
Graph6Color = 5;
pR = PeakBars( s11, per, 1 ) == 0;
endt1= LastValue(ValueWhen( pR, x, 1 ));
startt1=LastValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;
endR = LastValue(ValueWhen( pR, s11, 1 ) );
startR = LastValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
Graph7 = IIf(x>startT1-1 AND TRENDLINER>0 AND
TRENDLINER<100,trendlineR,-1e10);
Graph7Style = 1;
Graph7Color = 2;
_SECTION_END();

Let me explain how I use this. I have an indicator with parameter D1=5 and in another pane with D1=50. Let me name the indicator having D1=5 as STO5 and the other STO50. When both STO5 and STO50 says POSITIVE CROSS I would like to see a BUY signal. When both STO5 and STO50 says NEGATIVE CROSS I would like to have a SELL signal. What I would like to have is an AFL giving buy and sell signals according to these.

I am not able to create an indicator like this. Could anybody please help? And I also am interested in your opinion in using this strategy. I intend to use it in EOD trading, not intraday. I attach a picture showing the days of buy and sell (indicated by the pink lines).

Cheers,
s

 
Last edited:
#2
Oh and one more comment to this. We might include that BUY/SELL should happen around extreme levels, let's say 10/90 or 20/80 could be set as parameter or I don't know.
 

rkkarnani

Well-Known Member
#3
I do not use Amibroker, hence not aware about AFL's..however the formula posted by you has the words :
WriteIf(Cross(st3,st33)," POSITIVE CROSS"," ")+

st3 and st33 is repeated many times. To me, a person ignorant about AFL's, it seems the AFL is probably for Stochastic 3/33 system rather than 5/50 system!!! The figure 50 is not mentioned a single time in the entire AFL!!
 
#4
Thanks for the reply. Well, I don't know that 3/33 thing, I set 5 and 50 in D1 and gives the faster and slower graphs for me as seen on the picture. Whatever it does, it gives reasonable signals. :)