[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: coding request



PureBytes Links

Trading Reference Links

Preston,

	Thank you very much for the detailed and informative post.
	
	My aim was to use this as a custom stochastic oscillator. I 
am using the oscillator version 1 which you had provided.
	
	Regarding the last two lines of the code, namely, Cross(A2,A)
*100; {cross above overbought}  Cross(B,A2)*100; {cross below 
oversold}, I have just changed it to (Cross(A,A2)*100)*-1; Cross
(A2,B)*100; (because these were the signals I was looking for).

	Once again I thank you  for the guidance.

Regards,

George.







-- In equismetastock@xxxxxxxxxxxxxxx, pumrysh <no_reply@xxx> wrote:
>
> George,
> 
> Just a couple of points about your post. 
> You mention that the code is for a stochastic oscillator. 
> I'm not sure that is what you have. It is a indeed a stochastic 
> oscillator but it has been rewritten in a way that it has been 
> smoothed differently than a standard stochastic oscillator. It 
uses 
> exponential smoothing and smoothes the scaling value.  It has also 
> been given a second normalization in the A2 variable. See below 
for 
> help file definitions of the oscillator and the momentum index:
> 
> If your intent is for a custom stochastic then there is no problem 
> with using it. We can also make the corrections that you requested 
> using that indicator. 
> 
> The first problem that I noticed was in the scaling of the cross 
> indicators. The scaling for the stochastic is 0 to 100. The 
scaling 
> for the cross was 0 to 1. This means that the signal would have 
been 
> very difficult to see when plotted. By changing the scale the 
signals 
> are easily seen. This was done by multiplying the signals by 100. 
> 
> Next problem was when the signal should occur. Did you want the 
> signal when you went into overbought/oversold or came out of those 
> zones. If you want the signals when you go into those zones then 
the 
> code below will work.
> 
> Finally there is the question of using separate variables for the 
> overbought/oversold and their crosses. It is really redundant to 
do 
> this but can certainly be done if you so desire.   
> 
> {George's Custom Stochastic}
> X:=Input("LENGTH OF STOCHASTIC",5,30,5);
> Y:=Input("OVERBOUGHT",60,100,80);
> Z:=Input("OVERSOLD",0,40,20);
> A:=Input("CROSS OVERBOUGHT",60,100,80);
> B:=Input("CROSS OVERSOLD",0,40,20);
> 
> P2:=Mov(((C-LLV(L,X))/(HHV(H,X)-LLV(L,X)))*100,3,E);
> A2:=Mov(((P2-LLV(P2,X))/(HHV(P2,X)-LLV(P2,X)))*100,3,E);
> A2; P2; Y; Z;
> 
> Cross(A2,A)*100; {cross above overbought}
> Cross(B,A2)*100; {cross below oversold}
> {end}
> 
> 
> 
> DEFINITIONS FROM METASTOCK HELP FILES:
> 
> The following formula calculates a 13,25,2 Stochastic Momentum 
Index.
> 100 * ( Mov( Mov(C - (0.5 * ( HHV(H,13) + LLV(L,13))),25,E),2,E) /
>  (0.5*Mov( Mov( HHV(H,13) - LLV(L,13),25,E),2,E)))
> 
> 
> The following formula calculates a 5-period %K Stochastic 
Oscillator 
> with 3-period slowing: (sum( C - llv(L,5), 3 ) / sum(hhv(H,5) - llv
> (L,5), 3) ) * 100
> This next formula calculates a 3-period %D of the %K in the 
preceding 
> formula.
> mov( stoch(5,3), 3, S )
> 
> --------------end------------------
> 
> The stochastic is really just another way of saying that you are 
> normalizing. 
> The formula to normalize an indicator is:
> 
> {Normalized Indicator}
> Ind:= {your indicator here};
> Npds:=Input("norm periods",1,500,48);
> Norm:=(Ind-LLV(Ind,Npds))
> /(HHV(Ind,Npds)-LLV(Ind,Npds)+.0000001)*100;
> Norm;
> 
> In the case of the Stochastic we use
> (C-llv(L,5) /(hhv(H,5) - llv(L,5)
> The indicator is the relationship of the close to the highest high 
> and lowest low for the last 5 days.
> 
> We can see from the Sochastic Oscillator definition that it uses a 
3 
> day average to derive its value. We know that Sum(x,3) and Mov
(x,3,S) 
> are the same thing.
> In order to change to exponential smoothing we could rewrite the 
> formula to 
> (mov(C-llv(L,5),3,E) / mov(hhv(H,5) - llv(L,5),3,E)) * 100
> 
> or we could smooth like this
> 
> A:= (C-llv(L,5)) /(hhv(H,5) - llv(L,5));
> (mov(A,3,E))*100
> 
> Notice that in the indicators that I just wrote that I multplied 
by 
> 100 after performing the mathmatical operations. In George's 
formula 
> the scaling is performed before the smoothing. Does it matter? In 
> this case there is very little difference. My preference though is 
to 
> scale after not before the smoothing. The reason is to derive a 
true 
> vision of the smoothing effect. In this case since I was 
multiplying 
> by 100 very little difference was noted. The same would hold true 
if 
> I had also scaled by either 1 or 10.
> 
> Now lets look at the P2 and A2 variables. The formula is:
> 
> P2:=Mov(((C-LLV(L,X))/(HHV(H,X)-LLV(L,X)))*100,3,E);
> A2:=Mov(((P2-LLV(P2,X))/(HHV(P2,X)-LLV(P2,X)))*100,3,E);
> 
> In P2 we have a exponential stochastic. In A2 we are normalizing 
the 
> P2 stochastic and further smoothing using exponential smoothing. I 
> really see no problem with this as long as you understand that you 
> are normalizing the stochastic. I would though like to see a 
longer 
> normalizing period. You could double or triple the smoothing 
periods. 
> This could be an input variable. 
> 
> One more change is to eliminate the Cross Overbought/Oversold 
levels. 
> Unless you really want separate levels for the cross functions 
there 
> is really no need for them since you can use the levels which you 
> have set in the overbought/oversold input variables.
> 
> In version 2 you will note the changes which I have discussed 
above. 
> 
> {George's Custom Stochastic version2}
> X:=Input("LENGTH OF STOCHASTIC",5,30,5);
> A:=Input("Normalize None 1 Double Sto 2 Triple Sto 3",1,3,2);
> Y:=Input("OVERBOUGHT",60,100,80);
> Z:=Input("OVERSOLD",0,40,20);
> P2:=Mov(((C-LLV(L,X))/(HHV(H,X)-LLV(L,X))),3,E)*100;
> A2:=Mov(((P2-LLV(P2,X*A))/(HHV(P2,X*A)-LLV(P2,X*A))),3,E)*100;
> A2; P2; Y; Z;
> Cross(A2,Y)*100; {cross above overbought}
> Cross(Z,A2)*100; {cross below oversold}
> {end}
> 
> 
> George, thanks for sharing your indicator with us. Hopefully you 
will 
> find some of the ideas that I have outlined useful.
> 
> Preston
> 
> 
> --- In equismetastock@xxxxxxxxxxxxxxx, "georgeabraham3" 
> <georgeabraham3@> wrote:
> >
> > 
> > 
> >  Hi,
> > 
> > 				     Reg: Coding request.
> > 
> > 	The following is the coding for a stochastic oscillator:
> > 
> > X:=Input("LENGTH OF STOCHASTIC",5,20,5);
> > Y:=Input("OVERBOUGHT",60,100,80);
> > Z:=Input("OVERSOLD",0,40,20);
> > 
> > P2:=Mov(((C-LLV(L,X))/(HHV(H,X)-LLV(L,X)))*100,3,E);
> > A2:=Mov(((P2-LLV(P2,X))/(HHV(P2,X)-LLV(P2,X)))*100,3,E);
> > A2;
> > 
> > Y;
> > Z;
> > 
> > 	Can any one please help me to code using the input function, 
> > (so that the length of the stochastic oscillator, over bought 
and 
> > the over sold values can be changed) for Cross(80,stochastic 
> > oscillator) and also Cross(stochastic oscillator,20). The code I 
> > wrote is given below:
> > 
> > X:=Input("LENGTH OF STOCHASTIC",5,30,5);
> > Y:=Input("OVERBOUGHT",60,100,80);
> > Z:=Input("OVERSOLD",0,40,20);
> > A:=Input("CROSS OVERBOUGHT",60,100,80);
> > B:=Input("CROSS OVERSOLD",0,40,20);
> > 
> > P2:=Mov(((C-LLV(L,X))/(HHV(H,X)-LLV(L,X)))*100,3,E);
> > A2:=Mov(((P2-LLV(P2,X))/(HHV(P2,X)-LLV(P2,X)))*100,3,E);
> > A2;
> > 
> > Y;
> > Z; 
> > Cross(80,P2);
> > Cross(P2,20);
> > 
> > This code does not give the results. Can any one please correct 
my 
> > mistake?
> > Thanks in advance.
> > 
> > George.
> >
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/