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

#1
How to plot 200 DMA on a lower TF like 5 min/15min etc? i.e. chart is lower TF but a bigger TF MA is plotted?
Is there any AFL there? Please post it. Or anyother way to do it. Thanks in advance!
 

jahan

Well-Known Member
#2
How to plot 200 DMA on a lower TF like 5 min/15min etc? i.e. chart is lower TF but a bigger TF MA is plotted?
Is there any AFL there? Please post it. Or anyother way to do it. Thanks in advance!
hello,

take a look i think this is wat ur looking.
///***
TimeFrameSet( in5Minute ); // switch to 5 minute frame

/* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */

ma5_13 = MA( C, 13 );

TimeFrameRestore(); // restore time frame to original

TimeFrameSet( inHourly ); // switch now to hourly

mah_200 = MA( C, 200 ); // 200 bar moving average from hourly data

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( ma5_13, in5Minute), "13 bar moving average from 5 min bars", colorBlue );
Plot( TimeFrameExpand( mah_200, inHourly), "9 bar moving average from hourly bars", colorRed );

////////*****
regards,
jahan
 
#3
no this is nt wt i want.
thks anyways!

hello,

take a look i think this is wat ur looking.
///***
TimeFrameSet( in5Minute ); // switch to 5 minute frame

/* MA now operates on 5 minute data, ma5_13 holds time-compressed 13 bar MA of 5min bars */

ma5_13 = MA( C, 13 );

TimeFrameRestore(); // restore time frame to original

TimeFrameSet( inHourly ); // switch now to hourly

mah_200 = MA( C, 200 ); // 200 bar moving average from hourly data

TimeFrameRestore(); // restore time frame to original

Plot( Close, "Price", colorWhite, styleCandle );

// plot expanded average

Plot( TimeFrameExpand( ma5_13, in5Minute), "13 bar moving average from 5 min bars", colorBlue );
Plot( TimeFrameExpand( mah_200, inHourly), "9 bar moving average from hourly bars", colorRed );

////////*****
regards,
jahan
 
#4
tradepunt

please try the following

_SECTION_BEGIN("MTF MA");
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64);
PP = 0;
WDH = ParamList("TF", "Hourly,Daily,Weekly" );
if( WDH == "Daily" ) PP= inDaily;
if( WDH == "Weekly" ) PP= inWeekly;
if( WDH == "Hourly" ) PP= inHourly;
TimeFrameSet(PP);
P=ParamField("Price");
Per=Param("MA Period",20,1,200,1);
x=MA(P,Per);
TimeFrameRestore();
aa=TimeFrameExpand(x,PP);
Plot(aa,"",colorBlue,styleThick);
_SECTION_END();

Vidyasagar
 
#5
thks vidya sagar - this is not the exact one but somewhat i need (close to it). you hv really helped a beginner in coding an afl!

still few problems:

  1. on lower TF, it doesnt plot 200 MA of daily TF for any underlying.
  2. if i want to use 3 MAs of Daily TF on 15 min chart - for e.g. 200, 100, 50, i cant! even if i drag & drop on the price chart, it takes the parameter of the 1st drag n drop indicator. tis means even if i drag n drop 3 times, it will plot only one MA!!
  3. also, by default it takes SMA (MA method) & close (price type). there are no options for different MA method & price types. pls add them if possible!

pls reply if anything still unclear. i hope i have not asked for more. pls help me getting this thing done as in when you get time. i am not in hurry! so nice of you. thanks a ton in adv. i have attached the code for the metatrader mql related to this - http://img402.imageshack.us/img402/6985/mtf.pdf


if possible can u add sound & pop up alert in RMO code http://www.traderji.com/amibroker/77518-pls-add-sound-pop-up-alert-rmo-code.html

tradepunt

please try the following

_SECTION_BEGIN("MTF MA");
SetChartOptions(2,chartShowDates);
GraphXSpace=5;
Plot(C,"",1,64);
PP = 0;
WDH = ParamList("TF", "Hourly,Daily,Weekly" );
if( WDH == "Daily" ) PP= inDaily;
if( WDH == "Weekly" ) PP= inWeekly;
if( WDH == "Hourly" ) PP= inHourly;
TimeFrameSet(PP);
P=ParamField("Price");
Per=Param("MA Period",20,1,200,1);
x=MA(P,Per);
TimeFrameRestore();
aa=TimeFrameExpand(x,PP);
Plot(aa,"",colorBlue,styleThick);
_SECTION_END();

Vidyasagar
 
Last edited:

KelvinHand

Well-Known Member
#6
thks vidya sagar - this is not the exact one but somewhat i need (close to it). you hv really helped a beginner in coding an afl!

still few problems:

  1. on lower TF, it doesnt plot 200 MA of daily TF for any underlying.
  2. if i want to use 3 MAs of Daily TF on 15 min chart - for e.g. 200, 100, 50, i cant! even if i drag & drop on the price chart, it takes the parameter of the 1st drag n drop indicator. tis means even if i drag n drop 3 times, it will plot only one MA!!
  3. also, by default it takes SMA (MA method) & close (price type). there are no options for different MA method & price types. pls add them if possible!

pls reply if anything still unclear. i hope i have not asked for more. pls help me getting this thing done as in when you get time. i am not in hurry! so nice of you. thanks a ton in adv. i have attached the code for the metatrader mql related to this - http://img402.imageshack.us/img402/6985/mtf.pdf


if possible can u add sound & pop up alert in RMO code http://www.traderji.com/amibroker/77518-pls-add-sound-pop-up-alert-rmo-code.html

To display Daily 200MA onto your M15 chart, Had you check the requirement number of bars in 15M to do that ?
Min. required 19.2K of bars in order to display out.
I think not the code issue, is your bar setting issue.
Print your BarCount and take a look.
 
Last edited:
#7
no kelvin - tht is not the issue! i hv required set of bars!
infact 200DMA is not getting plotted even on 4H TF!
some code issue is still there!

To display Daily 200MA onto your M15 chart, Had you check the requirement number of bars in 15M to do that ?
Min. required 19.2K of bars in order to display out.
I think not the code issue, is your bar setting issue.
Print your BarCount and take a look.
 

KelvinHand

Well-Known Member
#8
no kelvin - tht is not the issue! i hv required set of bars!
infact 200DMA is not getting plotted even on 4H TF!
some code issue is still there!

MT4 different timeframe using independent data. such as they created and update different timeframe historical data. So when script caculation on that timeframe, it is possible to extract that timeframe of data and do calculation.


For amibroker, likely it worked on base timeframe:

The code work in EOD data on Daily, Weekly and Monthly. The reason is
the base time is inDaily.

I tested importing forex data from H1 (base time), it work ok with the code and display DailyMA200 on 4H

If you are using Live Data from broker, and if i assume your base time is 1min, you may not see DailyMA200 on 4H.

I tested with importing 1min as based time, and it really cannot.
On M15, it can only display DailyMA 1 to 25 period only.

Amibroker is very easy to program, no need to concern about MT4 timeframe compress/expansion scripts. They simplify by the Timeframe Setting command to replace all the hardwork in MT4.

If the code can work on EOD, It is most likely will work on Intraday. Because the same formula applied through out.

Other then that, any limitation on your broker provide data, such as maximum bars allowed, whether they create all timeframe historical data, i m not sure.
 
Last edited:
#9
inshort wht is the solution as i use 1min based charts for different TF?
OR any other AFL?

If you are using Live Data from broker, and if i assume your base time is 1min, you may not see DailyMA200 on 4H.

I tested with importing 1min as based time, and it really cannot.
On M15, it can only display DailyMA 1 to 25 period only.
 

KelvinHand

Well-Known Member
#10
inshort wht is the solution as i use 1min based charts for different TF?
OR any other AFL?
No Eye Deer.
- See any other expert who use live data in amibroker, know better then me, can help you.
- May be there are ways that the setting on the amibroker we don't know, see any purchased user can ask the amibroker for help.
- Ask your data provider, there may be had solution
- Don't use Amibroker.
 
Last edited:

Similar threads