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

Re: adaptive stochastic oscillator



PureBytes Links

Trading Reference Links

<x-html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3017.2400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY aLink=#ff0000 background="" bgColor=#ffffff link=#004080 text=#000000 
vLink=#8080ff>
<DIV><FONT face=Arial size=2>Dave:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>A couple comments.&nbsp; You can get around the 
problem with variables in the HHV and LLV functions by using LastValue(currlen) 
rather than just currlen.&nbsp; Also, the smoothing in the definition of stochma 
will give you a simple moving average instead of exponential.&nbsp; Instead, try 
stochma:= Mov(stoch, 3, Exponential);</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>You also need a different variable name for stoch, 
since this is also a function name.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Regards.</FONT></DIV>
<DIV>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A href="mailto:dave.nadeau@xxxxxxxx"; title=dave.nadeau@xxxxxxxx>Dave 
  Nadeau</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A 
  href="mailto:metastock@xxxxxxxxxxxxx"; 
  title=metastock@xxxxxxxxxxxxx>metastock@xxxxxxxxxxxxx</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, June 29, 2000 12:40 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: adaptive stochastic 
  oscillator</DIV>
  <DIV><BR></DIV>Here's what I come up with.&nbsp; It doesn't work, and I've run 
  into this issue when trying to solve some other problems. 
  <P>Does anyone have any ideas for circumventing the problem of putting a 
  variable into the "periods" part of the HHV or LLV functions? 
  <P>This gives an error when you try to put the code below into Metastock <FONT 
  color=#3333ff>(in blue)</FONT>: 
  <BR>-------------------------------------------------------------------------------------------------- 
  <BR>{-- © 2K Tushar Chande; Adaptive Stochastic Oscillator --} 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vars: v1(0), v2(0), v3(0), 
  v4(0) ; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vars: lenmax(28), 
  lenmin(7), currlen(0) ; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vars: 
  hh(0), ll(0), stoch(0), stochma(0) ; 
  <P><FONT color=#3333ff>lenmax:= 28;</FONT> <BR><FONT color=#3333ff>lenmin:= 
  7;</FONT> <BR><FONT color=#3333ff>currlen:= 0;</FONT> 
  <P>{-- Calculate 20-day std. Dev. And its 20-day range --} 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v1 = stddev(c,20) ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v2 = highest(v1, 20) ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v3 = lowest(v1, 20) ; 
  <P><FONT color=#3333ff>v1:= Stdev(Close, 20);</FONT> <BR><FONT 
  color=#3333ff>v2:= HHV(v1,20);</FONT> <BR><FONT color=#3333ff>v3:= 
  LLV(v1,20);</FONT> <BR>&nbsp; <BR>{-- Create v4: stochastic oscillator for 
  20-day std. dev. --} <BR>{-- if v1=v2 (highest level) =&gt; v4 = 1; if v1=v3 
  (lowest level) =&gt; v4=0 --} 
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (v2-v3) &gt; 0 then v4 = ((v1 
  - v3)/(v2-v3)) Else v4 = 0 ; 
  <P><FONT color=#3333ff>v4:=If((v2-v3)&gt;0,((v1 - v3)/(v2-v3)),0);</FONT> 
  <P>{-- Calculate current effective length; if v4 = 1, then length = mininum 
  --} <BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currlen = 
  IntPortion(lenmin + (lenmax-lenmin)*(1-v4)) ; 
  <P><FONT color=#3333ff>currlen:= If(v4=1,lenmin,(Int(lenmin + 
  (lenmax-lenmin)*(1-v4))));</FONT> 
  <P>{-- Calculate stochastic oscillator and its 3-day exponential average --} 
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hh = highest(h, currlen) ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ll = lowest(l, currlen) ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (hh-ll) &gt; 0 then stoch = 
  ((close - ll)/(hh - ll)) * 100 ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if currentbar = 1 then stochma 
  = 0 else 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  stochma = 0.5*stoch + 0.5*stochma[1] ;<FONT color=#3333ff></FONT> 
  <P><FONT color=#3333ff>hh:= HHV(High, currlen);</FONT> <BR><FONT 
  color=#3333ff>ll:= LLV(Low, currlen);</FONT> <BR><FONT 
  color=#3333ff>stoch:=If(((hh-ll)&gt;0,((close - ll)/(hh - ll)) * 100,50) 
  </FONT><FONT color=#ff0000>{I set the error condition to a stochastic 
  midpoint...I'm open to any other ideas???}</FONT> <BR><FONT 
  color=#3333ff>stochma:= (.5*stoch)+(.5*Ref(stoch,-1))</FONT> <BR>&nbsp; 
  <BR>{-- Plot data --} 
  <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot1(stoch, "adapt_stoch") ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot2(stochma, "stochma") ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot3(80, "hi_ref") ; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; plot4(20, "lo_ref") ; 
  <P><FONT color=#3333ff>stoch; stochma; 80; 20;</FONT> 
  <P>{ -- End of code --} <BR>---------------------------------- 
  <P>Dave Nadeau</P></BLOCKQUOTE></BODY></HTML>
</x-html>From ???@??? Fri Jun 30 15:55:54 2000
Return-Path: <majordom@xxxxxxxxxxxxxxxxxx>
Received: from listserv.equis.com (listserv.equis.com [204.246.137.2])
	by purebytes.com (8.9.3/8.9.3) with ESMTP id NAA01288
	for <neal@xxxxxxxxxxxxx>; Fri, 30 Jun 2000 13:36:59 -0700
Received: (from majordom@xxxxxxxxx)
	by listserv.equis.com (8.8.7/8.8.7) id NAA06263
	for metastock-outgoing; Fri, 30 Jun 2000 13:53:55 -0600
X-Authentication-Warning: listserv.equis.com: majordom set sender to owner-metastock@xxxxxxxxxxxxx using -f
Received: from freeze.metastock.com (freeze.metastock.com [204.246.137.5])
	by listserv.equis.com (8.8.7/8.8.7) with ESMTP id NAA06259
	for <metastock@xxxxxxxxxxxxxxxxxx>; Fri, 30 Jun 2000 13:53:52 -0600
Received: from smtp-server.tampabay.rr.com (smtp-server1.tampabay.rr.com [24.92.1.13])
	by freeze.metastock.com (8.8.5/8.8.5) with ESMTP id OAA16923
	for <metastock@xxxxxxxxxxxxx>; Fri, 30 Jun 2000 14:14:53 -0600 (MDT)
Received: from tampabay.rr.com (24161238hfc80.tampabay.rr.com [24.161.238.80])
	by smtp-server.tampabay.rr.com (8.9.3/8.9.3) with ESMTP id PAA11488
	for <metastock@xxxxxxxxxxxxx>; Fri, 30 Jun 2000 15:57:30 -0400 (EDT)
Message-ID: <395CFBA5.515EA93B@xxxxxxxxxxxxxxx>
Date: Fri, 30 Jun 2000 15:57:25 -0400
From: iamken <iamken@xxxxxxxxxxxxxxx>
X-Mailer: Mozilla 4.72 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: metastock@xxxxxxxxxxxxx
Subject: Re: adaptive stochastic oscillator - 
References: <395CE8CD.E685F718@xxxxxxxxxxxxxxx>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-metastock@xxxxxxxxxxxxx
Precedence: bulk
Reply-To: metastock@xxxxxxxxxxxxx
Status:   



iamken wrote:

> Re:  Chande's Adaptive Stochastic Oscillator on page 10 of the S&C July
> issue.
>
> >...I'm open to any other ideas???
>
> Ok, then here's my interpertation,

WRONG  WRONG WRONG!  :-)
Lastvalue is NOT the solution, since it changes all prior Stochastic values
to the current one.  Don't use the code I sent, because
it's....uh.....wrong.

Ken