How to draw between 2 MAs

 

Hi all,

Anyone knows how can I change the color of the window between 2 MAs, 100 EMA and 200 EMA lets say. Basically I would like to create a more visual appealing representation of the time when price is between those 2 EMAs.

Thanks,

soso

 

Here is a visual representation of what I am looking for. Please observe the shadows on the map: http://www.czirnich.de/Blog/Globetrader_97.png .

 
soso_beton:
Hi all,

Anyone knows how can I change the color of the window between 2 MAs, 100 EMA and 200 EMA lets say. Basically I would like to create a more visual appealing representation of the time when price is between those 2 EMAs.

Thanks,

soso

Hi,

You can receive a similar picture only with use of the histogram as in Ichimoku.

Igor

 

Hi,

Firstly you will need an indicator that draws both moving averages.These are around if you look for one. Possibly on Strategybuilderfx forum, something like the ACD4. indicator which uses multiple moving averages.

Then write into the code under 'drawing settings';

SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,5);

SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,5);

You could try just writing 'histogram' or 'dot' if you prefer.

Then set your colours and lengths of moving average and you will have the coloured areas you want.

I hope that helps you.

Napeharm

 

Hi Napeharm,

Thanks, indeed I have tried like this and it works. But there is a problem, when 100 EMA goes bellow 200 EMA then the histogram is not drawn anymore. And I have no idea why .

Here's the attached indicator code maybe you have a little time to take a look.

Thanks,

soso

Files:
 

Hi,

You could be a little ambitious with your indicator. You are using three moving averages and that is why it doesnt appear to work. I never managed to code any indicator which had more than two lines, ie; like a bollinger which has a centreline, it never seemed to work.I am not an expert at coding and never got around this issue and so stuck to simple indicators using just two moving averages.Surely this is all that you need anyhow to make the coloured areas?...........

Napeharm

 

It seems that not the number of buffer is the problem...But how DRAW_HISTOGRAM is handled when the indicator is in the same window as the chart. Unfortunately didn't find any clear explanation.

Is there any other MQL tutorial besides the one from this site?

soso

 

Hi,

I removed the reference to the third moving average in your code and it works fine.Just choose which two moving averages you most want to use and take out the other.Works perfectly with just two.

Napeharm

 

Puzzle solved, it seems it mattered the order of arrays.

Thanks everyone,

soso

 

Here's a couple of indicators for anyone that is interested:

MA_Cloud.mq4 - Input your 2 MAs. You can choose your MA type (Default is EMA) and what price to use (Default is Close). - You MUST go into your chart Properties --> Common and check 'Chart on Foreground'.

MA_Cloud-dots.mq4 - Same as above indicator except that you don'tneed to put your prices on the foreground. Not as visually pleasing.

Keris

Files:
 

OOh thanks so much! Chart on foreground does it indeed