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

[amibroker] Re: Zoom Link



PureBytes Links

Trading Reference Links

Had done it before, so until Tomasz gets to it -

//--------------------------------------------------------------------------------------------------
//
//  This function checks the current display range, and if it has
changed, it
//  synchronizes all other windows (documents) to that range.  
//
//  To use, #include this file in an indicator in each window
(document) to be 
//  synchronized.  Normally it sync's other windows (documents) when
the caller's
//  displayed date range changes, but it has an optional parameter to
force a re-sync.
//
//  NOTE - the only downside is that the blank bars on the right side are
//         removed by the ZoomToRange method
//
//  Bruce R - 12/10/08
//
//--------------------------------------------------------------------------------------------------

function ZoomSync( force )
{
	//  All variables are made local to guarantee naming collisions or
side effects
	local			bv, dr, Curstdt, Curenddt, prevstdt, prevenddt, Curststr,
Curendstr;
	local			OAB, OAD, dcount, i, OADoc, OAW, OADocWin, res;

	//  Get a count of the number of documents
	OAB				= CreateObject( "Broker.Application" );
	OAD				= OAB.Documents;
	dcount			= OAD.Count;

	//  Process multiple windows (documents)
	res				= False;
	if ( dcount > 1 )
	{
		//  Get current and last start and end DateTimes's
		bv				= Status( "barvisible" );
		dt				= DateTime( );
		Curstdt		= LastValue( Lowest( IIf( bv, dt, LastValue( dt ) ) ) );
		Curenddt		= LastValue( Highest( IIf( bv, dt, 0 ) ) );
		prevstdt		= Nz( StaticVarGet( "_prevstdt" ) );
		prevenddt		= Nz( StaticVarGet( "_prevenddt" ) );

		//  Check for a new date/time range
		if ( ( Curstdt != prevstdt OR Curenddt != prevenddt ) OR force )
		{
			//  Set the new last values
			StaticVarSet( "_prevstdt", Curstdt );
			StaticVarSet( "_prevenddt", Curenddt );
	
			Curststr		= DateTimeToStr( Curstdt );
			Curendstr		= DateTimeToStr( Curenddt );
	
			//  Loop through the document collection
			for ( i = 0; i < dcount; i++ )
			{
				//  If it is not the active document -
				OADoc			= OAD.Item( i );
	
				//  NOTE - it doesn't hurt to sync the current window and it makes all
				//         windows have no blank bars on the right so they look
the same
				//if ( OADoc != OAB.ActiveDocument )
				{
					//  Get the document window and zoom to range
					//_TRACE( "  Zoom to range document - " + i + " , " + 	Curststr +
" - " + Curendstr );
					OADW			= OADoc.Windows;
					//  Document window count assumed to be 1
					OADocWin		= OADW.Item( 0 );
					OADocWin.ZoomToRange( Curststr, Curendstr );
				}
			}
			res				= True;
		}
	}
	return		res;
}

//  Call for synchronization
ZoomSync( False );



--- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@xxx> wrote:
>
> TJ,
> 
> Would 'zoom link' functionality be difficult to implement...?
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/