FYI: Found the problem: data holes! I use 24 hour RT data and it has lots of holes, depending on where i place the cursor it works or it doesn't. Gotto work out a function that returns the nearest bar with a valid DateTime.
best regards, herman --- In [email protected], "psytek2" <[EMAIL PROTECTED]> wrote: > > I had the dates swapped for the Zoomout trigger, below the corrected > code. I tested on EOD data and the code works fine, but it does not > work on RT minute datat. > > best regards, > herman > SetBarsRequired(1000000,1000000); > BI = BarIndex(); > DT = DateTime(); > CursorBar = SelectedValue(BI); > Lastbar = Min(CursorBar + 5, BarCount-1); // use Ref() > FirstBar = Max(CursorBar - 5,0); > LDT = LastValue(ValueWhen( Lastbar ==BI, DT )); > FDT = LastValue(ValueWhen( FirstBar ==BI, DT )); > LDTstr = DateTimeToStr( LDT ); > FDTstr = DateTimeToStr( FDT ); > > FDT1 = LastValue(ValueWhen( BI==0, DT )); > LDT1 = LastValue(ValueWhen( BarCount-1==BI, DT )); > LDTstr1 = DateTimeToStr( LDT1 ); > FDTstr1 = DateTimeToStr( FDT1 ); > > AB = CreateObject("Broker.Application"); > AW = AB.ActiveWindow; > ZoomIn = ParamTrigger("Click to Zoom in","ZOOM"); > ZoomOut = ParamTrigger("Click to Zoom out","ZOOM"); > if( ZoomIn ) > { > if( AW.ZoomToRange( FDTstr, LDTstr ) ) > { > Msg="Zoom In successfull"; > } > } > if( ZoomOut ) > { > if( AW.ZoomToRange( FDTstr1, LDTstr1 ) ) > { > Msg="Zoom Out successfull"; > } > } > else Msg = ""; > > Plot(C,"",1,128); > Title = "\n"+Msg+"\n"+ > " BI: "+NumToStr(BI,1.0,False)+"\n"+ > " DT: "+NumToStr(DT,1.0,False)+"\n"+ > " FBAR: "+NumToStr(Firstbar ,1.0,False)+"\n"+ > " CBAR: "+NumToStr(CursorBar,1.0,False)+"\n"+ > " LBAR: "+NumToStr(Lastbar ,1.0,False)+"\n"+ > "FirstDate: "+ FDTstr + "\n"+ > "Last Date: "+ LDTstr +"\n"+ > "DataStart: "+ FDTstr1 + "\n"+ > " Lastdate: "+ LDTstr1; > > > --- In [email protected], "psytek2" <psytek@> wrote: > > > > Boy, why does it work for you and not for me? Nothing happens when > i > > click the paramtriggers. Is there a setting that can prevent this? > > > > Below the code what i "expect" should zoom you back to max range > > again however that doesn't work for me either. > > > > The whole execrise is to get to know this function so that I can > step > > from signal to signal to inspect backtester trades; without tedious > > scrolling. > > > > I think the code can be simplified a bit using Ref()...but i want > it > > working first. If anyone has an idea why it might not work for me > let > > me know... > > > > best regards, > > herman > > > > SetBarsRequired(1000000,1000000); > > BI = BarIndex(); > > DT = DateTime(); > > CursorBar = SelectedValue(BI); > > Lastbar = Min(CursorBar + 10, BarCount-1); // use Ref() > > FirstBar = Max(CursorBar - 10,0); > > LDT = LastValue(ValueWhen( Lastbar ==BI, DT )); > > FDT = LastValue(ValueWhen( FirstBar ==BI, DT )); > > LDTstr = DateTimeToStr( LDT ); > > FDTstr = DateTimeToStr( FDT ); > > > > LDT1 = LastValue(ValueWhen( BI==0, DT )); > > FDT1 = LastValue(ValueWhen( BarCount-1==BI, DT )); > > LDTstr1 = DateTimeToStr( LDT1 ); > > FDTstr1 = DateTimeToStr( FDT1 ); > > > > AB = CreateObject("Broker.Application"); > > AW = AB.ActiveWindow; > > ZoomIn = ParamTrigger("Click to Zoom in","ZOOM"); > > ZoomOut = ParamTrigger("Click to Zoom out","ZOOM"); > > if( ZoomIn ) > > { > > if( AW.ZoomToRange( FDTstr, LDTstr ) ) > > { > > Msg="Zoom In successfull"; > > } > > } > > if( ZoomOut ) > > { > > if( AW.ZoomToRange( FDTstr1, LDTstr1 ) ) > > { > > Msg="Zoom Out successfull"; > > } > > } > > else Msg = ""; > > > > Plot(C,"",1,128); > > Title = "\n"+Msg+"\n"+ > > " BI: "+NumToStr(BI,1.0,False)+"\n"+ > > " DT: "+NumToStr(DT,1.0,False)+"\n"+ > > " FBAR: "+NumToStr(Firstbar ,1.0,False)+"\n"+ > > " CBAR: "+NumToStr(CursorBar,1.0,False)+"\n"+ > > " LBAR: "+NumToStr(Lastbar ,1.0,False)+"\n"+ > > "FirstDate: "+ FDTstr + "\n"+ > > "Last Date: "+ LDTstr; > > > > > > > > --- In [email protected], "Anthony Faragasso" <ajf1111@> > > wrote: > > > > > > Herman, > > > > > > I just tried your formula and it zooms at the cursor position 10 > > bars + / - both ways on my computer.....could you add UnZoom > also :) > > > > > > Thanks > > > Anthony > > > ----- Original Message ----- > > > From: psytek2 > > > To: [email protected] > > > Sent: Sunday, August 13, 2006 5:59 AM > > > Subject: [amibroker] Re: Do i need to install ActiveX? > > > > > > > > > Thank you Tomasz, I am getting closer but my test code still > > doesn't > > > want to do what i want. I want the code, when I click a > > ParamTrigger > > > to zoom automatically +/- n bars around the cursor position. > > > > > > Can anybody tell my why this code doesn't work? > > > > > > Many thanks! > > > herman > > > > > > SetBarsRequired(1000000,1000000); > > > BI = BarIndex(); > > > DT = DateTime(); > > > CursorBar = SelectedValue(BI); > > > Lastbar = Min(CursorBar + 10, BarCount-1); > > > FirstBar = Max(CursorBar - 10,0); > > > LDT = LastValue(ValueWhen( Lastbar ==BI, DT )); > > > FDT = LastValue(ValueWhen( FirstBar ==BI, DT )); > > > LDTstr = DateTimeToStr( LDT ); > > > FDTstr = DateTimeToStr( FDT ); > > > > > > AB = CreateObject("Broker.Application"); > > > AW = AB.ActiveWindow; > > > ZoomIn = ParamTrigger("Click to Zoom in","ZOOM"); > > > if( ZoomIn ) > > > { > > > if( AW.ZoomToRange( FDTstr, LDTstr ) ) > > > { > > > Msg="Zoom successfull"; > > > } > > > } > > > else Msg = ""; > > > Title = "\n"+Msg+"\n"+ > > > " BI: "+NumToStr(BI,1.0,False)+"\n"+ > > > " DT: "+NumToStr(DT,1.0,False)+"\n"+ > > > " FBAR: "+NumToStr(Firstbar ,1.0,False)+"\n"+ > > > " CBAR: "+NumToStr(CursorBar,1.0,False)+"\n"+ > > > " LBAR: "+NumToStr(Lastbar ,1.0,False)+"\n"+ > > > "FirstDate: "+ FDTstr + "\n"+ > > > "Last Date: "+ LDTstr; > > > > > > --- In [email protected], "Tomasz Janeczko" <groups@> > > > wrote: > > > > > > > > BlankHerman, > > > > > > > > "new ActiveXObject" is a JScript-only syntax (so it can be > used > > in > > > EXTERNAL .JS file). > > > > > > > > > > > > If you want to use it from AFL use CreateObject. > > > > > > > > AB = CreateObject("Broker.Application"); > > > > > > > > > > > > Best regards, > > > > Tomasz Janeczko > > > > amibroker.com > > > > ----- Original Message ----- > > > > From: Herman > > > > To: _AmiBroker > > > > Sent: Saturday, August 12, 2006 3:23 PM > > > > Subject: [amibroker] Do i need to install ActiveX? > > > > > > > > > > > > I am trying to run this code: > > > > > > > > AB = new ActiveXObject("Broker.Application"); > > > > AW = AB.ActiveWindow; > > > > if( AW.ZoomToRange( FDTstr, LDTstr ) ) > > > > { > > > > WScript.Echo("Zoom successfull" ); > > > > } > > > > > > > > and get a syntax error on the first line, > > > > I change computers recently, how do i know ActiveX is > > installed? > > > How do I install it if it is not there? > > > > TIA, > > > > herman > > > > > > > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------- -- > -- > > -------- > > > > > > avast! Antivirus: Inbound message clean. > > > > > > Virus Database (VPS): 0632-2, 08/10/2006 > > > Tested on: 8/13/2006 6:17:00 AM > > > avast! - copyright (c) 1988-2006 ALWIL Software. > > > > > > 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 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/
