Rewinding Chart Similar to Marketsmith

Hello everyone,

I'm trying to create a chart I can 'rewind', ie I set a Date in the parameters and the chart only shows the bars up to and including that date. Also any chart code will also disregard the 'future bars'.

Marketsmith has a similar feature and I've been looking to implement something in Amibroker as well.

It seems successful so far except one caveat: the date axis doesn't move with it!

Here's the code:

_SECTION_BEGIN("Rewind");
{
	// Set rewind bars
	NowDate		= Now(1);
	RewindDate 	= ParamDate("Rewind to:", NowDate, 1);
		
	// from Amibroker forum (code taken directly from Tomasz post on how to use Lookup
	bi = BarIndex();
	RewindBars =  Lookup( bi, _DT(NowDate), -1 ) - Lookup( bi, _DT( RewindDate), -1 );
	
	// set new OHLC arrays
	L = Ref(L, -RewindBars);
	H = Ref(H, -RewindBars);
	C = Ref(C, -RewindBars);
	O = Ref(O, -RewindBars);
}
_SECTION_END();

Of course I'm not really doing anything with the date, that is because I'm completely stumped on how to rewind it. If it's not possible, that's too bad, but at least, I would like to know.

One other weird thing, I tried to do it 'properly' by resetting a composite ticker each time and adding the current ticker OHLC to the composite OHLC, then SetForeign() to the composite. However it always returned false, meaning it couldn't find it. This is why I chose to directly assign the OHLC bars to a Ref value of themselves.

Thanks!
Mike

You would have to use OLE ZoomToRange function via some trigger

etc.

No offense fxshrat, because you are a great contributor, but your answer doesn't give me what I'm looking for.

The last two links do not rewind the chart, they only zoom to specified locations, but the forward looking bars still exist. Using an OLE seems to go too far for me to be worth it, for now.

Note how I stated that I want the chart formula to not execute on the bars that are now in the future after the rewind:

Also any chart code will also disregard the 'future bars'.

So if you use Amibroker 6.38 and rewind MRVL to 11/20/2020 using my code (which you can add to any chart easily), it goes from looking like this:
image

To this:
image

Hopefully you can see what I mean now, if you look at the date axis it doesn't rewind with the rest of the chart so the date axis is now misleading.

Thanks
Mike

You would have to create own date axis (and vertical grid) using Gfx* functions.

1 Like

Looks like fun! Thanks @fxshrat!

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