MQL4 - automated forex trading   /  

Code Base

Read Financial Magazines in MetaTrader 4 and MetaTrader 5!

Code Base  Indicators  MA Candles Two Colors To post a new code, please log in or register

Download MetaTrader 5 and visit Code Base
and Trade on the Go!
and Trade on the Go!
Couldn't find the right code? Order it in the Jobs section

This library is for
MetaTrader 4
Download MT 4 - 455 Kb

and Trade on the Go!

and Trade on the Go!

MA Candles Two Colors
Author: file45 (2013.09.26 07:55)
Downloaded: 5181
 0 - MA Candles Two Colors.mq4 (3.6 Kb) View

MA Candles Two Colors : Also available for MT5

This Indicator draws different colored candles above and below a Moving Average (MA) line.

The Indicator includes all standard parameters of MA: Period, Shift, Method and Price.

The user is required to ensure that all Inputs Variables and Value parameters (MA Period, Shift, Method and Price) on both the present Indicator and the user provided Moving Average match each other exactly.

Use of this Indicator requires that Candlesticks, Price Bars or Price Line be graphically removed from the chart - see below instructions:

  1. Open a new chart.
  2. Change the chart price graphic to Line Chart - Press (Alt + 3) or locate 'Charts' on top menu and select 'Line Chart'. Make sure that 'Bar Chart' or 'Candlesticks' is not accidentally selected.
  3. Open the Chart Properties window - press (F8) or right click anywhere on the chart and select 'Properties'.
  4. Select the Colors tab.
  5. Select 'Line Chart:', now select the '▼' and change color to 'None'. The chart should now have no graphical price displayed and is referred to as the blank chart.
  6. A template of the blank chart can be made for further use with other currency pairs or instruments.
  7. Attach Indicator Color Candles cross MA to the blank chart.

The default parameters for MA1 are: Period = 1, Shift = 0, Method = 0 (SMA), Price = 0 (Close). This is the equivalent of having the color candles change color on price close above or below MA2.

The default method for MA2 is EMA.

Note: MA/s to be supplied by user and not part of Indicator.

Candle Accuracy: Although the standard chart price graphic is hidden it is not disabled and Open, High, Low and Close prices are available in MT4 Data Window (press Ctrl+D or View → Data Window). Accuracy of the Indicators Open, High, Low and Close can be checked against Open, High, Low and Close in MT4 Data Window. When cross-referencing the cursor point must be on the relevant colored candle:

Interpretation of the the Data Windows:

  1. The hidden candle Open: 1325.6
  2. The hidden candle High: 1326.6
  3. The hidden candle Low: 1321.5
  4. The hidden candle Close: 1323.1

The indicator candle H, L, O and C are listed in Columns R up, R dn, Bu and B dn (Red up candle, Red down, Blue uo candle, Blue down candle).

The hidden candle open is greater than the close so the candle is a down candle. The indicator Red down candle in column 2 corresponds to the hidden down candle.

  1. R dn L: 1321.5
  2. B dn H: 1326.6
  3. R dn C: 1323.1
  4. R dn O: 1325.6

All Inputs parameters and options can be changed and will save automatically. If after changing Inputs or Color parameters a Reset is used the Color Candles will display as Bars. To revert to Color Candles switch to a different timeframe and then back.

Input and Parameters
  • Candle _MA_Period - 34;
  • Candle_MA_ Shift - 0;
  • Candle_MA_Type - 1;
  • Candle_MA_Price - 0;
  • Candle_Shadow_Width - 1;
  • Candle_Body_Width - 4;
  • Type_Key - 0: SMA, 1: EMA, 2: SMMA, 3: LWMA;
  • Price_Key - 0: Close, 1: Open; 2: High;
  • Price_Key_cont - 3: Low, 4: Median;

1 comment  To post a new comment, please log in or register

Why keep re-setting a Scrip, Indicator or EA default parameter from, say, 34 to 50 ? Permanently change the default setting to 50 or make a copy with default 50 !

See HERE for instruction. It's dead easy ! - author: file45
09.01.2014 10:19 file45