Skip to main content

Unlock the secrets of stock price forecasting through Multi Timeframe analysis. This technique helps you peek into higher timeframe charts while trading on lower timeframes. The beauty of this method is that it drastically reduces false signals, although it trims down the number of signals. Typically, the support and resistance levels on higher time frames are more solid than the lower ones, and trends tend to stick around longer on higher time frames. That’s why it’s key to cross-check your signals on lower time frames with those on higher time frames. In this post, we’ll unravel a straightforward multi timeframe trading strategy that uses weekly charts to confirm the trend while trading on a daily timeframe. Plus, we’ll delve into an Amibroker exploration AFL for this strategy.

Tap Here to dive into AFL coding and build your own trading systems.

A Glimpse Into The Strategy

ParameterValue
Preferred Time-frame
Daily
Indicators UsedEMA,ADX
Buy Condition
  • Fast EMA crosses over slow EMA on Daily TF
  • ADX is above 30 on Weekly TF (for confirming the trend)
Short Condition
  • Fast EMA crosses below slow EMA on Daily TF
  • ADX is above 30 on Weekly TF (for confirming the trend)
Sell ConditionSame as Short
Cover ConditionSame as Buy

Uncovering The AFL Code

				
					//------------------------------------------------------
//
//  Formula Name:    Multi Timeframe Exploration
//  Website:         https://zerobrokerageclub.com/
//------------------------------------------------------

_SECTION_BEGIN("Multi Timeframe Exploration");

SetBarsRequired( sbrAll );
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));

Plot( Close, "Price",colorWhite, styleCandle );
FastEMA = Param("FastEMA",18,3,21,3);
SlowEMA = Param("SlowEMA",35,20,50,5);
ADXParam=Param("ADXParam",14,5,5,30);

/* switch to weekly time frame */
TimeFrameSet( inWeekly );
wADX = ADX(ADXParam);
TimeFrameRestore();

/* expand calculated MACD to daily so we can use it with daily signals */
wADX = TimeFrameExpand( wADX, inWeekly );


FastEMADaily = EMA(C,FastEMA);
SlowEMADaily = EMA(C,SlowEMA);
BuyDaily = Cross(FastEMADaily,SlowEMADaily);
ShortDaily = Cross(SlowEMADaily,FastEMADaily);

Buy = BuyDaily AND wADX>30;

Short = ShortDaily AND wADX>30;

Sell=Short;
Cover=Buy; 

Trade_Signal = WriteIf( Buy, "Buy", "Short" );

Filter = Buy OR Short;

AddColumn(C,"Close",1.2,IIf(C>Ref(C,-1),colorGreen,colorRed));
AddColumn(wADX,"Weekly ADX");
AddColumn(FastEMADaily,"Fast EMA");
AddColumn(SlowEMADaily,"Slow EMA");
AddTextColumn(Trade_Signal,"Trade_Signal",1,fgcolor = colorDefault, bkcolor=IIf(Buy,colorGreen,colorRed));


_SECTION_END();
				
			

Setting The Code In Motion

Step 1: Kickstart Amibroker, hit File–>New–>Formula, and paste the exploration code provided.

Step 2: Hit File–>New–>Analysis. Set the time frame to Daily.

Step 3: In the ‘Apply to’ dropdown, choose ‘All symbols’. In the range dropdown, pick ‘From- To dates’. And for both dates, select today’s date.

Multi-Timeframe-Trading-StartegyStep 4: Hit the Explore Button. You’ll unveil a list of stocks that fit the strategy rules. Check out the ‘Trade_Signal’ column for Buy or Short signals. The listed symbols are your hot picks for the next day.

Multi-Timeframe-Trading-Startegy-ResultsStep 5: Fancy narrowing down the exploration? Run it on a subset of stocks by picking the Filter option on ‘Apply To’ dropdown.

Note: These steps presume you’ve already loaded the EOD stock prices in Amibroker.

Also Read: Spotting Trending Stocks with Amibroker AFL

Diving Deeper Into The Code

Essentially, the code performs two actions:

  1. Calculates the ADX value on a Weekly timeframe
  2. Works out Fast and Slow EMA values on a Daily timeframe

When the ADX sails above 30 on the weekly timeframe and the Fast EMA crosses over the slow EMA on the daily timeframe, a Buy signal springs up. A Short signal emerges when the ADX sails above 30 on the weekly timeframe and the Fast EMA crosses below the slow EMA on the daily timeframe. The ADX values serve as a handy backup for confirming the trade by peeking at a higher timeframe.

Let’s breakdown some of the key multi timeframe-related functions used in the initial part of the code:

TimeFrameSet( inWeekly ): This flicks the current timeframe to Weekly from Daily.

TimeFrameRestore(): This rolls the timeframe back to Daily.

TimeFrameExpand( wADX, inWeekly ): This spreads the time-compressed array wADX from weekly timeframe to daily timeframe.

One Comment

Leave a Reply