Orders Execution
Indicators Used
0
Views
0
Downloads
0
Favorites
RSIfhAlligv2MA
//+------------------------------------------------------------------+
//| RSI Zaur$.mq4 |
//| Copyright 2012, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
extern double Lots = 0.1;
extern int TraillingStop = 300;
extern int slippage = 3;
//--------RSI---ATR---------------
extern int RSI_PERIOD = 14;
extern int ATR_PERIOD = 12;
//------Âðåìÿ íà÷àëà è êîíöà òîðãîâëè------
extern int TimeStart = 8;
extern int TimeStop = 22;
//----------ïàðàìåðòû MA-------------------
extern int FastEMA = 13;
extern int SlowEMA = 26;
extern int SignalSMA = 10;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double TakeProfit;
double StopLoss;
int RSI_1, RSI_2;
int OT = OrdersTotal();
int TC = TimeHour(TimeCurrent());
double teeth, jaw, lips, MacdCurrent, MacdPrevious, SignalCurrent, SignalPrevious, ATR;
//-----------------------------------------------------------------------------------------------
ATR = iATR(NULL,PERIOD_H4,ATR_PERIOD,1);
RSI_1 = iRSI(NULL,PERIOD_H1,RSI_PERIOD,PRICE_CLOSE,1);
RSI_2 = iRSI(NULL,PERIOD_H1,RSI_PERIOD,PRICE_CLOSE,2);
teeth = iAlligator(NULL,PERIOD_H4, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1);
jaw = iAlligator (NULL,PERIOD_H4, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 1);
lips = iAlligator (NULL,PERIOD_H4, 13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, 1);
MacdCurrent=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,9,PRICE_CLOSE,MODE_MAIN,1);
MacdPrevious=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,9,PRICE_CLOSE,MODE_MAIN,2);
SignalCurrent=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,1);
SignalPrevious=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,SignalSMA,PRICE_CLOSE,MODE_SIGNAL,2);
//------------------------------------------------------------------------------------------------
TakeProfit = ATR;
StopLoss = ATR;
//-----------------------------------------------------------------------------------------------
if(TC > TimeStart && TC < TimeStop) {
if(OT < 1) {
if(MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && RSI_1 < 50) {
if(lips > teeth && teeth > jaw){
OrderSend(Symbol(),OP_SELL,Lots,Bid,slippage,Bid+StopLoss,Bid-TakeProfit);
}
}
if(MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious && RSI_1 > 50) {
if(jaw > teeth && teeth > lips) {
OrderSend(Symbol(),OP_BUY,Lots,Ask,slippage,Ask-StopLoss,Ask+TakeProfit);
}
}
}
//-----------------------------------------------------------------------------------------------
if(OT > 0) {
for(int i=0;i<OT; i++) {
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) {
if(OrderType()==OP_BUY) {
if(Bid-OrderOpenPrice()>TraillingStop*Point){
if(OrderStopLoss()<Bid-TraillingStop*Point){
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TraillingStop,OrderTakeProfit()+TraillingStop*Point,0,0);
return(0);
}
}
}
if(OrderType()==OP_SELL) {
if(OrderOpenPrice()-Ask>TraillingStop*Point) {
if(OrderStopLoss()>Ask+TraillingStop*Point) {
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TraillingStop*Point,OrderTakeProfit()-TraillingStop*Point,0,0);
return(0);
}
}
}
}
}
}
}
//-----------------------------------------------------------------------------------------------
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---