value strategy using peak & average price for trailing 4 months
Author: denoving
Creation Date: 1/8/2013 1:13 AM
profile picture

denoving

#1
Hi: the petro sector has pulled back some, but it's believed
to be a short term situation. to identify value, I'd like to
compute average for trailing months and peak for ave 4 months
using day bars.

I'd like to display the average and peak prices, and I'd like
to buy if the price is 10% below the recent peak [in the last
4 months], and below the average price in that period.

Could you help me get started with that code please?

In WL4, I'd come up with a series, and I'd attempt to do
computations on that series using variables and logic to
determine if a stock meet the desired criteria.

regards,

Dan
profile picture

Eugene

#2
QUOTE:
I'd like to buy if the price is 10% below the recent peak

This strategy's code should help get you started in the right direction:

WSJ Common Sense system

It enters when the instrument has declined 10% from the recent peak (or from last position's entry price).
profile picture

denoving

#3
Thanks, I'll check it out!

By the way it doesn't compile until you add one additional "}" at the end.
profile picture

denoving

#4
No, but thank you all the same.

The "WSJ common sense system" is a limit order system that always
comes up with 1152 alerts. That's not what I had in mind.

It doesn't do what I need it to do:

It doesn't

1) compute the average for the trailing 4 months and put it in a variable.
2) compute the peak in the trailing 4 months and put that in a variable.
3) provide an alert if it is 10% below 2), and below 1).

I'll go through my existing strategies and see if I can pull something out that might get some of it going, and then maybe I'll have some more questions.

But thank you for your time & attention.

regards,
Dan
profile picture

denoving

#5
Maybe if you could just give me a script that assigns the closing price of the day bar with the highest closing price in the trailing 120 days. maybe that's all I need to modify one of my other strategies to get where I want to go.

regards,
Dan
profile picture

Eugene

#6
QUOTE:
By the way it doesn't compile until you add one additional "}" at the end.

That's because you did not copy it properly.

It compiles perfectly and error-free if you either copy/paste it correctly or, as we suggest everyone to do, simply download the strategy's code using Wealth-Lab's "Open Strategy > Download" feature.
QUOTE:
It doesn't

I gave you an example that illustrates how to:
1) compute the peak and put that in a series
2) provide an alert if it is 10% below the recent peak

For the details like trailing 4 months, I expected, you will tailor the script on your own. I thought it provides a good enough place to start.
QUOTE:
assigns the closing price of the day bar with the highest closing price in the trailing 120 days.

It's not too much different from WL4:

Highest.Series

For more informations, please see the WealthScript Programming Guide > DataSeries.
profile picture

denoving

#7
OK, thanks. I'll take another run at it tomorrow.

I gotta say I sooooooo much preferred the pascal based language.

I thought I was going to like C#, and really gave it a chance. But
it doesn't make any sense. Pascal is so pure and logical, you can reason it
out, whereas with C# you just memorize stuff and hope it applies in
your case.

The problem I have is this structured code I find to be nonsensical,
whereas Pascal was so straight forward and logical.

People think that this new way of programming is better, but they're
wrong. Oh well. It is what it is.

In WL4 everything was so logical and straight forward and simple, but
new scripts make absolutely no sense at all.

None of this new scripting language makes any sense at all.

Needless to say, I'm frustrated, and I'm sure you've heard it all before,
and I'll get over it. Probably better to just ignore the rants of
this old fool. Sorry to waste your time.

regards,
Dan
profile picture

Eugene

#8
Yes Dan, I heard this before but I don't want to pretend that I understand your frustration. I think that the lead architect of C#, Anders Hejlsberg, who also happens to be the author of Turbo Pascal and Delphi, would definitely disagree with you. :)

Many believe (quite reasonably) that it's C# that provides the less painful and the most natural transition to the world of .NET from Pascal/Delphi. Further, WealthScript hasn't changed conceptually since Version 4 -- it's mostly a matter of forgetting the begin/end blocks and welcoming the curly braces.

Actually, not sure what's that "new way of programming" is about. Object Pascal aka WealthScript was pretty much object-oriented, if you mean it, and any serious idea (multi-systems, genetic algorithms etc.) in Versions 3/4 required that one would use objects.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).