EnglishFrenchGermanSpainItalianDutchRussianPortugueseJapaneseKoreanArabicChinese Simplified

Showing posts with label MQL4. Show all posts
Showing posts with label MQL4. Show all posts

Part II : EA Example

The first discussion, is the EA (after EA, and then we'll discuss a custom indicators and scripts).

To start making EA, after entering MetaEditor, select File -> New -> select Expert Advisor and then enter the Copyright and Link

then you'll get a code like this:


Code:

//+------------------------------------------------------------------+
//| EAIIExample.mq4 |
//| Copyright © 2010, eTrader |
//| http://erlandhy.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, eTrader"
#property link "http://erlandhy.blogspot.com"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+


Little explanation,

which in the init () run 1x when EA first time in drag to the charts
which in deinit () is run when the EA in 1x remove from the chart, or chart closed
which at the start () is run every tick (every no new price)

nah, look at the following EA's super simple:


Code:

//+------------------------------------------------------------------+
//| EAIIExample.mq4 |
//| Copyright © 2010, eTrader |
//| http://erlandhy.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, eTrader"
#property link "http://erlandhy.blogspot.com"

extern double Lots=0.1;
extern int SL=100;
extern int TP=150;
extern string txtComment="eTrader";
extern int MagicNumber=12345;
extern int Slippage=5;


//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (OrdersTotal()==0)
{
if (iClose(Symbol(),0,1) > iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,1) )
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-SL*Point,Ask+TP*Point,txtComment,MagicNumber);
}
else if (iClose(Symbol(),0,1) < iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,1) )
{ OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+SL*Point,Bid-TP*Point,txtComment,MagicNumber); } }
//---- return(0);
}
//+------------------------------------------------------------------+

The logic of this EA, i think (eg EA was placed on the chart GBPUSD 1 Hour), If no position, if the candle hours ago closenya above the EMA 10, then buy, if the candle hours ago closenya below the EMA 10, then sell.



I think like this is ...... buy on the open candle that i love arrows (because the previous candle closed above EMA) at 1.7366 and close at 1.7516 (150 pips TP) ...
hum, i forgot calculate spreads its supposed to get buy-in price was 1.7369 and at 1.7519 TPyes but the point is so i thik


let's examine one by one part ..... explanation on this topic briefly  ... details will be explained in each part.


Code:
extern double Lots=0.1;
extern int SL=50;
extern int TP =100;
extern string txtComment="eTrader";
extern int MagicNumber=12345;
extern int Slippage=5; 
 More details Click This 

Read More....

Part I : MQL4 Introduction

Make Money While You Sleep - Advanced Forex Auto Trading Robot - Metatrader MT4 EA - Expert AdvisorMQL4 programming language is contained in the MetaTrader 4 platform. MQL4 is most commonly used to create Expert Advisor (EA), Custom Indicators and Scripts. Expert Advisor / EA, as we already know, is a program to automate your trading based paramater2 logika2 and certain.  

Custom Indicators, almost the same as EA, just could not make trades. And can use function2 indicator. Script, just like EA, only be made only 1x when the script is executed. To create a program / script with MQL 4, the way is easy, just run enough MetaEditor. 

Elite Expert Trader Forex PortfolioThis MQL4 its structure and syntax similar to C / C + +. So if you've habit with C / C + +, should ga will have difficulty making the MQL4 program. The difficulty might be when debugging ..Further, MQL4 can interconnect with a DLL file. This allows programming of more complex and complicated, and of course, it's possible to be infiltrated spyware / virus by EA makers (especially those that use the DLL).
 

Read More....

MQL4 Learning

Expert Advisor Programming: Creating Automated Trading Systems in MQL for MetaTrader 4In addition to testing and review expert advisor (EA), Forexindo also provides articles about MQL4. Starting from the introduction of MQL4, how to design and construct EA, until later how to backtest and optimization EA.

Tutorial on making basic functions EA has finished writing. While the tutorials on the functions that are more advanced will be available in some future time.



Currently, MQL4 tutorial consists of 8 sections:


  1. Introduction: discuss about MQL4 and usefulness.
  2. Examples of EA's simple: for example, discusses its Expert Advisor
  3. Syntax and The Basics: to discuss and comment variables.
  4. Data Type: MQL4 discuss data types in its examples.
  5. Operators and Expressions: discusses operators and expressions in MQL4 and examples.
  6. Decision and loops: discuss the use of branching and looping to regulate flow of the EA program.
  7. Order and Technical Analysis: EA to discuss how to create order and to use technical indicators.
  8. Arrange EA: EA discusses how to prepare. It is expected that the reader can make a simple EA
  9. Use of iCustom: EA to discuss how to craft a custom database entry based on the indicators.
  10. Money Management: discuss money management system in the EA

If there is a poorly understood, you can ask questions by way of know-Command on the topic concerned.

Read More....