A little help with Moving Average coding.........

#1
A little help needed guys.................I want the value of 15 period Moving Average in Daily Timeframe to be displayed on the chart...........so technically I want this value to be always displayed on the chart even If I am using the chart in 1min, 5mins, 15mins etc .
for example if the 15period MA value of a scrip in Daily Timeframe is "100", I want this "100" value displayed somewhere on the screen when I am watching the chart on 5mins , 10mins , 15mins , etc timeframe..................
If anyone can post the code it would be of great help........thanks
 

siddhant4u

Well-Unknown Member
#2
try this

this will plot a line, idea is to set TimeFrameSet to your fixed timeframe and get the moving avg.


Code:
TimeFrameSet( inDaily ); // switch now to hourly

mah_15 = EMA( C, 15 ); // 9 bar moving average from hourly data

TimeFrameRestore(); // restore time frame to original

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

// plot expanded average

Plot( TimeFrameExpand( mah_15, inDaily), "15 bar moving average from hourly bars", colorRed );
 
#3
try this

this will plot a line, idea is to set TimeFrameSet to your fixed timeframe and get the moving avg.


Code:
TimeFrameSet( inDaily ); // switch now to hourly

mah_15 = EMA( C, 15 ); // 9 bar moving average from hourly data

TimeFrameRestore(); // restore time frame to original

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

// plot expanded average

Plot( TimeFrameExpand( mah_15, inDaily), "15 bar moving average from hourly bars", colorRed );

hey brother ......thanks for the help.......can u please do the same for this below posted indicator........I've tried but could not

_SECTION_BEGIN("");
Plot(100,"",colorBlack,styleDashed);
Plot(-100,"",colorBlack,styleDashed);
n=18;
n= Param ( "Periods", 9, 1, 200, 1 );
ys1=(High+Low+Close*2)/4;
rk3=EMA(ys1,n);
rk4=StDev(ys1,n);
rk5=(ys1-rk3)*100/rk4;
rk6=EMA(rk5,n);
UP=EMA(rk6,n);
DOWN=EMA(up,n);
Oo=IIf(up<down,up,down);
Hh=Oo;
Ll=IIf(up<down,down,up);
Cc=Ll;
barcolor2=IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1),colorBlue,IIf(up>down,colorGreen,colorRed));
PlotOHLC(Oo,hh,ll,Cc, "" + Name(), barcolor2, ParamStyle ("Style") );
Plot(1,"ribbon",IIf(Ref(oo,-1)<Oo AND Cc<Ref(Cc,-1), colorBlue, IIf( up>down, colorLime, IIf( down>up, colorRed, colorBlue ))),styleOwnScale|styleArea|styleNoLabel, -01, 50 );
_SECTION_END();
 

Similar threads