Unless you use zero Blank bars in the right Margin this type of code
may not always work correctly, you can add an offset to the last bar
index() to correct for this (set to 4 in the demo code below). AFAIK,
we cannot set/read the number of blank bars set in preferences
so you will have to remember to set this properly in you formulas. The need for SetBarsRequired() in this application may also confuse some users. When Applying a formula AB scans all bars and if you don't use SetBarsRequired() this can generate transient conditions. This may be a concern if you are real time trading from the indicator. If you get confusing results it is always a good habit to write some test code as shown below. In fact, I have a folder in my chart-tree for just such small test programs :-) Plot(C,"",1,128); SetBarsRequired(1000000,1000000); BlankBarsInRightMargin = 4; Plot(BarIndex()==Status("FirstVisibleBar"),"",5,styleArea|styleOwnScale,-10,10); Plot(BarIndex()==Status("LastVisibleBar")-BlankBarsInRightMargin,"",4,styleArea|styleOwnScale,-10,10); Title = "\n"+ "SelectedBarIndex: "+NumToStr(BarIndex(),1.0)+"\n"+ " FirstBarIndex: "+NumToStr(Status("FirstVisibleBar"),1.0)+"\n"+ " LastBarIndex: "+NumToStr(Status("LastVisibleBar"),1.0); best regards, herman Fred wrote: __._,_.___HVC = Highest(ValueWhen(BarIndex() >= Status("FirstVisibleBar") AND BarIndex() <= Status("LastVisibleBar"), C));--- In amibroker@yahoogroups.com, "wavemechanic" <[EMAIL PROTECTED]> wrote:Wayne: I just took a look at your code. For starters, you are settingBegin and End to BarIndex() and, as a result numBars = 1. I don't think that is what you want.Bill ----- Original Message ----- From: "wlandry01" <[EMAIL PROTECTED]> To: <amibroker@yahoogroups.com> Sent: Tuesday, August 29, 2006 12:09 PM Subject: [amibroker] Re: Need Help With FirstVisibleBarIndexThomas/WaveMechanic, Thanks for the input - very helpful. Part of my confusion is thatmyunderstanding was that "firstvisiblebarindex" returns the barindex value of the first bar visible, and that "firstvisiblebar"returns a"1". If "firstvisiblebarindex" returns a "1", how does it differfrom"firstvisiblebar"? Also, haven't gotten this to work yet. When I run an ExplorationonRedHat (RHAT), for example, I get a "HighValue" of 143.12, for all dates since 12/09/1999. This tells me that the "HighValue" calculation is not restricted to "NumBars", but is applied acrosstheentire data history for RHAT. There are, no doubt, several problems, but it is likely that Istilldon't have the NumBars calculation correct. Unless I can get that straight the rest certainly won't work. Following is what I currently have, based on your joint comments: Begin=ValueWhen(Status("firstvisiblebarindex"),BarIndex()); End=ValueWhen(Status("lastvisiblebarindex"),BarIndex()); NumBars=LastValue(End-Begin+1); HighValue=HHV(C,NumBars); TestValue=0.9*HighValue; Plot(C,"Close",colorLightGrey,styleHistogram|styleThick); PlotGrid(LastValue(TestValue),colorDarkRed); AddColumn(C,"Close",format=1.2); AddColumn(HighValue,"HighValue",format=1.2); AddColumn(TestValue,"TestValue",format=1.2); AddColumn(NumBars,"NumBars",format=1.2); Filter=1; On a side note, it seems I've noticed that some, if not all, ofthe"bar" statuscodes will not output to the Exploration window.Could itbe that the "NumBars" calculation is correct but is outputtinga "1"or "0" since it's using codes that are not used in theExploration module?If you have any ideas, please let me know. Thanks, Wayne --- In amibroker@yahoogroups.com, "wavemechanic" <fimdot@> wrote:Wayne: Your numBars is "backwards" and needs to subtract Begin from Endotherwise you have a negative number. Also, the only place thatyouneed LastValue is in the HighValue line. So this should work:numBars = (end - begin + 1); highValue = LastValue(C, numBars); testValue = .9 * highValue; ----- Original Message ----- From: "wlandry01" <wlandry01@> To: <amibroker@yahoogroups.com> Sent: Tuesday, August 29, 2006 9:19 AM Subject: [amibroker] Need Help With FirstVisibleBarIndexHi, I'm trying to set up an indicator that will calculate the HHVfor thecurrent chart so that I can do a PlotGrid at 90% of thathighest valueshown on the chart. I thought the following would do this: //Calculate the Number of Bars Shown on the Current Chart Begin=Status("firstvisiblebarindex"); End=Status("lastvisiblebarindex"); NumBars=LastValue(Begin-End+1); //Determine the HHV of the Chart and Calculate 90% of thatValueHighValue=HHV(C,NumBars); TestValue=0.9*LastValue(HighValue); //Plot the Result PlotGrid(TestValue,ColorDarkRed); It appears, however, that the "Begin" and "End" values are not returning the index values associated with the chart. As faras I cantell, I'm getting "1" for all values. I can't for the life ofmeunderstand what the problem might be. Any help would be greatly appreciated. WaynePlease 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 <*> To visit your group on the web, go to: http://groups.yahoo.com/group/amibroker/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/ 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
SPONSORED LINKS
YAHOO! GROUPS LINKS
__,_._,___ |
- Re: [amibroker] Re: Need Help With FirstVisibleBarIndex Herman
- [amibroker] Re: Need Help With FirstVisibleBarIndex Fred
- Re: [amibroker] Re: Need Help With FirstVisibleBarInd... Herman
- [amibroker] Re: Need Help With FirstVisibleBarInd... wlandry01
- Re: [amibroker] Re: Need Help With FirstVisib... Graham
- [amibroker] Re: Need Help With FirstVisi... wlandry01
- [amibroker] Re: Need Help With First... Fred
- Re: [amibroker] Re: Need Help Wi... Graham
- Re: [amibroker] Re: Need Help Wi... Steve Dugas
- Re: [amibroker] Re: Need Help Wi... Graham
- [amibroker] Re: Need Help With F... wlandry01