MA’s on the side

by Dr.Hamdi Boukamcha
MA’s on the side
Author: bdeyes (2011.09.27 14:06)
Downloaded: 2519
MA's on the side   MA Segments.mq4 (37.7 Kb) View


Often times I find my chart is too cluttered with indicators to see the price action, however I still need those reference points.

My solution was to create an indicator which displays the current level of some of the MA’s off to the side of the current candle.

Works on all time-frames except Weekly and Monthly. Can show MA’s from other time-frames on current chart i.e. Daily 10 EMA on 15 min chart. The indicator is attached, change it as you like. The code is commented well enough that I hope making changes should be fairly self-explanatory. (I have seen enough posts on here to know that everyone will probably want a different MA added – feel free to make you own changes.)

NOTE: This is the “upgrade” version of the indicator I erroneously placed in the Forum under the same title. Adds ability to toggle MA’s on/off from the properties window and further internal commenting.


MA's on the side

4 comments  To post a new comment, please log in or register

Thank you so much,

great idea !! it ‘s very useful !!


23.10.2011 12:13 ludo31

Will come back to look at this one as it is along the lines of something I want to do, ie; I want to be able to display MAV values no matter what time frame I’m in – like show the daily200MAV and the 1hr200mav even if I’m in say the 5 min chart

Will come back t it as I’m searching for something else atm……..

12.10.2011 18:13 CanAm

good idee bad indicator
30.09.2011 17:05 wansiman

Man I love you guys.

I put in the original post that I didn’t want to make MA changes for you, cause there’s only like about a million different MA’s combinations in MetaTrader (I’m sure I’m going to hear about that – I’m know someone on here has probably actually counted).

The post has been up less than a day and I have already had 3 requests for different MA’s

Here’s how you change the MA’s – if you can type you can do this.

Open the mq4 file of the indicator in MetaEditor

Save the file under another name i.e. MA_Segments v2

Change the highlighted parts to match the MA you want to use. Replace the timeframe (PERIOD_D1) with one of these http://docs.mql4.com/constants/timeframes Replace the period (200) with whatever number you want. Replace the MA Method (MODE_SMA) with the one you want http://docs.mql4.com/constants/movings (Don’t mess up the commas)

Change the red part of the variables to match your MA using this format MA_Timeframe_Period_MA Method

Change the green object names the same as you did the variables above. Note that the line and the label each have a name. (Don’t mess up the double quotes)

Change the label text to match your MA.

Don’t forget to change your comments also.

Click on Compile.




PS: Now you’re a programer too!!!





The variables are at the top...

extern bool MA_D1_200_SMA = true; // set true to display

These are further down...

int deinit()


    // Daily 200 SMA line Change your comments too
    if (MA_D1_200_SMA) // draw if true
    // if there is an old line delete it...
    if (ObjectFind("D1_200_SMA") != -1) ObjectDelete("D1_200_SMA");
    // and draw a new one.
    ObjectCreate("D1_200_SMA", OBJ_TREND, 0, Time[0]+line_leader, iMA(NULL, PERIOD_D1,200,0,MODE_SMA,PRICE_CLOSE,0), (Time[0]+line_length+line_adjustment), iMA(NULL, PERIOD_D1,200,0,MODE_SMA,PRICE_CLOSE,0));
    ObjectSet("D1_200_SMA", OBJPROP_RAY, false);
    ObjectSet("D1_200_SMA", OBJPROP_TIME1, Time[0]+line_leader);
    ObjectSet("D1_200_SMA", OBJPROP_TIME2, (Time[0]+line_length+line_adjustment));
    ObjectSet("D1_200_SMA", OBJPROP_COLOR, Lime);

    // Daily 200 SMA text label Change your comments too
    if (MA_D1_200_SMA) // draw if true
    // if there is an old label delete it...
    if (ObjectFind("D1_200_SMA_label") != -1) ObjectDelete("D1_200_SMA_label");
    // and draw new one.
    ObjectCreate("D1_200_SMA_label", OBJ_TEXT, 0, (Time[0]+text_shift+text_adjustment), iMA(NULL, PERIOD_D1,200,0,MODE_SMA,PRICE_CLOSE,0));
    ObjectSet("D1_200_SMA_label", OBJPROP_TIME1, (Time[0]+text_shift+text_adjustment));
    ObjectSet("D1_200_SMA_label", OBJPROP_COLOR, Lime);
    ObjectSetText("D1_200_SMA_label", "D1 200 SMA", font_size, "Arial", Lime); 

Share this article

Leave a comment