Multi time frame filter in exploration

Hi,

First I have searched the forum and read all I found under the below link.

Now an explanation of what I am trying to do:-

Run an exploration, all in one exploration only, for stocks which satisfy the following conditions:-

where ;;; CLOSING PRICE > 20 period EMA on monthly and weekly time frames AND CLOSING PRICE < 20 period EMA on the daily time frame .

Basically looking for pullbacks.

Thanks in advance, I know that the solution will be simple but have been trying for over a month without success.

See

@JEETU usually it would be helpful if you posted your coding efforts so someone on the forum could help you solve your problem. And you must carefully read the link that was just posted by @TrendSurfer ( a few seconds before I posted)

Below is an example of code that should help get you started.

TimeFrameSet( inMonthly );
MonthlyMA = EMA( C, 20 );
TimeFrameRestore();
MonthlyToDaily_MA = TimeFrameExpand( MonthlyMA, inMonthly, expandLast );

TimeFrameSet( inWeekly );
WeeklyMovingAverage = EMA( C, 20 );
TimeFrameRestore();
WeeklyToDaily_MA = TimeFrameExpand( WeeklyMovingAverage, inWeekly, expandLast );

PullBack = C < EMA( C, 20 ); // assume you are using Daily periodicity in this analysis

Condition = PullBack AND C > WeeklyToDaily_MA AND C > MonthlyToDaily_MA;

////////////////////////
// Exploration
////////////////////////
if( Status( "action" ) == actionExplore )
{
    Filter = 1;
    AddColumn( Close, "Daily Close" );
    AddColumn( Condition, "Condition", 1.0, colorDefault, IIf( Condition, colorGreen, colorDefault ) );
    AddColumn( EMA( Close, 20 ), "Daily MA" );
    AddColumn( WeeklyToDaily_MA, "Weekly MA" );
    AddColumn( MonthlyToDaily_MA, "Monthly MA" );

}

////////////////////////
// Charting
////////////////////////
if( Status( "action" ) == actionIndicator )
{
    _SECTION_BEGIN( "Thick Bar Chart" );
    SetChartOptions( 0, chartShowArrows | chartShowDates );
    _N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );
    Color = IIf( C >= Ref( C, -1 ), colorGreen, colorRed );
    PlotOHLC( Open, High, Low, Close, "", color, styleBar | ParamStyle( "Style" ) | GetPriceStyle() , Null, Null, 0, 0, 2 );
    Plot( MonthlyToDaily_MA, "Monthly MA", colorAqua, styleLine | styleThick );
    Plot( WeeklyToDaily_MA, "Weekly MA", colorBlue, styleLine );
    Plot( EMA( C, 20 ), "Daily MA", colorRed, styleLine );
    PlotShapes( Condition * shapecircle, colorlightblue, 0, H, 20 );

    _SECTION_END();
}

Which produces an exploration that looks like this,
image

Or a chart like this
image

4 Likes

True, but it's probably more so that other forum members can see that the person asking for help has at least made a effort at their end before asking for others to make an effort by provide their help.

3 Likes

Thanks, apologize for not acknowledgeing your solution earlier, more than I was aiming for, the charting section was more than I was trying to do.

My efforts were an absolute mess hence had not posted.

Been using Amibroker for nearly 3 years. My coding skills are nearly zero. When I have an idea, search the forum, read the manual and only after struggling over a few months do I lay my problem in this forum.

Once again thanks a lot.

regards.

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