Example on how to use Stock.Quotations.Adjust

How do i use Stock.Quotations.Adjust ? Is there any example using vbscript or jscript ?

@suresh, this feature was added implementing some user requests, as discussed in this past thread

ok. i kinda get it but need a psuedocode example before i run through it. so here is my example . Is this how we can use this feature?

Name="GOOG"
exDate="07/18/202"
multiplier=20

AB = new ActiveXObject("Broker.Application");
Stk = AB.Stocks( Name );
quote= Quotes.Retrieve(1,exDate)
Quotes.Adjust(quote.close,multiplier,<whattoputhere>,exDate,<whattoputhere>)
AB.Save()
AB.RefreshAll();

Here is AFL example

if ( ParamTrigger("Trigger", "CLICK HERE" ) ) {

	AB = CreateObject( "Broker.Application" );
	stcks = AB.Stocks();

	sym = stcks.Item( Name() );

	qts = sym.Quotations;

	multiplier = 2;
	offset = 0;
	before = False;
	dt = "2022-04-04";

	qts.Adjust("OHLC",multiplier,offset,dt,before);
}
1 Like

what conditions will we apply "before = true"?

before = true means that it will apply multiplier and offset for dates being before set date. If false then after set date.

Thanks fxshrat for providing this code. I need to do something similar for intraday ASX data which need to be adjusted for Daylight Savings.

I tried testing your code to learn further before I make my own attempt at using the Quotes.Adjust object but it causes AmiBroker to hang. See screenshot below.
Quote_adjust

Do you have any idea what could be the cause of this? Also, is there any documentation in relation to this other than this: AmiBroker Object Model but it doesn't have a mention of Quotes.Adjust?

Thanks again :slight_smile:

Can not confirm.

But I guess you have old AB version.
You have to update to most recent public AB version 6.40.4.

What's new in AmiBroker 6.40

  • OLE: added Stock.Quotations.Adjust function to perform adjustments programmatically OLE: added Stock.Quotations.Adjust() function.
    long Adjust(BSTR pszFieldList, float fMultiplier, float fOffset, DATE dDateTime, boolean bBefore)
1 Like

Good call, that was it. Had the one version previously, cheers.

Such a neat feature that was added, love AmiBroker!

@Tomasz , The documentation doesn't seem to include this new feature.

It is documented but only in the ReadMe / Release Notes

In my case the Readme file was over written with a new readme file. Anyways it is a good practice to keep the online documentation up to date.

The function is now documented here:
https://www.amibroker.com/guide/objects.html

2 Likes

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