Amps

Saturday, December 12, 2015

Forex MQL4 EA Properties code 2

External variable or Extern Variable MQL4

From Last Chapter

Extern ones also determine the input parameters of an mql4 EA
They are available from the Properties window
Extern variables can be modified in the Properties window and MQL4 Program

This chapter we would talk about how to coding EA properties

Learn to know Moving Average Indicators




Learn to know Moving Average Functions

Function Name
double iMA
Function Parameter
Function Value Function Value Name Function Meaning
symbol NULL
ENUM_TIMEFRAMES

0 PERIOD_CURRENT
1 PERIOD_M1
5 PERIOD_M5
15 PERIOD_M15
30 PERIOD_M30
60 PERIOD_H1
240 PERIOD_H4
1440 PERIOD_D1
10080 PERIOD_W1
43200 PERIOD_MN1
ma_period Averaging period for calculation
MA shift Indicators line offset relate to the chart by timeframe
ENUM_MA_METHOD

0 MODE_SMA
1 MODE_EMA
2 MODE_SMMA
3 MODE_LWMA
ENUM_APPLIED_PRICE

applied_price 0 PRICE_CLOSE Close price
applied_price 1 PRICE_OPEN Open price
applied_price 2 PRICE_HIGH The maximum price for the period
applied_price 3 PRICE_LOW The minimum price for the period
applied_price 4 PRICE_MEDIAN Median price, (high + low)/2
applied_price 5 PRICE_TYPICAL Typical price, (high + low + close)/3
applied_price 6 PRICE_WEIGHTED Weighted close price, (high + low + close + close)/4
shift
Current candle is 0 (candle 1-N is count back from current candle)

iMA Function Moving Average from MetaQuotes Example

iMA Function Moving Average in MetaQuotes EA or Expert Advisor Examples have 2 lines use iMA function 

that's

ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);

This we would learning how to build EA properties for this function

Basic variable Data Type

Every Vaiable should contain and specific data type as below
int (integers)
double (real numbers)
bool (Boolean values, that is logical values)
string (values of string type)
color (values of color type)
datetime (values of date and time)

Extern MQL4 Variable Group

1. Input Value directly (Like input to Edit Box) to the MQL4 EA properties
2. Input Value pass Boolean drop down list to the MQL4 EA properties
3. Input Value pass EA Methode Function


Time to change the properties of MetaQuotes EA or Expert Advisor Examples code

Function from original code
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);

This we would add 3 lines to select Time Frame, Moving Everage and Apply Price, so add code as below to EA properties 



Input Enum Variable to the Moving Average Function to the MQL4 code

We have 3 enum variable now

TimeFrameUsed
EMA_method1
Applied_Price1

from original iMA function in the code
ma=iMA(NULL,0,MovingPeriod,MovingShift,MODE_SMA,PRICE_CLOSE,0);

Change to
ma=iMA(NULL,TimeFrameUsed,MovingPeriod,MovingShift,EMA_method1,Applied_Price1,0);


Test Run Moving Average EA on youtube


No comments:

Post a Comment