e-PassLevCCI-EMA

Author: Gentor, KimIV
Profit factor:
0.30
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
8 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/CAD Jul 2025 - Sep 2025
0.00
Total Trades 21
Won Trades 0
Lost trades 21
Win Rate 0.00 %
Expected payoff -1.96
Gross Profit 0.00
Gross Loss -41.22
Total Net Profit -41.22
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.15
Total Trades 36
Won Trades 2
Lost trades 34
Win Rate 5.56 %
Expected payoff -2.16
Gross Profit 14.00
Gross Loss -91.80
Total Net Profit -77.80
-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.72
Total Trades 23
Won Trades 5
Lost trades 18
Win Rate 21.74 %
Expected payoff -0.59
Gross Profit 35.00
Gross Loss -48.60
Total Net Profit -13.60
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.20
Total Trades 14
Won Trades 1
Lost trades 13
Win Rate 7.14 %
Expected payoff -2.01
Gross Profit 7.00
Gross Loss -35.10
Total Net Profit -28.10
-100%
-50%
0%
50%
100%
USD/JPY 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%
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%

Comments