e-PassLevCCI-EMA

Author: Gentor, KimIV
Profit factor:
0.34
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Commodity channel index
6 Views
0 Downloads
0 Favorites
e-PassLevCCI-EMA
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                             e-PassLevCCI-EMA.mq4 |
//|                              Èäåÿ Gentor, ðåàëèçàöèÿ â ÌÒ4 KimIV |
//|                                              http://www.kimiv.ru |
//| Ôèêñàöèÿ ïðèáûëè â ïîðÿäêå ïðèîðèòåòà:                           |
//| 1. TrailingStop                                                  |
//| 2. TakeProfit                                                    |
//| 3. Ïî ñèãíàëó âûõîäà                                             |
//| Ôèëüòð EMA                                                       |
//+------------------------------------------------------------------+
#property copyright "Gentor, KimIV"
#property link      "http://www.kimiv.ru"
#define   MAGIC     20050822

//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern double Lots          = 0.1;    // Ðàçìåð òîðãóåìîãî ëîòà
extern int    StopLoss      = 27;     // Ðàçìåð ôèêñèðîâàííîãî ñòîïà
extern bool   UseTakeProfit = True;   // Èñïîëüçîâàòü òýéê
extern int    TakeProfit    = 70;     // Ðàçìåð ôèêñèðîâàííîãî òýéêà
extern bool   UseTrailing   = False;  // Èñïîëüçîâàòü òðàë
extern int    TrailingStop  = 50;     // Ðàçìåð òðàëà
extern int    CCI_Period    = 18;     // Ïåðèîä CCI
extern int    EMA_Period    = 34;     // Ïåðèîä EMA
extern int    BarsForCheck  = 4;      // Êîëè÷åñòâî áàðîâ äëÿ ïðîâåðêè

//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
datetime OldBar;

//+------------------------------------------------------------------+
//| Ïðîâåðêà óñëîâèé îòêðûòèÿ ïîçèöèè                                |
//+------------------------------------------------------------------+
void CheckForOpen() {
  bool   PosExist=False;     // Åñòü îòêðûòàÿ ïîçèöèÿ ïî òåêóùåìó èíñòðóìåíòó
  double cci1, cci2, ema;
  double take;

  // Ïîèñê ïîçèöèé ïî òåêóùåìó èíñòðóìåíòó, îòêðûòûõ èìåííî ýòèì ñîâåòíèêîì
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        PosExist=True;
      }
    }
  }

  // Íåò îòêðûòûõ ïîçèöèé.
  if (!PosExist) {
    // Ôèêñèðóåì çíà÷åíèÿ ÑÑÈ.
    cci1 = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, 1);
    cci2 = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, BarsForCheck);
    ema  = iMA (NULL, 0, EMA_Period, 0, MODE_EMA, PRICE_TYPICAL, 1);
    // Ñèãíàë íà ïîêóïêó.
    if (cci1>100 && cci2<-100 && ema>Close[1]) {
      if (UseTakeProfit) take = Ask+TakeProfit*Point;
      else take = 0;
      OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,take,"e-PassLevCCI",MAGIC,0,Blue);
      OldBar = Time[1];
      return;
    }
    // Ñèãíàë íà ïðîäàæó.
    if (cci1<-100 && cci2>100 && ema<Close[1]) {
      if (UseTakeProfit) take = Bid-TakeProfit*Point;
      else take = 0;
      OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,take,"e-PassLevCCI",MAGIC,0,Red);
      OldBar = Time[1];
      return;
    }
  }
}

//+------------------------------------------------------------------+
//| Ïðîâåðêà óñëîâèé çàêðûòèÿ ïîçèöèè                                |
//+------------------------------------------------------------------+
void CheckForClose() {
  bool fs=False;        // Ôëàã íàëè÷èÿ ñèãíàëà çàêðûòèÿ
  int  cci1, cci2;

  // Ôèêñèðóåì çíà÷åíèÿ ÑÑÈ.
  cci1 = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, 1);
  cci2 = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, 2);
  // Ñèãíàë íà çàêðûòèå ïîçèöèè.
  if (cci1*cci2<0 && OldBar!=Time[1]) fs = True;

  // Ïîèñê ïîçèöèé ïî òåêóùåìó èíñòðóìåíòó, îòêðûòûõ èìåííî ýòèì ñîâåòíèêîì
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY && fs) {
          OrderClose(OrderTicket(), Lots, Bid, 3, Aqua);
          return;
        }
        if (OrderType()==OP_SELL && fs) {
          OrderClose(OrderTicket(), Lots, Ask, 3, Violet);
          return;
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè                                            |
//+------------------------------------------------------------------+
void TrailingPosition() {
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY) {
          if ((Bid-OrderOpenPrice())>TrailingStop*Point) {
            if (OrderStopLoss()<Bid-TrailingStop*Point) {
              OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),Blue);
              return;
            }
          }
        }
        if (OrderType()==OP_SELL) {
          if ((OrderOpenPrice()-Ask)>TrailingStop*Point) {
            if (OrderStopLoss()>Ask+TrailingStop*Point) {
              OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),Red);
              return;
            }
          }
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  CheckForOpen();
  if (UseTrailing) TrailingPosition();
  else if (!UseTakeProfit) CheckForClose();
}
//+------------------------------------------------------------------+

Profitability Reports

USD/CHF Jul 2025 - Sep 2025
0.55
Total Trades 23
Won Trades 4
Lost trades 19
Win Rate 17.39 %
Expected payoff -1.26
Gross Profit 34.97
Gross Loss -64.03
Total Net Profit -29.06
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.30
Total Trades 29
Won Trades 3
Lost trades 26
Win Rate 10.34 %
Expected payoff -1.24
Gross Profit 15.34
Gross Loss -51.24
Total Net Profit -35.90
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.78
Total Trades 13
Won Trades 3
Lost trades 10
Win Rate 23.08 %
Expected payoff -0.46
Gross Profit 21.00
Gross Loss -27.00
Total Net Profit -6.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.52
Total Trades 24
Won Trades 4
Lost trades 20
Win Rate 16.67 %
Expected payoff -1.08
Gross Profit 28.00
Gross Loss -54.00
Total Net Profit -26.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.26
Total Trades 65
Won Trades 6
Lost trades 59
Win Rate 9.23 %
Expected payoff -1.26
Gross Profit 29.31
Gross Loss -111.10
Total Net Profit -81.79
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.06
Total Trades 43
Won Trades 1
Lost trades 42
Win Rate 2.33 %
Expected payoff -3.00
Gross Profit 8.47
Gross Loss -137.49
Total Net Profit -129.02
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.68
Total Trades 24
Won Trades 5
Lost trades 19
Win Rate 20.83 %
Expected payoff -0.47
Gross Profit 24.35
Gross Loss -35.72
Total Net Profit -11.37
-100%
-50%
0%
50%
100%

Comments