[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Intraday indicator loop question



PureBytes Links

Trading Reference Links

I can't give a complete answer, but here are some tidbits I have 
picked up along the way:
(1) Check out the 3rd party timeframe.dll for referencing various 
periods of time in your formulas
(2)if(TimeNum()==093000) - This line will not work b/c you cannot 
reference an array within a loop.  You could do something like this 
though:
TimeVar = TimeNum();
if(TimeVar[i] = 093000)
This wouldn't really work but the point is you must reference a 
specific point within the array, in this case [i].
Think of it like this: A "normal" AFL function iterates each line as 
a full array, so that "yourarray"=iif(H>MACD(),1,0); calculates the 
return of 1 or 0 for every data point - in other words every bar in 
your chart.  However, a looping function lets you control what to 
calculate, so that "yourarray" can be controlled only to hold 1 
value, for example at bar 1 of your chart.
So, If your chart had five bars your data could look like this:
                    B1 B2 B3 B4 B5
"yourtypAFLarray"   0  0  1  1  0
"yourlooparray"     0  1

Here's some code that may help:

day  = 0; //your day array
time = 0; //your time array

for(i=1;i<BarCount;i++)
{
time = time + 1; //assume for example time in hrs. and 6 hrs./day
day  = Iif(frac(time/6)==0,day+1,day);
...other commands}


--- In amibroker@xxxxxxxxxxxxxxx, "g_r_e_g_69" <gregoliver_@xxxx> 
wrote:
> I am currently doing some backtesting on a bunch of (1 minute) 
> intraday data and am looking to create a few indicators that 
> accumulate throughout the day but reset to a certain level at the 
> beginning of every new day.  However, I am an inexperienced 
> programmer and am not yet very proficient at creating loops.  
Perhaps 
> someone out there can help me.  How can I create an indicator with 
a 
> loop that shows the intraday high and low?
> 
> Here's what I tried so far (it didn't work)...
> 
> 
> IntradayH[0]=High[0];
> IntradayL[0]=Low[0];
> 
> for(i=1;i<BarCount;i++)
> {
> if(TimeNum()==093000)
> {
> IntradayH[i]=High[i];
> IntradayL[i]=Low[i];
> }
> else
> {
> IntradayH[i]=max(IntradayH[i-1], High[i]); 
> IntradayL[i]=min(IntradayL[i-1], Low[i]);
> }
> }
> Plot( IntradayH, "High", 27); Plot( IntradayL, "Low", 32);
> 
> 
> NOTE:  I know that I can create the intraday high/low with the 
> following AFL code...
> 
> IntradayH = IIf(TimeNum() == 930000, High, HHV(High, BarsSince
(TimeNum
> () == 093000)));
> IntradayL = IIf(TimeNum() == 930000, Low, LLV(Low, BarsSince(TimeNum
> () == 093000)));
> 
> ...but I want to know how to do it with a loop because I have a 
> couple of other ideas that also need to be reset at the beginning 
of 
> each day, but are too complex to code without a loop (without the 
> program crashing).  If anyone can help it would be much appreciated.
> 
> Greg


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/