myHHVMACD = HHV(IIf(u1 == 1, var1, -999999), 99999);
HowardFor loops can be nested. Be careful to avoid confusion between the index variables controlling each loop. But you can refer to the value of the index of the outer loop when setting the range of the inner loop, which seems to be what you are asking.Hi Karl --Here is a link to the AmiBroker Reference for the For statement:
https://www.amibroker.com/guide/keyword/for.htmlfor( i = 1; i < BarCount; i++ )
{
for( j = i; j < myCount; j++ )
{
// your comparison
}
}Best,On Fri, Apr 1, 2016 at 9:12 PM, karl.bergerson@gmail.com [amibroker] <amibroker@yahoogroups.com> wrote:Can I use a nested FOR loop or .. to perform
an operation such as HHV on a subset of records
from a larger set of records where the subset is
chosen based on meeting a certain condition?
EXAMPLE:
I want to do the HHV of column 3 on 4 records
within the last 7 records where column 4 value
is 1. Column 2 is a flag for me. The number
of records to consider (4) is set by user.
I need the loop to keep reading and calculating
the values until 4 records have been found that
meet the condition and then perform the operation
such as HHV.
I seem unable to figure out how to write this code.
Any help would be Much appreciated!!
col 1 col 2 col 3 col 4
date1 close1 value1 1
date2 close2 value2 0
date3 close3 value3 0
date4 close4 value4 1
date5 close5 value5 1
date6 close6 value6 0
date7 close7 value 1
I want the HHV of records from date1, date4,
date5 and date7.
--
〒002-0857
札幌市北区屯田7条11丁目10-10
電話 050-5809-7325 (Skype)
Posted by: Karl Bergerson <karl.bergerson@gmail.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
EmoticonEmoticon