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

Re: [amibroker] Dynamic cursor through three floating windows and two differents contracts



PureBytes Links

Trading Reference Links

Reinsley,

Here is some various pieces of code scattered between several of my  
modules.  I tried to piece them together to be useful.  You will need  
to supply a MouseFirstDown variable.  Examples for this are in  
Tomasz's button examples.  These routines save the static variable  
with the chartID as a key.  However, I define FP_ChartID to this.  You  
can substitute some other constant so that it is not keyed to any  
particular chart.

BR,
Dennis

/*================================================================
// Return the Y axis value ($) for a number of pixels
// this gives a factor for plot offsets for stacking shapes which are  
pixel based graphics
*/
function PixelsToYAxis( pixels ) {
	return pixels * (Status( "axismaxy" ) - Status( "axisminy" )) /  
Status( "pxheight" );
}

/*================================================================
// Plot Vertical Line leaving a gap around the price bars
// Style = styleDashed|styleThick etc.
// mode = 1: bot only, 2: top only, 3: both
// Offset is in pixels
// Zorder (AB5.24)
*/
procedure f_PlotVert( array, mode, color, style, Offset, Zorder ) {
	global barDensity;
	LineStyle = styleOwnScale|styleNoLabel|styleHistogram|style;
	botLine = Status( "axisminy" );
	topLine = Status( "axismaxy" );
	Offset = PixelsToYAxis( Offset );
	if ( mode&1 ) { Plot( (array>0) * (L-Offset), "", color, LineStyle,  
botLine, topLine, 0, Zorder ); }
	if ( mode&2 ) { Plot( (array>0) * (H+Offset-topLine), "", color,  
LineStyle, botLine-topLine, 0, 0, Zorder ); }
}


	// Initialize the selected bar
	v_LastBar = barCount-1;
	FP_ChartID = getChartID();

	if ( MouseFirstDown ) { // set the new selected bar -- you will need  
a mouse down routine to set this variable -- mine is too complex.
		SelectedDateTime = SelectedValue( v_DateTime );
		SelectedBarIndex = SelectedValue( v_BarIndex );
		FP_SelectedBar = SelectedBarIndex - v_BarIndex[0];
		if ( FP_SelectedBar == v_LastBar )  
{StaticVarSet( "FP_SelectedDateTime"+FP_ChartID, Null); } // special  
mark for last bar
		else {StaticVarSet( "FP_SelectedDateTime"+FP_ChartID,  
SelectedDateTime); }
	}

	SelectedDateTime =  
Nz( StaticVarGet( "FP_SelectedDateTime"+FP_ChartID ),  
v_DateTime[v_LastBar]);
	SelectedBarIndex =  
LastValue( ValueWhen( SelectedDateTime==v_DateTime, v_BarIndex,1 ) );
	FP_SelectedBar = Min( v_LastBar, Max( 0, SelectedBarIndex -  
v_BarIndex[0] ) );

	// Plot the vertical marker for the selected bar --  if it is the  
last bar, then make it faint and shifted one bar to first blank bar
	SelectedArray = 0;
	SelectedArray[FP_SelectedBar] = 1;
	if ( FP_SelectedBar < v_LastBar ) { f_PlotVert( SelectedArray, 3,  
colorCyan, styleThick, 10, Z0 ); }
	else { Plot( SelectedArray, "", ColorRGB( 200,255,255 ),  
styleOwnScale|styleNoLabel|styleHistogram, 0, 1, 1, 0 ); }



On Jul 6, 2009, at 4:22 PM, reinsley wrote:

>
> Hi Dennis,
>
> Thank you for your help.
>
> My first thought was to add / hide the quote marker with :
>
> Hides the quote selector line on per-pane basis,
> and programmatically via SetChartOptions function:
> SetChartOptions( 2, chartHideQuoteMarker );
>
> I was baffled to identify the vertical line of pane1 vs vertical  
> line of
> pane2...
>
> Your idea to add my own quote marker solves some points and will raise
> others, a "static variable" exercise shows its face.
>
> Would you mind to post your code ? I could adapt it and start on a  
> good
> basis to deal with two panes.
>
> Best regards
>
>
>
>
> Dennis Brown a écrit :
>>
>>
>>
>> Reinsley,
>>
>> You talked about cursors, but if you only need to show the selected
>> bar from one chart on other charts, then you can do that with AFL.
>> Save the time for the selected bar in a static variable that the
>> charts read and display a vertical line at the bar that contains that
>> time (use the date also if you need to -- datetime). There can be a
>> couple of variations on this theme depending on you aesthetics. I my
>> case, I hide the selected bar marker and supply my own vertical  
>> marker
>> that has a break around the price bars, but is otherwise on top of
>> other things like area charts. I am only working on one chart though,
>> so I do not have an AFL to share. I believe I previously posted my
>> vertical line with a break around price bars. If not, I can send it
>> again. It is simple.
>>
>> BR,
>> Dennis
>>
>> On Jul 6, 2009, at 1:24 PM, reinsley wrote:
>>
>>>
>>> To say it in another way :
>>>
>>> We can display two "vertical line " cursors, one in each different
>>> floating windows running two differents futures.
>>>
>>> Can we link these two cursors to move them together ?
>>>
>>> TIA
>>>
>>>
>>> reinsley a écrit :
>>>>
>>>>
>>>>
>>>> Hello,
>>>>
>>>> I have 4 windows : The main AB application normal window plus three
>>>> floating windows.
>>>>
>>>> I follow two futures : contract_of_country_1 and
>>>> contract_of_country_2
>>>>
>>>> The AB normal windows shows contract_of_country_1 in 5 minutes
>>>>
>>>> The floating windows #1 shows contract_of_country_2 in 5 minutes
>>>> The floating windows #2 shows contract_of_country_1 in 2 minutes
>>>> The floating windows #3 shows contract_of_country_2 in 2 minutes
>>>>
>>>> Symbol link 1 is active between normal and floating_2
>>>> Symbol link 2 is active between floating_1 and floating_3
>>>>
>>>> How can I dynamically display the vertical line cursor (or  
>>>> crosshair)
>>>> simultaneously on the four windows ?
>>>>
>>>> NB : The green and red putter do the trick, they are displayed on  
>>>> the
>>>> four windows, but it is static.
>>>>
>>>> Thank you in advance
>>>>
>>>> Best regards
>>>>
>>>>



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

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

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

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

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/