Centred moving average ELA code help..

jsd

Active member
Messages
232
Likes
3
Hi, i am trouble trying to plot a mathematically correct centred moving average using ELA easy language code for use in supercharts. A typical MA will lag half the period . what i need is ELA code that will plot say a 15 bar ma 7 bars back , the peaks and troughs then will be correctly aligned up to date. any ideas ?

jd
 
regarding code

jsd said:
Hi, i am trouble trying to plot a mathematically correct centred moving average using ELA easy language code for use in supercharts. A typical MA will lag half the period . what i need is ELA code that will plot say a 15 bar ma 7 bars back , the peaks and troughs then will be correctly aligned up to date. any ideas ?

jd
did you evr end up a codethat works with moving average :!:
 
Maybe I do not fully understand question but can you not just use

Plot1[7] (Average(Price,15) , "MA 7-day displaced");
 
hmm still having trouble easy to do on paper, but supercharts keeps rejecting it....

ok so you can see what i am attempting to do in supercharts i'll plot the following..

1) 25
2) 28
3) 29 29.6 **
4) 32
5) 34

total of 5 data = 148 divide by 5 = **29.6 this 29.6 needs to be plotted 3 bars back , a typical MA will plot it at data point 5 not data bar 3

Maybe it is simple, but I havent worked it out so it shifts the average price back...

jsd.
 
After the "plot" command you should be able to put the number of bars displacement in [ ] brackets. At least this is how it works in EL for Tradestation. Maybe try ( ) brackets if [ ] doesn't work.

Plot1[7] (Average(Close,15) , "MA 7-day displaced");
 
Inputs: Price(Close), Length(9), Displace(0);

If Displace >= 0 OR CurrentBar > AbsValue(Displace) Then Begin
Plot1[Displace](AverageFC(Price, Length), "SimpAvg1");

{Alert Criteria}
IF Price < Plot1 AND Plot1 < Plot1[1] AND Plot1[1] > Plot1[2] Then
Alert("The Moving Average has just changed direction and is now bullish")
Else
If Price > Plot1 AND Plot1 > Plot1[1] AND Plot1[1] < Plot1[2] Then
Alert("The Moving Average has just changed direction and is now bearish");

{Moving Average Commentary}
#BeginCmtry
Commentary(ExpertAvg1Line(Price, Length, Displace, Plot1));
#End;
End;
 
ok thanks for that twalker, i'll have a tinker with it this afternoon..

jsd.
 
hmm ok it says "multiple statement formulas are not supported in quick editor, use trade stations power editor..." ive had me chips i think ,unless theres another way to write it in basic easy language, or import via an ELA file. I can transfer in from a .ELA file, could i paste your coding and save as a ELA extension or something? ive transfered in indicators of the web a few years back just a bit rusty with it of late...

jsd.
 
Sorry to say I do not know the answer to this. I have always used TS power editor.
 
Top