Quick Review Replication

Hello,

I am learning to replicate the "Quick Review " in Amibroker. The below code is giving me the exact results of "Quick Review" window, but I am confused about the days in the calculation about 4,18,57,245. Please guide me If the code is not correct.

1 Week = Roc(C,5); as we have 5 trading days in a week but Roc(C,4) gave me the exact result as in "Quick Review window)

_SECTION_BEGIN("Explore All");
Filter=1;
AddColumn(C,"Close",1.2);
AddColumn(ROC(C,1),"% Daily",1.2);
AddColumn(ROC(C,4),"% Weekly",1.2);
AddColumn(ROC(C,18),"% Montly",1.2);
AddColumn(ROC(C,57),"% Quarterly",1.2);
AddColumn(ROC(C,245),"% Yearly",1.2);

_SECTION_END();

Quick review uses actual weeks, months and years. It is NOT equivalent to fixed number of bars as in your code. Your code may work on one data set but it won't work the same on other. You would need to use timeframe functions to achieve http://www.amibroker.com/guide/h_timeframe.html what Quick Review is doing (TimeFrame is one of MANY solutions possible)

1 Like

After studying the article on Time Frame , I came up with the below idea to get the weekly closing price.

_SECTION_BEGIN("Explore All");
Filter=1;
AddColumn(C,"Close",1.2);
 AddColumn(TimeFrameGetPrice( "C", inWeekly, -1 ), "Weekly close");
_SECTION_END();

Close

analysis

As seen from the above I am getting Closing price of 30-04-2020 ( which is the last trading day of last week) But I want the Closing price of Tuesday i.e 28-04-2020 ( for the purpose of Replicating the result in Quick review)

Can you please guide me.

For example, you may do like this for EOD

function DOWprice(array, daynum, delay) {
	/// Get array of specific day of week
	/// @link https://forum.amibroker.com/t/quick-review-replication/18774/4
	dd_cond = DayOfWeek() == daynum;
	sp_comp = SparseCompress(dd_cond, array);
	sp_exp = SparseExpand(dd_cond, Ref(sp_comp, -delay));	
	return sp_exp;
}

price = DOWprice(C, day_of_week = 2, delay = 1);

Filter = 1; 
format = 1.2;

AddColumn( DayOfWeek(), "DayOfWeek", 1 );
AddColumn( C, "Close", format );
AddColumn( price, "DayOfWeek Price", format );

11

Or by using Now(9) or LastValue() / SelectedValue()

day_of_week = Now(9)-1;
price = DOWprice(C, day_of_week, delay = 1);

day_of_week = LastValue(DayOfWeek);
price = DOWprice(C, day_of_week, delay = 1);
1 Like

Thank you for the help. I am getting the correct value of Tuesday. But what I am trying to do is replicate the "Quick Review Window" Of Amibroker.

When I run the above code for the next day i.e wednesday I am not getting the previous week wednesday price.

My objective is to avoid running the scan for "Daily" , "Weekly", "Monthly","Quarterly","Yearly" time frames in Quick window and get all the results in single Exploration window. As I have multiple watch lists it is consuming time.

Quck%20Scan

@amisur,

Please study the code/post carefully.

To get Wednesday results set difference value at second argument of the posted function.

In that case you have to replace 2 by 3.

Or as been posted use lastvalue() function or selectedvalue function to get results for dayofweek of last date of array or of last date of analysis range.

Thank you. I got the result for weekly % Change. Are there any functions for Monthly,Quarterly,HalfYearly & Yearly? So that I can work in the similar manner?

function DOWprice(array, daynum, delay) {
	/// Get array of specific day of week
       /// @link https://forum.amibroker.com/t/quick-review-replication/18774/4
	dd_cond = DayOfWeek() == daynum;
	sp_comp = SparseCompress(dd_cond, array);
	sp_exp = SparseExpand(dd_cond, Ref(sp_comp, -delay));	
	return sp_exp;
}
day_of_week = SelectedValue(DayOfWeek());
wp = DOWprice(C, day_of_week, delay = 1);
wc = ((C-wp)/wp)*100;
Filter = 1; 
format = 1.2;
AddColumn( DayOfWeek(), "DayOfWeek", 1 );
AddColumn( C, "Close", format );
AddColumn( wp, "DayOfWeek Price", format );
AddColumn( wc, "Close",1.2);

@amisur,

Please listen, if you come here asking for help and get help and even code then within that code you got you rather do not remove links to original source/post which in addition explains how to use it. I do consider such "I do not bother" attitude as disrespectful (even if is small code/post because what you do on small works you would also do on large ones). Writing post and code takes time. It has not been you taken the time to think about it and it has not been you having come up with something that works. Reality check... it has been someone else. You may leave out things if you come up with something yourself.

What's your goal? Asking for help on code here and then getting (paid) reward elsewhere?
Or is it just "I don't bother" attitude?

I am very close to leaving this forum completely. I am not dependent on it anyway as it is just for fun.

Adios....

5 Likes

@amisur - if you copy paste someone's else code you MUST keep it with original comments if they refer to this forum and you MUST quote the author. These are rules of this forum. ALWAYS show appreciation to original author and ALWAYS show the source. If you don't follow the rules you will be not be allowed to participate.

2 Likes