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

Notification

Icon
Error

Options
Go to last post Go to first unread
manatrader  
#1 Posted : Monday, April 20, 2009 6:11:49 PM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

aa:=if(c-ref(c,-1)>0,1,0);
bb:=if(ref(c,-1)-ref(c,-2)>0,1,0);
cc:=if(ref(c,-2)-ref(c,-3)>0,1,0);
dd:=if(ref(c,-3)-ref(c,-4)>0,1,0);
ee:=if(ref(c,-4)-ref(c,-5)>0,1,0);
ff:=if(ref(c,-5)-ref(c,-6)>0,1,0);
gg:=if(ref(c,-6)-ref(c,-7)>0,1,0);
hh:=if(ref(c,-7)-ref(c,-8)>0,1,0);
ii:=if(ref(c,-8)-ref(c,-9)>0,1,0);
jj:=if(ref(c,-9)-ref(c,-10)>0,1,0);
kk:=if(ref(c,-10)-ref(c,-11)>0,1,0);
ll:=if(ref(c,-11)-ref(c,-12)>0,1,0);
if((aa+bb+cc+dd+ee+ff+gg+hh+ii+jj+kk+ll)/12<opt1,1,0)

The above (long entry) test is running on my system, with 3 more optimizations for exit, short, buy to cover, and one for a trail stop. Total opts is 32k, and it ran overnight completing only 25% of the test. The attempt is to trade based on # of days up in the last 12, any help appreciated on code correctly identifying the condition, or to speed me uup!

wabbit  
#2 Posted : Monday, April 20, 2009 6:30:12 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)
First, you don't need to use If(x,1,0) because MS automatically does this for you in its determination of Boolean logic operations.

Second, what is the purpose of taking the average of the 12 inputs? It's redundant logic.

Third, have a look at the Sum() function. Your code can be written in one line.

As for the optimisation: There is a fine line between optimising a system and "curve fitting" so I'd strongly suggest you do some research on the difference, but more importantly, the effects of trading an optimised system versus trading a curve-fitted system. Also, if you're looking to find the number of UP days, shouldn't the comparison in the last line be gt not lt ?


wabbit [:D]



wabbit  
#3 Posted : Monday, April 20, 2009 6:38:12 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)
P.S.

c-ref(c,-1)>0

has two operations to evaluate; MS will do the arithmetic, then it will do the comparison to return a TRUE (1) or FALSE (0) answer.

Compare this with:

c>ref(c,-1)

which will have the same result, but completed in less processes.


The difference on a single operation is negligible, but as you have discovered, if you have to do several thousand-million or more passes, then the time taken to do these extra computations becomes very significant.


Remember, MS scripts are not compiled or optimised for execution; it's up to the author to write well.



wabbit [:D]

manatrader  
#4 Posted : Tuesday, April 21, 2009 5:18:15 PM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

Grooveness, thanks. Added your changes except I gotta search around on the sum fx to see if calc times can get shortened, for further tweakings
<+>
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.