Codes

MA-ATR for MetaTrader 4

This indicator combines Moving Average (MA) and Average True Range (ATR)

Donchian Channel Indicator for MetaTrader 4

This indicator draws three Donchian bands: up, middle and down bands based on which you can design your scalping system

H3, H6, H8 and H12 Candle Sticks Indicator for MetaTrader 4

This indicator adds H3, H6, H8 and H12 time frames into your charts

Forum

Decimal to Binary

Is there a function in MQL4 that converts a decimal value into its binary representation (for example, in string format of 0's and 1's)

Is multiple inheritance allowed in mql4?

I am writing a library in mql4 language in which I would like to have multiple inheritance. I use the following format: class A { // some variables and functions }; class B { // some variables and functions } class C : public A, public B { // some variable and functions }; But at compile time

How to test a market indicator in MT4?

I have noticed recently that the indicators (of MT4 in the market) can be demo tested in the strategy tester . I downloaded the latest MT4 (build 765) from metatrader4.com. However, I do not see any change in the strategy tester similar to what MT5 lets users to test the indicators. Does anybody

Label Object font size is larger than it must be!

I created a test indicator which draws a Label Object with "Arial" font name and a font size of 10. I tested the same code on four different computer/Windows 7s. The strange thing is that the size of the text of the label on one of the computers is (much) larger than the rest (the text looks the

OrderCommission() must be subtracted?

In order to calculate the total profit/loss of an open position, which one of the following equations is correct? double pl = OrderProfit()+OrderCommission()+OrderSwap(); or double pl = OrderProfit()-OrderCommission()+OrderSwap();

How to get the bar number/time from OnChartEvent()?

In an Expert Advisor code, I would like to know on which bar of a chart the user clicked. From the example and documentation of OnChartEvent() function, a left click of mouse can be captured as a position (x, y). Is there a way to get the bar time/number on which the user left clicked

How to read value of an indicator attached to a chart from EA code?

I would like to know how I can read the value in the buffer of an indicator attached to a chart from my EA code? Please note that I do not want to use iCustom function. I want to use, for example, ChartIndicatorsTotal() and ChartIndicatorName(), to access to the buffer of an attached indicator to

ATR formula used in MT4 indicator is not original

I was studying Average True Range indicator that I realized the calculation used in standard MT4 indicator is different than original formula. The calculation of ATR in MT4 is based on following formula: ATR[i] = ATR[i-1] + ( TR[i] - TR[i-n] ) / n; // n is the ATR period But the original formula as

Why this example code from MQL4 reference does not compile?

Hi there, I have installed MT4 Build 646 on my computer. The attached code has been taken from MQL4 help file. The strange thing is that, if you try to compile it with MetaEditor (version: 5.00 build 934 that comes with MT4), the compile will fail with the following error: 'indicator_type1' -