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.
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