AddColumn(C,"Close");
AddColumn(Mom_P,"White Body(%)");
AddColumn((dt), "White Body Date",formatDateTime);
AddColumn(C_MA5H1Dev,"Deviasi Close to MA5");
_SECTION_END();
But the problem are:
The explore limited to White Body date 2020-08-27 when i run explore range 1 recent day(s) or from- to date 2020-09-04 and 2020-09-04.
How to make this afl explore more previous daily candle (ie previous 20 candle daily) when i run in range 1 recent day(s).
Because i run exlpore this afl in intraday time frame, its show more than 1 signal in a day. How to make only show latest signal when i use range 1 recent day(s).
First set "1 recent day(s)". Then you have to insert 20 and then hit Enter key. Then explore.
/// @link https://forum.amibroker.com/t/how-to-get-more-previous-daily-candle/21227/2
TimeFrameSet( inDaily ); // switch now to Daily
dt = DateTime();
WhiteBody_Up = ((Close - Open)/Open * 100) >= 5;
Mom_P = (Close - Open)/Open * 100;
TimeFrameRestore(); // restore time frame to original
/// Expansion AFTER TimeFrameRestore
WhiteBody_Up = TimeFrameExpand(WhiteBody_Up,inDaily);
Mom_P = TimeFrameExpand(Mom_P,inDaily);
ma5= MA(C,5);
C_MA5H1Dev = (C - ma5) / C * 100;
dn = DateNum();
newday = dn != Ref( dn, -1);
Filter = WhiteBody_Up AND C_MA5H1Dev <= 5;
// get most recent true Filter within a day
cs = SumSince(newday, Filter);
comp = TimeFrameCompress(cs, inDaily, compressHigh);
expand = TimeFrameExpand(comp, inDaily, expandFirst);
Filter = Filter AND cs == expand;
AddColumn(C,"Close");
AddColumn(Mom_P,"White Body(%)");
AddColumn(TimeFrameExpand(dt,inDaily), "White Body Date",formatDateTime);
AddColumn(C_MA5H1Dev,"Deviasi Close to MA5");
Then another general advice in regards to creating post.
It is mandatory rule to insert code via code tags.
Please read carefully and watch GIF animation there
Thank alot Mr. fxshrat for your reply.
Problem no 2. i already test and work properly to prevent multi signal in one daily candle.
But problem no 1, could you please tell me another way to achieve it than just change 1 recent(days) to 20 recent(days) because i prefer use default range 1 recent(days) for all my afl, sir.
Make sure that only single (!) analysis window is opened (Because the last closed analysis tab saves new state for all others re-opened afterwards).
Set Range to "1 recent day(s)".
Then close Analysis window.
Re-open analysis window from "File - New - Analysis" or from + button right of last chart tab. Set Range still should be "1 recent day(s)" being new default setting.
(You may save to APX file in addition, File - Save or Save as.)
I did it sir but there is no solved my problem about limited previous (White_Body) candle sir.
The problem is AFL's output only 2020-08-27 when i screening today with last candle (2020-09-04). I want to screening about 20 candle daily even i use my default range 1 recent(days).
Good Evening Mr. fxshrat and Mr. Tomasz,
I am so sorry for miss explain about the problem in my last post.
The problem actually is i want to search stock that price near ma5 in its last candle in 60minute timeframe but with White Body in its previous daily candle, let say between yesterday until 20 daily candle previous.
Because if i use range 20 recent(days) or from- to dates in window explore, these output are not signal in last candle 60m tf but its signal in previous candle.
I write/edit the afl like below :
_SECTION_BEGIN("Pullback of Momentum Daily candle");
TimeFrameSet( inDaily ); // switch now to Daily
dt = DateTime();
WhiteBody_Up = ((Close - Open)/Open) * 100 >= 5;
Mom_P = ((Close - Open)/Open) * 100;
TimeFrameRestore(); // restore time frame to original
WhiteBody_Up = TimeFrameExpand(WhiteBody_Up,inDaily);
Mom_P = TimeFrameExpand(Mom_P,inDaily); ;
ma5= LastValue(MA(C,5));
C_MA5H1Dev = ((LastValue(C) - ma5) / LastValue(C)) * 100;
Filter = WhiteBody_Up AND C_MA5H1Dev < 5; // its mean deviation price to ma5 below 5%
AddColumn(C,"Close");
AddColumn(Mom_P,"White Body(%)");
AddColumn(TimeFrameExpand(dt,inDaily), "White Body Date",formatDateTime); // i want to 1-20 daily candle previous
AddColumn(C_MA5H1Dev,"Deviasi Close to MA5");
_SECTION_END();
I use ma5= LastValue(MA(C,5)); to get ma5 value in last candle.
I very curious is this possible or not, sir.