Professional Documents
Culture Documents
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
//
// Standard inputs
//
input double InpOrderSize = 2; // Order
size
input string InpTradeComment = "HHA RSI Ascending"; // Trade
comment
input int InpMagicNumber = 199309; // Magic
number
input double InpLessThanRsi = 30 ; // Low Rsi Defaul
input double InpGreaterThanRsi = 70 ; // High Rsi Defaul
// Use these to store the point values of sl and tp converted to double
//
double TakeProfitSell;
double StopLossSell;
double TakeProfitBuy;
double StopLossBuy;
bool CloseOpposite;
int order;
int OnInit() {
//
// Convert the input point sl tp to double
//
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
//+----------------------------+
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
order =
OrderSend(NULL,OP_SELL,InpOrderSize,Bid,1,StopLossSell,TakeProfitSell,NULL,InpTrade
Comment,0,clrGreen);}
}
else if (rsiIndex >= InpGreaterThanRsi && Ask < aveLastOP ){
//Sell
if (order <=0){
order =
OrderSend(NULL,OP_SELL,InpOrderSize,Bid,1,StopLossSell,TakeProfitSell,NULL,InpTrade
Comment,0,clrGreen);}
}
else if (rsiIndex <= InpLessThanRsi && Bid > aveLastOP ){
//Buy
if (order <=0){
order =
OrderSend(NULL,OP_BUY,InpOrderSize,Ask,1,StopLossBuy,TakeProfitBuy,NULL,InpTradeCom
ment,0,clrGreen);}
}
}
void closeOrder(){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderType() == OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Bid,2,clrBlue);}
}
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if (OrderType() == OP_BUY )
OrderClose(OrderTicket(),OrderLots(),Ask,2,clrBlue);}}