Buy X trading days before EOM and sell Y trading days of the next month
Author: tpoto
Creation Date: 1/19/2009 2:05 PM
profile picture

tpoto

#1
I'm try to write a script that
Buys: 6 market days before the end of the month and
Sell: 2nd market day of the following month.

Tried the get(month) and get(day) but the trade
dates seem not to be correct- probably logic is faulty?

This following script buys on the 29th of the month
in many cases. Can't see how it calculates that.

Thanks

CODE:
Please log in to see this code.
profile picture

Cone

#2
Since you posted in the .NET >> General forum, are you looking for this to work in Version 4 or for a translation to C#?

Please look for the appropriate forum to avoid doubts like these.
profile picture

tpoto

#3
Looking for the code in version 4.

(please provide the link where I can ask ver. 4 questions)

thanks
profile picture

Eugene

#4
Please notice the Wealth-Lab 4 forums link on the left.
profile picture

tpoto

#5
I am trying to upgrade the program that Eugene was kind enought to write for me-
to WLP 5.1 (via the translator)

It does not like the Date Study VI.
I looked at the WIKI for workarounds, but found none.
Any suggestions.
Thanks (hope I posted this in the correct forum...)



CODE:
Please log in to see this code.
profile picture

Eugene

#6
1) Please use the CODE tags, it's dead simple and they exist for a reason.

QUOTE:
I am trying to upgrade the program that Eugene was kind enought to write for me-
to WLP 5.1 (via the translator)

It does not like the Date Study VI.


2) Yes, this seems to be the case. Please keep in mind that if you face an issue with WealthScript Translator, the best way is to report it directly to the developer (Dr. Koch) on his dedicated forum.

P.S.
QUOTE:
I looked at the WIKI for workarounds, but found none.

The universal Wiki answer to date-related functions is "think .NET instead". However, fundtimer's function isn't that simple and requires some effort to re-code it in C#.
profile picture

Eugene

#7
Well... here is a quick workaround that doesn't take holidays into account:

CODE:
Please log in to see this code.


Accounting for holidays with their floating nature is a PITA, sorry.

Let me add that fundtimer's function was versatile enough to return the remaining trading days in a week or year as well. This one is limited to "days in month" scenario.
profile picture

tpoto

#8
Great, thanks, I'll give it a try.
profile picture

Eugene

#9
QUOTE:
Accounting for holidays with their floating nature is a PITA, sorry.

Found myself here accidentally. With Community Components it' a piece of cake to account for market holidays by using this overloaded call:

CODE:
Please log in to see this code.


So the code from post #7 boils down to simply this:

CODE:
Please log in to see this code.
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).