Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 3/7/2005(UTC) Posts: 1,346
|
jose lightly touched on something a while back that finally made since to me... can't quite remember perfectly but it was along the line of making sure the indicator would plot something if the indicator value was null....
just noticed that sometimes our prefered defaults might not be low enough to encompass the values of all securities so the plot might be null from the word go.... a meltdown won't insue but it's a pain nonetheless....... in the case of the barssense indicator below i had to include a -5 line.... could have just as easily been a 0 but the -5 seemed visualy better....
while we're on 0's, have you ever noticed many self-made indicators will include a 0 line as the last line of code.... some of the better code sites have them built that way.... it seems better to me to have the 0 line code elsewhere.... having it last gets in the way of applying some indicators to that self-made indicator.... the 0 line will at times be the target, not always but sometimes....
and speaking of not playing well together, the barssince seems abit selfish.... its been an unusually long time since we've had the standard 9% correction, which got me studyin on barssince.... one of the neat things about metastock is how quickly we can turn our random thoughts into answers.... i started coding a barssince indicator looking back to past levels of particular occurences....
to make it flexible inputs were included... ordinarily we could use a single input value.... it could be set as " x:=input("value",-500,500,1), that should just about cover most values we incur.... for some reason it would not work.... the only way was to let each barssince have it's own input, 1 for rsi, 1 for cci and so on..... of course we shouldn't rule out a coding error on my part.....
and lastly.... when running system tests, esp if many with slight variances, its nice to use the systems tester's 'plot on chart' feature to see the trades..... trouble is to view the second one erases the first.... to better cross compare the trades of multiple systems, plot the first test.... then use the 'new window' feature to exactly replicate that chart, choose the stack option for viewing....... now open the next system test and plot it.... only the orignal chart will change to the new test... the new window replicated one stays as is....keep that going until you have a reasonable number of systems ploted....
now open a clean chart, one by one copy and paste the system tests on the same chart...... just right click on a price bar from each test and select copy, it will copy all symbols, price bars and such.... paste that into a new window in your clean chart..... .... this way the slider line along with other functions can have equal access to all tests at once, as all test will be on one chart..... might want to save that chart along with included rules..... will expand on that idea later.....
takes less than a minute to put 5 tests on one chart along with indicators..... its far easier than it sounds.... h
playin around with barssince
[code:1:909447909e]choice:=Input("macd><,cci><,rsi><,willr><",1,20,1);
x:=Input(" macd value ",-5,5,.1);
y:=Input("cci value ",-500,500,100);
z:=Input("rsi value",1,100,30);
zz:=Input("willr value",-100,0,-30);
u:=Input("indicator value",1,100,10);
aa:=BarsSince(MACD()>x);
bb:=BarsSince(MACD()<x);
aaa:=BarsSince(CCI(14)>y);
bbb:=BarsSince(CCI(14)<y);
aaaa:=BarsSince(RSI(u)>z);
bbbb:=BarsSince(RSI(u)<z);
aaaaa:=BarsSince( WillR(u)>zz);
bbbbb:=BarsSince(WillR(u)<zz);
-5;
plot:=If(choice=1,aa,If(choice=2,bb,If(choice=3,aaa,If(choice=4,bbb,If(choice=5,aaaa,If(choice=6,bbbb,If(choice=7,aaaaa,If(choice=8,bbbbb,MACD()))))))));
plot[/code:1:909447909e]
|