logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Biff Malibu  
#1 Posted : Thursday, May 3, 2012 1:24:58 PM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

Hi, I've been a member here for about 7 years and like most of you there are several indicators I follow, I have one that is my favorite that I have created, and then there are 1 or 2 others that seem to add "a lot" to the accuracy of the first indicator. Obviously, "a lot" is subjective, and I, being somewhat OCD, would like to use the system tester to find how much, and also, how much "weight" I should assign the secondary indicator.

For example let's look at the CTI which is a fantastic indicator included with metastock.

CTI:=(((ADI/(ADI+DCI))-0.5)*100)*(p1/100) +
(((NNH/(NNH+NNL))-0.5)*100)*(p2/100) +
(((USV/(USV+DSV))-0.5)*100)*(p3/100) +
ROC(MKT,p4,%)*(p5/100);
Mov(CTI,p6,E)

In this case, different weights are assigned to the different components, specified by the p1/100, p2/100, p3/100 etc.
First question, is there a way to use the system tester to optimize these to find out what are the optimum weights to use for these indicators??? They would all have to add up to 1, and that's where I'm having problems with coding.
Can you specify somehow that p1/100 + p2/100 ... p6/100 = 1 or opt1 + opt2 ... +opt6 = 1???

Thanks for any help or direction!
Biff


jjstein  
#2 Posted : Thursday, May 3, 2012 1:28:55 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Some code appears to be missing; can you repost, using the CODE tags (see below)?

Biff Malibu  
#3 Posted : Thursday, May 3, 2012 1:35:57 PM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

Hi yes, here is the code for the Indicator, however I'd like to use it in the system tester to optimize the percentage that I could assign each variable.
Code Below****

{This indicator is a combination of the ratios of the Advancing issues vs Declining issues, Advancing Volume vs. Declining Volume, New Highs vs. New Lows, and the rate of change of the underlying exchange. The result is smoothed by an exponential moving average. The default weighting of the ratios and the length of the average is aimed at measuring a relatively moderate time frame.}

p1:=Input("Advancing and Declining Issues %",0,100,25);
p2:=Input("New Highs and New Lows %",0,100,30);
p3:=Input("Up Volume and Down Volume %",0,100,20);
p4:=Input("Periods in Rate of Change",1,200,12);
p5:=Input("Rate of Change %",0,100,25);
p6:=Input("Exponential Moving Average periods",1,200,12);
ADI:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",C);
USV:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",V);
DCI:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",C);
DSV:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",V);
NNH:=Security("C:\MetaStock Data\BM Data\X.NYSE-H",C);
NNL:=Security("C:\MetaStock Data\BM Data\X.NYSE-L",C);
MKT:=Security("C:\MetaStock Data\BM Data\.NYA",C);

CTI:=(((ADI/(ADI+DCI))-0.5)*100)*(p1/100) +
(((NNH/(NNH+NNL))-0.5)*100)*(p2/100) +
(((USV/(USV+DSV))-0.5)*100)*(p3/100) +
ROC(MKT,p4,%)*(p5/100);
Mov(CTI,p6,E)

jjstein  
#4 Posted : Thursday, May 3, 2012 2:52:19 PM(UTC)
jjstein

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 5/13/2005(UTC)
Posts: 715
Location: Midwest, USA

Was thanked: 1 time(s) in 1 post(s)
Oh, ok, I see; you're using "BM NYSE Composite Tape Index - Medium Term". Two comments:

1. You'll have to post the code (or something similar) you're using it with. If you'd rather not make it public, send it to me in a Private Message (see top right box).

2. When you optimize, you must use separate data sets to Train, Test & Trade. If you don't know what "walk-forward" means, do NOT optimize until you do. If you fail to do this, the "Statistics Police" won't show up at your door, but the system will be contaminated by curve-fit, and will likely fail.

wabbit  
#5 Posted : Thursday, May 3, 2012 5:50:32 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
This problem is where Neural Networks (NN) come into play and where they do their most powerful work. In lieu, using the EST "optimisation" (brute-force curve-fitter), we have 6 Optx variables, so express them as a percentage of the whole:

Code:

p1:=opt1;
p2:=opt2;
p3:=opt3;
p4:=opt4;
p5:=opt5;
p6:=opt6;

total:=opt1+opt2+opt3+opt4+opt5+opt6;
total:=if(total=0,1,total);

p1:=p1/total;
p2:=p2/total;
p3:=p3/total;
p4:=p4/total;
p5:=p5/total;
p6:=p6/total;

ADI:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",C);
USV:=Security("C:\MetaStock Data\BM Data\X.NYSE-A",V);
DCI:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",C);
DSV:=Security("C:\MetaStock Data\BM Data\X.NYSE-D",V);
NNH:=Security("C:\MetaStock Data\BM Data\X.NYSE-H",C);
NNL:=Security("C:\MetaStock Data\BM Data\X.NYSE-L",C);
MKT:=Security("C:\MetaStock Data\BM Data\.NYA",C);

CTI:=(((ADI/(ADI+DCI))-0.5)*100)*(p1) +
(((NNH/(NNH+NNL))-0.5)*100)*(p2) +
(((USV/(USV+DSV))-0.5)*100)*(p3) +
ROC(MKT,p4,%)*(p5);

{we cannot use the std mov() here, so make our own}
ma:=if(cum(isdefined(CTI))=1,CTI,Prev*(1-p6)+CTI*p6);

{add some trading logic here}
...
...



You'll need to walk-foward your test results.



wabbit [:D]

[edit] You're also going to need one kick-ass CPU and a lot of time to run this through the EST.

opt(1-5) : [1...100] => 100^5 = 1e+10 passes, multiplied by your EMA lengths (opt6), say, [1..100] again => 100^6 = 1e+12 passes (1,000,000,000,000) and remember: we have required the use of a PREV function!



Biff Malibu  
#6 Posted : Thursday, May 3, 2012 9:27:39 PM(UTC)
Biff Malibu

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 4/21/2005(UTC)
Posts: 33

Ah Wabbit, I KNEW I could count on you, thank you my friend. Yes I don't intend on using all 6 variables, more like 3, but that's exactly what I was looking for. Thank you my friend Biff
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.