extern double LotSize=0.1;
extern double stopLoss=50;
extern double Takeprofit=100;
extern int Slippage=5;
extern int MagicNumber=123;
extern int FastMAperiod=10;
extern int SlowMAperiod=20;
//Global. variables
int BuyTicket;
int SellTicket;
double UsePoint;
int UseSlippage;
//int function
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int init
{
//---
UsePoint=PipPoint);
UseSlippage=GetSlippage,Slippage);
//---
return;
}
//+------------------------------------------------------------------+
//| Expert Start function |
//+------------------------------------------------------------------+
int start
{
//Moving averages
double FastMA=iMa;
double SlowMA=iMa;
//Buy order
if
{
OrderSelect;
//Close order
if==0&&SellTicket>0)
{
double CloseLots=OrderLots;
double ClosePrice=Ask;
boot Closed=OrderClose;
}
double OpenPrice=Ask;
//Calculate stop loss and take profit
ifdouble BuyStopLoss=Openprice-;
ifdouble BuyTakeProfit=OpenPrice+;
//Open buy order
BuyTicket=OrderSend,OP_BUY,LotSize,OpenPrice,UseSlippage,BuyStopLoss,BuyTakeProfit,"Buy Order",MagicNumber,0,Green);
SellTicket0;
}
//Sell Order
if
{
OrderSelect;
if==0&&BuyTicket>0)
{
CloseLots=OrderLots;
ClosePrice bid;
Closed=OrderClose;
}
OpenPrice=Bid;
ifdouble SellStopLoss=OpenPrice+;
ifdouble SellTakeProfit=OpenPrice-;
SellTicket=OrderSend,OP_SELL,LotSize,Openprice,UseSlippage,SellStopLoss,SellTakeProfit,"Sell Order",MagicNumber,0,Red);
BuyTicket=0;
}
return;
}
//Pip Point Function
double Pippoint
{
int CalcDigits=MarketInfo;
ifdouble CalcPoint=0.01;
else if CalcPoint=0.001;
return;
}
//GetSlippage Function
int GetSlippage
{
int CalcDigits=MarketInfo;
{
ifdouble CalcSlippage=SlippagePips;
else if CalcSlippage=SlippagePips*10;
}
return;
} |