Need help with Moving Average Indicator....

 
Could anyone make me a "Truncated" Moving Average Indicator for MT-4
(or simply provide the script). By "Truncated," I mean the moving
average lines would only extend back for about 15-20 bars, rather than
back to infinity. Other than that, it would just be a typical MA with
simple, exponential, and weighted options and an adjustable period.
There is already a Custom MA indicator over on the Yahoo site in the MT-4 indicator files
section. If there is just some simple adjustment to be made to the
code, I may be able to do it myself. If anyone can help, it would be
greatly appreciated.

Chris
 
It's not exactly elegant, but try the following in the Moving Averages indicator sample from MT.

look for
SetIndexDrawBegin(0,draw_begin);
and change it into
SetIndexDrawBegin(0, Bars-50);

(replace 50 with the number of bars you want to see).


If you're more daring and want it to be configurable as an input, look for

extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;

and add a new line there with

extern int MA_History=50;

and in the place mentioned above:
SetIndexDrawBegin(0, Bars-MA_History);


I haven't tried it (just typed it here), so no guarantees ;-) (Making a copy of the original version recommended)


Markus
 
Markus:

Thanks a lot.

I just tried it and it works great! I appreciate your help.


Regards,

Chris






It's not exactly elegant, but try the following in the Moving Averages indicator sample from MT.

look for
SetIndexDrawBegin(0,draw_begin);
and change it into
SetIndexDrawBegin(0, Bars-50);

(replace 50 with the number of bars you want to see).


If you're more daring and want it to be configurable as an input, look for

extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;

and add a new line there with

extern int MA_History=50;

and in the place mentioned above:
SetIndexDrawBegin(0, Bars-MA_History);


I haven't tried it (just typed it here), so no guarantees ;-) (Making a copy of the original version recommended)


Markus



 
You're welcome ... glad to have been of help


Markus
Reason: