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

RE: [amibroker] Re: For loop help



PureBytes Links

Trading Reference Links

Dimitris, Dingo, Herman, Graham,

Thanks for your input. I tried everything you suggested. For your 
info, here is what worked. Adding the statement:

SetBarsRequired(10000,10000); 

Made the code run without error. What I don't understand now is that 
the Help file says that the SetBarsRequired is not needed if you are 
running pure AFL code, its only needed if you are running scripts or 
dll's. Does anyone have any comments here?

The statement:

for(i = StartDate; i < EndDate + 1; i = i + 1)

works as is. It tells the loop to work up through i=EndDate, but stop 
before i is greater than EndDate + 1. This type of statement is used 
in the help manual.

PHigh without the [i] works if you are only going to use it as a 
scalar later. But PHigh[I\i] also works.

Dingo, I don't understand why the original code worked as-is for you. 
I am using V4.50. Are you using a later beta version?

Again, thanks for your inputs.

Bill



--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> The solution is to add a line in the beginning [and change PHigh to 
> PHigh[i]].
> Try the
> 
> SetBarsRequired(1000,1000); 
> Range = 20;
> EndDate = LastValue(BarIndex());
> StartDate = EndDate - Range + 1;
> for(i = StartDate; i < EndDate + 1; i = i + 1)
> {
> PHigh[i] = H[i];
> }
> Plot(PHIGH,"",1,1);
> Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Graham" <gkavanagh@xxxx> wrote:
> > EndDate = LastValue(BarIndex());
> > i < EndDate + 1 which is saying LastValue(BarIndex()) +1 
> > 
> > You are specifying the last bar past the end of the charts 
> > The last bar is LastValue(BarIndex())
> > So use i < EndDate but depending on your formula if it looks into 
> the future
> > you may need to move the enddate further back with any future 
look 
> forwards.
> > 
> > You can also replace i=i+1 with just i++
> > And you may need to have the Phigh as Phigh[i]
> > 
> > 
> > 
> > Cheers,
> > Graham
> > http://www.golala.com/forums/?mforum=asxsharetrading
> > http://groups.msn.com/fmsaustralia 
> > 
> > -----Original Message-----
> > From: billbarack [mailto:wbarack@x...] 
> > Sent: Wednesday, 28 January 2004 4:24 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] For loop help
> > 
> > 
> > Can anyone find out why I'm getting a "Error 7 Subscript out of 
> > Range" error statement on the following code?
> > 
> > Range = 20;
> > EndDate = LastValue(BarIndex());
> > StartDate = EndDate - Range + 1;
> > for(i = StartDate; i < EndDate + 1; i = i + 1)
> > {
> > 		PHigh = High[i];
> > }
> > 
> > I've tried everything I could think of to understand this (even 
> > reading and re-reading the help files :>)  ). These senior 
moments 
> > are starting to happen far to often for me !
> > 
> > Thanks,
> > 
> > Bill
> > 
> > 
> > Send BUG REPORTS to bugs@xxxx
> > Send SUGGESTIONS to suggest@xxxx
> > -----------------------------------------
> > 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 
> > 
> > ------------------------ Yahoo! Groups Sponsor -------------------
--
> ~--> Buy
> > Ink Cartridges or Refill Kits for your HP, Epson, Canon or 
Lexmark 
> Printer
> > at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
> > http://www.c1tracking.com/l.asp?cid=5511
> > http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
> > ------------------------------------------------------------------
--
> -~->
> > 
> > Yahoo! Groups Links
> > 
> > To visit your group on the web, go to:
> > http://groups.yahoo.com/group/amibroker/
> > 
> > To unsubscribe from this group, send an email to:
> > amibroker-unsubscribe@xxxxxxxxxxxxxxx
> > 
> > Your use of Yahoo! Groups is subject to:  
> http://docs.yahoo.com/info/terms/


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 

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/amibroker/

To unsubscribe from this group, send an email to:
 amibroker-unsubscribe@xxxxxxxxxxxxxxx

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