e-man123_203

Author: man123 & KimIV
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
125.00 %
Total Trades 38
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 4.26
Gross Profit 798.90
Gross Loss -637.10
Total Net Profit 161.80
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
493.00 %
Total Trades 44
Won Trades 30
Lost trades 14
Win Rate 0.68 %
Expected payoff 40.15
Gross Profit 2215.80
Gross Loss -449.20
Total Net Profit 1766.60
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
21.00 %
Total Trades 41
Won Trades 15
Lost trades 26
Win Rate 0.37 %
Expected payoff -20.40
Gross Profit 225.40
Gross Loss -1061.90
Total Net Profit -836.50
-100%
-50%
0%
50%
100%
e-man123_203
//+------------------------------------------------------------------+
//|                                                     e-man123.mq4 |
//|                                                   man123 & KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|  16.02.2006  Ñîâåòíèê ïî äèñêðåòíûì ñèãíàëàì òð¸õ èíäèêàòîðîâ.   |
//+------------------------------------------------------------------+
#property copyright "man123 & KimIV"
#property link      "http://www.kimiv.ru"

//------- Âíåøíèå ïàðàìåòðû ñîâåòíèêà --------------------------------
extern string _P_Expert = "---------- Ïàðàìåòðû ñîâåòíèêà";
extern double Lots       = 0.1;
extern int    StopLoss   = 0;
extern int    TakeProfit = 0;
extern int    MAGIC      = 20060216;
extern bool   UseAddPos  = True;
extern string _P1 = "---------- Ïàðàìåòðû 1-ãî èíäèêàòîðà";
extern int    K1         = 10;
extern double Kstop1     = 0.5;
extern int    Kperiod1   = 50;
extern int    PerADX1    = 14;
extern int    CountBars1 = 50;
extern string _P2 = "---------- Ïàðàìåòðû 2-ãî èíäèêàòîðà";
extern int    K2         = 20;
extern double Kstop2     = 0.5;
extern int    Kperiod2   = 100;
extern int    PerADX2    = 14;
extern int    CountBars2 = 50;
extern string _P3 = "---------- Ïàðàìåòðû 3-ãî èíäèêàòîðà";
extern int    K3         = 30;
extern double Kstop3     = 0.5;
extern int    Kperiod3   = 150;
extern int    PerADX3    = 14;
extern int    CountBars3 = 50;

//------- Ãëîáàëüíûå ïåðåìåííûå ñîâåòíèêà ----------------------------
int   Slippage    = 3;
color clOpenBuy   = LightBlue;
color clOpenSell  = LightCoral;
color clCloseBuy  = Blue;
color clCloseSell = Red;
int   prevTimeBar;


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  if (prevTimeBar!=Time[0]) OpenPositions();
  prevTimeBar=Time[0];
}

//+------------------------------------------------------------------+
//| Îòêðûòèå ïîçèöèé                                                 |
//+------------------------------------------------------------------+
void OpenPositions() {
  double ldStop=0, ldTake=0;
  int    bs=GetTradeSignal();

  if (bs>0) {
    if (ExistPositionByOP(OP_SELL)) CloseAllPositions();
    if (!ExistPositionByOP(OP_BUY) || UseAddPos) {
      if (StopLoss!=0) ldStop=Ask-StopLoss*Point;
      if (TakeProfit!=0) ldTake=Ask+TakeProfit*Point;
      OpenPosition(OP_BUY, ldStop, ldTake);
    }
  }
  if (bs<0) {
    if (ExistPositionByOP(OP_BUY)) CloseAllPositions();
    if (!ExistPositionByOP(OP_SELL) || UseAddPos) {
      if (StopLoss!=0) ldStop=Bid+StopLoss*Point;
      if (TakeProfit!=0) ldTake=Bid-TakeProfit*Point;
      OpenPosition(OP_SELL, ldStop, ldTake);
    }
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò òîðãîâûé ñèãíàë:                                      |
//|    1 - ïîêóïàé                                                   |
//|    0 - ñèäè, êóðè áàìáóê                                         |
//|   -1 - ïðîäàâàé                                                  |
//+------------------------------------------------------------------+
int GetTradeSignal() {
  int    bs=0;
  double b1=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K1, Kstop1, Kperiod1, PerADX1, CountBars1, 0, 1);
  double b2=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K2, Kstop2, Kperiod2, PerADX2, CountBars2, 0, 1);
  double b3=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K3, Kstop3, Kperiod3, PerADX3, CountBars3, 0, 1);
  double s1=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K1, Kstop1, Kperiod1, PerADX1, CountBars1, 1, 1);
  double s2=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K2, Kstop2, Kperiod2, PerADX2, CountBars2, 1, 1);
  double s3=iCustom(NULL, 0, "AltrTrend_Signal_v2_2", K3, Kstop3, Kperiod3, PerADX3, CountBars3, 1, 1);

  if (b1>0 && b2>0 && b3>0) bs=1;
  if (s1>0 && s2>0 && s3>0) bs=-1;

  return(bs);
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò ôëàã ñóùåñòâîâàíèÿ ïîçèöèè                            |
//+------------------------------------------------------------------+
bool ExistPositionByOP(int op) {
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==op) return(True);
      }
    }
  }
  return(False);
}

//+------------------------------------------------------------------+
//| Îòêðûòèå ïîçèöèè                                                 |
//| Ïàðàìåòðû:                                                       |
//|   op     - îïåðàöèÿ                                              |
//|   ldStop - óðîâåíü ñòîï                                          |
//|   ldTake - óðîâåíü òåéê                                          |
//+------------------------------------------------------------------+
void OpenPosition(int op, double ldStop, double ldTake) {
  color  clOpen;
  double pp;

  if (op==OP_BUY) {
    clOpen=clOpenBuy; pp=Ask;
  } else {
    clOpen=clOpenSell; pp=Bid;
  }
  pp=NormalizeDouble(pp, Digits);
  OrderSend(Symbol(),op,Lots,pp,Slippage,ldStop,ldTake,"",MAGIC,0,clOpen);
}

//+------------------------------------------------------------------+
//| Çàêðûòèå âñåõ ïîçèöèé ïî ðûíî÷íîé öåíå                           |
//+------------------------------------------------------------------+
void CloseAllPositions() {
  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY) {
          OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy);
        }
        if (OrderType()==OP_SELL) {
          OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);
        }
      }
    }
  }
}
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---