JegForex - Solusi Tepat Untuk Investasi
Home Register About Forex Platforms Education Jeg Blog
» Demo Account
» Real Account
» Open Account

» JegForex Basic
» Psychologys Tading
» Indicator Trading
» MetaTrader Platform

» Learn MQL4
 

Section 1
Introduction: the uses and about MQL4.
Section 2
Simple Example of EA: the Expert Advisor, its example
Section 3
The Syntax and Basics: the variable and comments.
Section 4
Data Type: the type of data on MQL4 with examples.
Section 5
Plans and expressions: the operator and its expression in the MQL4 example.
Section 6
Decision and Looping: the use of branching and looping to set the EA program flow.
Section 7
Order and Technical Analysis: EA discusses how to create order and make use technical indicators.
Section 8
Developing EA: discuss how to prepare EA. It is expected that the reader is able to make a simple EA.
Section 9
Use iCustom: discuss how to prepare the EA based on a custom basis entry indicator.

 
JegForex Registration
JegForex Contact
JegForex Education
 

 Back to Learn MQL4

Prepare EA

OK, basically, a simple EA / standard (non-EA complex network such as humans, for example, or that consists of several modules that control the trade separately) ... consists of several parts / structure .. this part usually make in a distinctive function, so that coding looks neat, while simplify debugging

part:

  1. BuySignal: what conditions on the EA open buy
  2. SellSignal: what conditions on the EA open cell
  3. CloseBuySignal: what conditions on the EA close buy position (this should not have, because it can use TP / SL as closing)
  4. CloseSellSignal: same as CloseBuySignal
  5. MoneyManagement: create automatically calculate lotsize
  6. Trail: create trailling position, for example, what is needed
  7. Confirmator: if for example EA cuman trade Monday-Thursday, then usually put in this section ..

If section 7 is met, EA make it so more easily

for example like this, I want to make the EA as in Section 2 - Sample EA

EA this logic, some (eg, EA is placed in the GBPUSD chart 1 Hour) If you do not have a position, if the candle hours ago close above its 10 EMA, then buy, if the candle close to its days ago under the EMA 10, then sell. TP and the SL 150 is its 100 pips

in the breakdown so that the earlier 7:

  1. BuySignal: if the previous candle close price is greater / above 10 EMA on the previous candle
  2. SellSignal: if the price of the previous candle close more small / under the 10 EMA on the previous candle
  3. No
  4. No
  5. Lot is automatically calculated based on the SL and the percent risk.
  6. No use trail, so there is no
  7. Posis new opened if there are not positions, and also does not trade on Friday (I will add rule)

about the source code is so well

code:
extern double RiskPercent=5;
extern int StopLoss=100;
extern int TakeProfit=150;
extern string txComment="Order EA1";
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 (bolehTrade()) //that can trade
{
if (BuySignal() ) //buy signal if there
{
OrderSend(Symbol(),OP_BUY,itungLot(),Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,txComment,MagicNumber);
}
else if (SellSignal() ) // sell signal if there
{
OrderSend(Symbol(),OP_SELL,itungLot(),Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,txComment,MagicNumber);
}

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

bool BuySignal()
{
/ / if the previous candle close price is greater / above 10 EMA on the previous candle
if (iClose(Symbol(),0,1) > iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,1) )
{
return(true);
}
else
{
return(false);
}
}

bool SellSignal()
{
/ / if the price of the previous candle close more small / under the 10 EMA on the previous candle
if (iClose(Symbol(),0,1) < iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE,1) )
{
return(true);
}
else
{
return(false);
}
}

bool bolehTrade()
{
/ / if the day Friday, EA does not trade, or if the order is open, the EA does not trade
if (DayOfWeek()==5 || OrdersTotal()>0) { return (false); } else { return(true); }
}

double itungLot()
{
/ / for this lot is calculated automatically based on the SL and the risk of
double xLots=0;
xLots=NormalizeDouble(AccountBalance()*RiskPercent/100 /StopLoss / 10,1);
return (xLots);
}

logic is so neat and clear ...

Oya, the operator at a glance
| | & Means or means and (later will be described in the section about the service)

EA is invisible to its simple coding of most need its only 5-10 minutes .... but if in the backtest, profitable (irrespective of its dradown large) ...

Hopefully useful to all of us ..
Click the register when you are ready!

Section 9 - Use iCustom: discuss how to prepare the EA based on a custom basis entry indicator.

 
 

 

 

 Jadikan homepage Anda | | Risk Disclosure | Contact | Links

Solusi tepat dalam investasi.
© 2010. all rights reserved
 
Sported by Polsend.com