Shift+Double Click-like Backtest Chart Behavior, but in Exploration

Hi,

I know this sounds trivial, but I haven't found a simple way to do it. In the backtest results I can hold SHIFT, then double-click a row to simultaneously bring up the ticker on the chart and bring the Date from that row into focus on the chart.

It would be immensely helpful if I could do this from an exploration as well, as I'm developing or analyzing indicators/signals/etc. and going through a long list of thousands of exploration results. I can't do this in Backtest mode because columns cannot be easily added there, etc. Explore seems like the right tool for the job. Doing something like this was actually my main motivation for trying out AmiBroker, as I couldn't do good interactive charting in Python.

Right now I can turn on the sync chart on selection and it works great for what it does, I can use the keyboard up/down arrows to quickly go through results. But, not having it synced to the bar of interest is a big hinderance to moving quickly.

IMHO, ideal solution would be to sync chart + specific bar, in Explore Results (a'la backtest shift+dblclick behavior), and be able to use up/down arrows (auto sync). This way, one can focus on the chart while moving quickly, eyes can immediately focus where they need to be. An extra bonus would be the ability to control the position of the bar of interest (i.e. left (current behavior), center, right).

Any way to currently do this? I saw a few posts about it, but no concrete solution.

Thanks

1 Like

SHIFT and CTRL keys in listviews in Windows are coupled with MULTI-SELECTION. This is how Windows works and no application should change standard behavior of list views.

Instead you should RIGHT CLICK and use "Show arrows for current trade". As of version 6.41.0 it ALSO WORKS in Exploration (not only in backtest).

Thank you @Tomasz. I updated to the 6.41 beta and it does indeed now behave like the backtest results.

I'm not sure I understand the complexities of keys and gui controls, and it appears shift+dbl click does now have the same effect as right-click "Show arrows for current trade". But in any case, I'm actually trying to avoid the clicks and menus altogether. I'd much prefer symbol+date sync immediately when any new selection is made.

My brain just finds it way too hard to rapidly parse the location of the trade arrow on the chart with the current behavior while clicking around the explore list.

Some users had mentioned AHK on the forum, so I thought I'd take a stab at getting the behavior I'm looking for with it. It seems to work great. The caveat here is I have to press a key to activate this after I make a new selection (I bound it to right arrow). Of course I'd prefer this to trigger when a new selection is made, but this works in a pinch.

I'll try to contribute where I can, hopefully someone finds it useful:

; Set `zoom_range_months` to whatever start/end range you want to see
; on the chart.
zoom_range_months = 6

SubtractMonthsFromDate(end_date, num_months) {
	; We already have the `end_date`. To use the `ZoomToRange` AmiBroker
	; OLE function, we need to also give it a start date. Parse `end_date`
	; and subtract `num_months` to acquire the `start_date`.
	RegexMatch(end_date, "O)(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)", match)
	year := match.year
	month := match.month
	day := match.day
	if (year = "") {
		Return, 0
	}
	if (month > Mod(num_months, 12)) {
		month := Format("{:02}", Mod(month - num_months, 12))
		year := year - num_months // 12
	} else {
		month := Format("{:02}", 12 - Mod(num_months, 12) + month)
		year := year - (num_months // 12 + 1)
	}
	start_date = %year%-%month%-%day%
	Return, start_date
}

Right::

target_symbol = ""
target_date = 0
start_date = 0

; Get the selected row in Analysis/Backtest results
ControlGet, selected_row, List, Focused, SysListView323, Analysis1

; Grab symbol and date from first few columns
Loop, Parse, selected_row, %A_Tab%
{
	if A_Index = 1 ; symbol field in explore/backtest
	{
		target_symbol = %A_LoopField%
	}
	else if A_Index = 2 ; date field in explore
	{
		target_date = %A_LoopField%
		start_date := SubtractMonthsFromDate(target_date, zoom_range_months)
		if (start_date != 0) {
			break
		}
	}
	else if A_Index = 3 ; date field in backtest
	{
		target_date = %A_LoopField%
		start_date := SubtractMonthsFromDate(target_date, zoom_range_months)
		break
	}
}

if (start_date != 0) {
	AB := ComObjCreate("Broker.Application")
	AW := AB.ActiveWindow
	AW.ZoomToRange(start_date, target_date)
}

return

;--------------------------------------------------------------------------------------
guiclose:
exitapp

f12::reload
+esc::exitapp

#Persistent
#SingleInstance force

Disclaimer: I have zero AHK/OLE/GUI experience so please forgive anything idiotic here.

Cheers

2 Likes

Small, but very helpful update to this script. Just before the Right:: line add a line with #IfWinActive, Analysis1

This will ensure the arrow key hook only triggers from the analysis window and doesn't affect other windows like your text editor. I'm satisfied with this as a somewhat wonky, but functional solution for now.

1 Like

Note: AmiBroker uses your system date format. Mine is set to YYYY-MM-DD for this script. If you use a different system date format, you'll need to adjust the SubtractMonthsFromDate date parsing.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.