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

Answer to Reversal of OSCP() Function



PureBytes Links

Trading Reference Links

rickyp wrote:
> 
> greetings,
> 
>   this is my first post to this list, i am using metastock version 6.0
> for windows 95/NT (i use windows 95).
> 
>   i am making my first attempt at building a testable method.
> 
>         i am using a price oscillator:  oscp(1,20,S,$)
> 
>         i would like to have a variable, OPT1, that specifies a minimum number
> of periods (days) since the oscp has last changed direction.  if it has
> been at least OPT1 days, then a buy signal would be generated.
> 
>         i am unsure how to write this formula.  i tried to reference the
> previous oscp values, but could not work a changing OPT1 into the
> formula, and could not determine how to reference the point where the
> oscp last changed direction.
> 
>   i would greatly appreciate any suggestions, also, if a FAQ exists,
> please point the way to it!!  (-:
> 
> rickyp
> 
> p.s., might i create variables in a system test, for example, when the
> oscp reversed, could i have assigned that closing price to, say,
> "close_at_reverse"?
> 
>                                _../|_
>                               ='__   _~-.
>                                    \'  ~-`\._
>                                          |/~`
> 
>    .    .    .    .    .    .    .    .    .    .    .    .    .    .
> _.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(._.`(.
> . rick pendrick                    i am a poor freezingly cold soul, .
> . 5302 32nd avenue                 so far from where i intend to go. .
> . kenosha, wi  53144     trudging through life's very constant lows, .
> . usa   414-652-5912         so far from where i'm determined to go. .
> .                                                                    .
> . mailto:rickyp@xxxxxxxxxx            "seasick, yet still docked"    .
> . http://www.execpc.com/~rickyp                    - morrissey       .
> .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
Greetings to Rick,
Greetings to everyone else,

This is also my first entry to this forum. I purchased MetaStock/95
about 1 month ago. I saw your entry on the forum and thought I
could suggest a solution for you. I would also be interested in
seeing how you MetaStock veterans would handle this (since
the MetaStock language takes some getting used to).

Use the following functions (I suggest you look each one up in
the manual or on-line help. The barssince function has a caveat
regarding the use of the MetaStock Explorer).

Formula 1:
barssince(  cross(  roc( oscp(1,20,s,$), 1, %), 0 ) )

Formula 2:
barssince(  cross(  0, roc( oscp(1,20,s,$), 1, %) ) )


Formula 1 will give you the number of trading periods since the
oscp() turned up. Formula 2 will give you the number of trading 
periods since the oscp() turned down.

The roc function (Rate Of Change) acts as the first derivative (slope) 
of your oscp() function. When the oscp() reverses direction, the slope
will cross the zero line (hence the use of the cross() function). The
barssince finally gives you the result you seek, i.e. the number of 
trading periods since a zero crossing (reversal of oscp()) has 
occurred. I hope this helps.

Regards,
Tim