Amps

Sunday, November 29, 2015

MT4 EA build procedure 1 MQL4 EA Structure

MT4 EA build procedure 1 MT4 EA Structure

MQL4 Property structure


//+------------------------------------------------------------------+
//|                                             test_bistechn_ea.mq4 |
//|                               Copyright 2015, BIS and Technology |
//|                                                 www.bistechn.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, BIS and Technology"
#property link      "www.bistechn.com"
#property version   "1.00"
#property strict

This part for declare the property owner of this EA or MQL4 code after Meta Editor complied this MT4 EA property would show in Metatrader program (MT4) part of Expert Advisors during we point this mouse to this EA.

Also this part used for declare public variable. (public variable would able used in any function in MT4 EA)

MT4 EA properties for setting basic parameter would declared in this part

MQL4 Initialization function


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  } 

The Initialization function part used for initialize EA instance Change the Time Frame Trading and etc.

MQL4 Expert deinitialization function


//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }

This part used for clean all draw line, arrow, which build by EA after not using

MQL4 Expert Start function 


//+------------------------------------------------------------------+
//| Expert Start function                                             |
//+------------------------------------------------------------------+
int start()
  {
//---
   
  }return (result);
//+------------------------------------------------------------------+

The MQL4 Expert Start Function used for create function what we want this EA working or trade instance open buy or sell and all of  activities we would like to do


Tuesday, September 29, 2015

Forex MT4 coding 2 variable Structure


MT4 variable structure

Look at MACD Sample code for example.


Properties show the code owner


Global variable

This part used for declare  global variable, which variable in this part would able to see and able to used by every function of code
(so these variable name in this part should be unique name)



Function variable

Variable in this part able to used in this part only unable to used by other function.




Forex MT4 EA coding Step1 Starting build The EA


First Step MT4 EA coding

Goto Menu Tools => Metaquotes Language Editors or F4
To access MetaEditor code Editors


Use MQL Wizard to tell what type of code we would build => Select Expert Advisor Template to build Expert Advisor


Input the name of MT4 EA, Author and Link (if have your web sites)


Select Function would like to build instance MT4 work under Timer, on ChartEvent and etc.


Saturday, September 26, 2015

How to Back Test MT4 Expert Advisor

Short cut Back Test MT4 Expert Advisor

Click on the Icon Expert Advisor Tester (Strategy Tester)


Tester windows would show


Click Expert Properties button to => Input the properties value



Select date time and range date want to test the MT4 expert advisor

  • Click on Start button to start testing
Click on Result this MT4 Tester would show the tester result



Click on Open Chart button would show the result chart






Attach MT4 indicators


Attach MT4 indicators and Save to the template

Select Indicator pasted into Chart


Example MT4 Moving Average Trend Indicators 10, 50, 200



Average Directional Movement Index with put Moving average to the ADX chart




Stochastic Oscillator and MACD and save template to use in next time and other currency pair photo show as below



First Setting up mt4 trading screen

MT4 Setting indicators and Template

MT4 Chart Setting

Right click on the Symbol currency pair we want to make a trading => Select Popup Chart Windows

Default chart would show in Time Frame H1 (60 minutes)
The time frame selection would found on small icon
  • m1 = 1 minute/candle
  • m5 = 5 minute/candle
  • m15 = 15 minute/candle
  • m30 = 30 minute/candle
  • H1 = 1 hours/candle
  • H4 = 4 hours/candle
  • D1 = 1 day/candle
  • W1 = 1 week/candle
  • MN= month/candle



Right click on the chart tick select chart style and colour of candles


On the Common page tick to Show Ask Line


After finish Setting screen would show like this