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

RE: [amibroker] Loop thru past N bars



PureBytes Links

Trading Reference Links

Perhaps:

Str = "";
nBarsToLoopThrough = 10;
for (n=BarCount-1; n >= BarCount - nBarsToLoopThrough; n--)
{
Str = Str + NumToStr(n,1.0,False)+"\n";
}
str;

Not sure what you mean with "I want it to start from the 1st bar in the
chart."....you are starting at the end and count backwards. Perhaps this:

Str = "";
nBarsToLoopThrough = 10;
for (n=BarCount - nBarsToLoopThrough-1; n< BarCount; n++)
{
Str = Str + NumToStr(n,1.0,False)+"\n";
}
str;

Copy to a new Indicator, Apply, Open your Interpretation screen, and click
on your chart to see a list of array elements addressed by the loop.

best regards,
herman

-----Original Message-----
From: stevenpang21 [mailto:stevenpang21@xxxxxxxxx]
Sent: Monday, February 21, 2005 3:47 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Loop thru past N bars




Hi,
I am trying to write a for loop to loop thru the past N bars for each
backtesting cycle.

I did something like this:

lastbar = LastValue(BarIndex());

for (n=lastbar; n>=lastbar-20; n--)
{
check close[n], etc.
}

But it seems that this loop is only run once during the auto analysis
starting at the very last bar of the chart. I want it to start from
the 1st bar in the chart.

Thanks,
Steven.








Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html




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 the Yahoo! Terms of Service.




------------------------ Yahoo! Groups Sponsor --------------------~--> 
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
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/