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
- Visit your group "amibroker" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
