Rank: Newbie
Groups: Registered, Registered Users Joined: 1/24/2006(UTC) Posts: 6
|
I would appreciate help with the following. I would like to develop a formula for a System Test which would "buy" a security when the underlying index moves up X% from its most recent trough and would "sell" the security when the underlying index moves down Y% from its most recent peak.
The parameters would be along the lines of the following:
Recommended Index: User programmable
Limiting data: User programmable
Earliest Start date: User programmable
Startup Period: User programmable
Signals Change: User programmable
Data: User programmable
Originator: Public Domain.
Options / Defaults
------------------
Buy Swing % (BS)
Sell Swing % (SS)
Frequency (F) D=Daily, W=Weekly, M=Monthly
Single Day Moves (SD) 0=Unchecked, 1=Checked
Base Index (I)
PSW: BS=0.9, SS=0.9, F=D, SD=0, I=SPX
PSWN: BS=1.0, SS=1.0, F=D, SD=0, I=NDX
F is how often swings are checked.
(e.g. Weekly causes only weekly
closing values to be used in setting up
peaks, valleys, and signal swings.)
If SD is checked the swing percentage
for buy and sell signals must occur on a single
day, week, or month depending F.
Index or EDF (I) - This is the index that
you would like PSW to use for the %swings.
You may enter and External Data File (EDF)
filename in this field.
Buy Signals
-----------
B0: I closes BS% above any low since
the last sell signal on an F basis.
Sell Signals
------------
S0: I closes SS% below any high since
the last buy signal on an F basis.
Indicators
----------
Swing %= This indicator graphs the percent change
of the base index since the last short
term top or bottom.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Michaelesq, sooner or later you will be wondering why nobody has replied to your lengthy MetaStock request.
This forum is all about assisting MetaStock users with their own programming issues, as opposed to a free source of custom trade strategy programming.
If you consider your proposed trading strategy valuable enough for someone to spend their valuable time on it, you may also have to consider the use of professional programming services to put it together.
jose '-)
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 1/24/2006(UTC) Posts: 6
|
Sorry Jose. Thank you for your prompt (if somewhat curt) response. I was just trying to find out if anyone had seen such a program written in MetaStock Code before I contact the professional MetaStock staff to engage them for such a project (something which I have done a number of times in the past).
As you indicated: "This forum is all about assisting MetaStock users with their own programming issues."
I scanned the formulae on the forum site but did not see one that was similar.
Please don't fault me for first checking to see if that formula is already published elsewhere before I pay for it to be (re)created.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
Michael-
No faults here... we encourage all of our members to exhause the present resources before posting a new topic. See the forum rules for more info. Since the Search fueature of the forum is hosed, it is difficult to know exactly what is available and what isn't. You might trying searching our forum using Google and seeing if that will help. The criteria you posted looks like it was written with another program in mind. If you have existing code, then that might be helpful. Some people do have experience with conversions; however, like Jose mentioned, addressing a long system of trading would require a lot of attention and those that can do that for you will generally be fee-based responses.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
No problem, Michael.
Try splitting up your coding request into small "modules" - you'll have a much better chance of a useful response this way.
jose '-)
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 1/24/2006(UTC) Posts: 6
|
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 1/24/2006(UTC) Posts: 6
|
Earlier this year, I was seeking assistance with the preparation of formula for a system backtest involving what I would call "Percent Swing". The system should "buy" when the referenced security or index (in this example, the SPY) has moved up 1% from its most recent trough. I came across the following formula which, I believe, may provide the "Buy" signals:
target:=1.0;
pt:=Trough(1,Security("SPY",c),target);
time:=TroughBars(1,Security("SPY",c),target);
signal:=Cross(((Security("SPY",c)-pt)/pt)*100,target);
signal AND (Ref(BarsSince(signal),-1)>=time)
Similarly, the following formula is intended to provide a "Sell Signal" when the SPY has declined 1% from its most recent Peak:
target:=1.0; pt:=Peak(1,Security("SPY",c),target); time:=PeakBars(1,Security("SPY",c),target); signal:=Cross(Neg(target),((Security("SPY",c)-pt)/pt)*100); signal AND (Ref(BarsSince(signal),-1)>=time)
Being somewhat of a novice programmer, I was hoping someone with some Metastock programming experience might be able to confirm that this what the formulas in fact provide. When I use the formula in the System Backtest and then come the results with a mannual backtest, some of the signals are correct and others are not. Therefore, it seems there may be more going on in the formula than I suspect.
Any help in deciphering the above code would be appreciated.
Regards,
Michael
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/9/2007(UTC) Posts: 16
|
Hi michaelesq,
I have also struggled with the same issue. Here is a formula I use:
var1:=If(( Mov(P,3,S) *.913)>PREV, Mov(P,3,S) *.913,If(( Mov(P,3,S) *1.087)<PREV, Mov(P,3,S) *1.087,PREV));
a:=Cross(Mov(P,3,S) ,var1); b:=Cross(var1, Mov(P,3,S) );
state:=If(BarsSince(a)<BarsSince(b),1,0);
state=1
Ssome signals are wrong. Worse yet , I have not been able to use a different percent to generate buy and sell signals.
Dataman
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/9/2007(UTC) Posts: 16
|
hi again,
Your formula is better. I used weekly data from 1982 to 1992 and all buy and sell signals were 100% accurate.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.