How to plot higher TF MA in lower TF in Amibroker?

#21
I used the MTF MA AFL provided here in this thread but I am getting wrong values of the MA's through this AFL when I compare the values of the MA's calculated as per the normal procedure.

Can some TJ member provide another AFL where it is possible to see the higher time frame MA on a lower time frame data. eg. 60 minute SMA on a 5 minute chart.

Thanks in Advance.
 
#22
I used the MTF MA AFL provided here in this thread but I am getting wrong values of the MA's through this AFL when I compare the values of the MA's calculated as per the normal procedure.

Can some TJ member provide another AFL where it is possible to see the higher time frame MA on a lower time frame data. eg. 60 minute SMA on a 5 minute chart.

Thanks in Advance.

apply this AFL on 5 minute chart

TimeFrameSet( inhourly);
a = MA( C,21);
TimeFrameRestore();

Plot( TimeFrameExpand( a, inhourly), "a", colorGold,styleLine );


hope this will help u ......


regards
AnAtheist:)
 

xsis

Active Member
#24
this is nt working!
wen i try 21period hourly on any TF less than hourly or if i change the afl to 21period daily and plot it on any TF less than daily!
nt wrkin in any ocndition!

the value mismatches!

apply this AFL on 5 minute chart

TimeFrameSet( inhourly);
a = MA( C,21);
TimeFrameRestore();

Plot( TimeFrameExpand( a, inhourly), "a", colorGold,styleLine );


hope this will help u ......


regards
AnAtheist:)
 

KelvinHand

Well-Known Member
#26
this is nt working!
wen i try 21period hourly on any TF less than hourly or if i change the afl to 21period daily and plot it on any TF less than daily!
nt wrkin in any ocndition!

the value mismatches!
Try this test code.
PHP:
_SECTION_BEGIN ("Test HTF");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot( C, "Close", colorDefault, styleBar); 

MA_Period = Param("MA Period", 21,1);
iInterval = Param("Interval", 1);


switch(ParamList("High TF", "Hour|Day|Week|Month"))
{
  case "Month":  iTf = inMonthly; break;
  case "Week":  iTf = inWeekly; break;
  case "Day":  iTf = inDaily; break;
  default: iTf = inHourly; break;

}


iPeriod = iInterval*iTF;

TimeFrameSet(iPeriod);
MA1 = MA( C,MA_Period);
TimeFrameRestore();


str = "(C,"+MA_Period+")";
Plot( TimeFrameExpand( MA1, iPeriod), "MA1"+str, colorYellow,styleNoLabel);


MA2= MA(C,MA_Period*iPeriod/Interval());


Plot( MA2, "MA2"+str, colorRed, styleNoLabel|styleThick);

Title=Title+"\nBarCount = "+BarCount;

_SECTION_END();
 

xsis

Active Member
#27
hey kelvin - it is also not correct!
btw i found the correct one here
thks anyways!

Try this test code.
PHP:
_SECTION_BEGIN ("Test HTF");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot( C, "Close", colorDefault, styleBar); 

MA_Period = Param("MA Period", 21,1);
iInterval = Param("Interval", 1);


switch(ParamList("High TF", "Hour|Day|Week|Month"))
{
  case "Month":  iTf = inMonthly; break;
  case "Week":  iTf = inWeekly; break;
  case "Day":  iTf = inDaily; break;
  default: iTf = inHourly; break;

}


iPeriod = iInterval*iTF;

TimeFrameSet(iPeriod);
MA1 = MA( C,MA_Period);
TimeFrameRestore();


str = "(C,"+MA_Period+")";
Plot( TimeFrameExpand( MA1, iPeriod), "MA1"+str, colorYellow,styleNoLabel);


MA2= MA(C,MA_Period*iPeriod/Interval());


Plot( MA2, "MA2"+str, colorRed, styleNoLabel|styleThick);

Title=Title+"\nBarCount = "+BarCount;

_SECTION_END();
 

manojborle

Well-Known Member
#30
PHP:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_BEGIN("EMA 5 MIN");
TimeFrameSet(in5Minute);
m5= EMA(Close,20) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorBlue ), ParamStyle("Style", styleDashed));
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
TimeFrameSet(in15Minute);
m15= EMA(Close,20) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorGrey50 ), ParamStyle("Style", styleDashed));
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("EMA 60 MIN");
TimeFrameSet(60*in1Minute);
m60= EMA(Close,20) ;
Plot(TimeFrameExpand(m60, 60*in1Minute), "", ParamColor( "60 Min Color", colorLightGrey ), ParamStyle("Style", styleDashed));
TimeFrameRestore();
_SECTION_END();

_SECTION_BEGIN("Bar Count");
iBars = ParamToggle("BarCount","No|Yes",1);
if (iBars) 
iBars = BarsSince( Day() != Ref( Day(), -1 ) );
for ( i = BarCount - ( LastValue( iBars ) + 0 ); i < BarCount; i=i+3 )
{
    j[i] = abs( ( LastValue( BarCount ) - 2 * i - ( LastValue( iBars - i ) ) - 2 ) );
    PlotText( NumToStr( j[i], 1 ), i, L[i] - L[i]*0.003, colorBlack );
}
Could someone please help me building AFL of 15 min & 60 min 20 EMA on 5 min chart. I have attached the screenshot for reference
http://imgur.com/a/NCTP0
 

Similar threads