|
Hi - I played with the code and found a mistake,
the new code below should work for the simple example I provided. I can't see
your BUY statement and don't know how it relates to your FILTER statement, so
your own code may still have other problems I don't know about. If you run
this code in explorer as I did, set for current ticker, n=100, it will display
the last 100 bars of your arrays - this is a good way to see when the value of
your arrays is not what you expect and is a good way to debug problems. You
could also do it with charts by replacing AddColumn statements with Plot
statements. I have attached a picture showing the results of my test. Good
luck!
Steve
Buy = Cross(
Close, MA(
Close, 10 )
);
MaxHigh = HighestSince( Buy,
High );
BarsToMaxHigh = BarsSince( Buy ) -
HighestSinceBars( Buy,
High );
Filter = 1;
AddColumn ( Buy, "Buy" );
AddColumn ( High, "High" );
AddColumn ( MaxHigh, "Max High" );
AddColumn ( BarsSince( Buy ), "BS Buy" );
AddColumn ( HighestSinceBars( Buy, High
), "BS MaxHigh" );
AddColumn ( BarsToMaxHigh, "Bars
To Max High" );
----- Original Message -----
Sent: Sunday, April 09, 2006 4:19
PM
Subject: Re: [amibroker] On Scalar Values
and Arrays
Hi Steve,
Thank you for responding. Unfortunately, that very straightforward and
intuitive solution doesn't seem to work. It appears to be returning the high
of the day after the signal. That's probably a result of the way I have "Buy"
defined. My "Buy" is defined to tell me the day after the signal day. Here's
the code:
VolFilter=Ref(V,-1)>5*Ref(MA(V,50),-1) AND Ref(MA(V,50),-1)>=100000;
PriceFilter=Ref(C,-1)>Ref(O,-1)
AND Ref(C,-1)>1 AND
Ref(C,-1)>Ref(C,-2)
AND Ref(O,-1)>Ref(C,-2);
Filter=Volfilter AND PriceFilter;// AND FundFilter;
MaxHigh=HighestSince(Filter,High);
PeriodstoMaxHigh=BarsSince(Filter)-BarsSince(MaxHigh);
I think that, because HighestSince() is an array, I would have to
reference some part of the array; thus the use of LastValue().
Steve Dugas <[EMAIL PROTECTED]>
wrote:
Hi
- Wouldn't something like this work?
MaxHigh = HighestSince( Buy,
High ); BarsToMaxHigh = BarsSince( Buy ) - BarsSince( MaxHigh
);
Steve
----- Original Message ----- From: "fatboycato"
<[EMAIL PROTECTED]> To:
<[email protected]> Sent: Sunday, April 09, 2006 12:50
PM Subject: [amibroker] On Scalar Values and Arrays
> Well,
I'm about to put on my clown suit, get my AK-47, and climb the > bell
tower. It seems to me there is a legitimate reason to reference > a
particular value in an array in explorations. I'll try to give a >
specific example to exactly what I'm searching for, but I think this
> array-to-scalar problem is going to plague me everywhere. >
> Trading System: > Buy on the open the day after a high volume
gap up. > Analysis questions: > 1) What is the maximum high the
stock attained after the signal day, > and how many days did it take
to get to the maximum high? > 2) What is the minimum low the stock
attained after the signal day, > and how many days did it take to get
to the minimum low? > > I'm having no problem identifying the
signal day, it's finding the > data to answer the questions where I
fail. I can get the answer to > question number one with: >
MaxHigh=LastValue(HighestSince(Filter,H,1),1); >
PeriodstoMaxHigh=(BarCount-LastValue(HighestSinceBars >
(Filter,H,1),1))-BarIndex()-1; > > But this makes the
assumption that a stock will always go up > because "LastValue()"
only looks at the last occurence when the > criteria were satisfied.
An assumption I could probably live with, > but there should be a
better way of doing this. > > Regardless, this solution doesn't
work for finding the answer to > Analysis question #2 because, again,
LastValue() only looks at the > last time the criteria were met.
Therefore, the MinLow is going to > be the lowest value the stock
attained after the last signal day. > > I thought I could put
in a loop to iterate through each successive > day after each signal
day and check if it's making higher highs or > lower lows - no luck.
Ref() is an array, SelectedValue() is the last > occurence,
ValueWhen() is an array, can't use High[] because I won't > know what
goes between the brackets because, even though I can get > AA to
return the correct barindex, BarIndex() is an array. > > I'm
sure there's something easy I'm missing because closing a > position
based on yesterday's levels is a fairly common exit > strategy (isn't
it?). Wouldn't AB be able to compare today's prices > against
yesterday's prices and decide if they're higher or lower? > >
Thank you in advance for any help you can give. > >
Jeff > > > > > > > Please
note that this group is for discussion between users only. > >
To get support from AmiBroker please send an e-mail directly to >
SUPPORT {at} amibroker.com > > For other support material
please check also: > http://www.amibroker.com/support.html >
> > Yahoo! Groups Links > > > >
> > > >
Yahoo! Messenger with Voice. Make
PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For other support material please check also:
http://www.amibroker.com/support.html
YAHOO! GROUPS LINKS
|