Author: Copyright � 2005, MetaQuotes Software Corp.
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
MACD Histogram
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
85.00 %
Total Trades 29
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.26
Gross Profit 375.00
Gross Loss -440.60
Total Net Profit -65.60
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
42.00 %
Total Trades 27
Won Trades 6
Lost trades 21
Win Rate 0.22 %
Expected payoff -22.36
Gross Profit 435.50
Gross Loss -1039.30
Total Net Profit -603.80
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
49.00 %
Total Trades 27
Won Trades 6
Lost trades 21
Win Rate 0.22 %
Expected payoff -11.19
Gross Profit 284.90
Gross Loss -587.10
Total Net Profit -302.20
-100%
-50%
0%
50%
100%
hocok
//+------------------------------------------------------------------+
//|                                                        hocok.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- input parameters
extern int TakeProffit   = 0;
extern int StopLoss      = 0;
extern int signal_period = 9;

static int     magic = 1;
static datetime opentime;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
void CloseOrders()
{
   for (int i = OrdersTotal() - 1; i > -1; i--)
   {
      if (OrderSelect(i, SELECT_BY_POS, MODE_MAIN))
      {
         if (OrderMagicNumber() == magic)
         {
            if (OrderType() == OP_BUY)
               OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
            else         
               OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
         }
      }
   }
}
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
   double SL = 0, TP = 0;
   int fast_ema_period = 21;
   int slow_ema_period = 34;
   
   if (opentime == Time[1])
      return (0);

   opentime = Time[1];
   
   double prev = iMACD(Symbol(), 0, fast_ema_period, slow_ema_period, signal_period, PRICE_CLOSE, MODE_SIGNAL, 2);
   double curr = iMACD(Symbol(), 0, fast_ema_period, slow_ema_period, signal_period, PRICE_CLOSE, MODE_SIGNAL, 1);
   
   // Ñèãíàë ê ïîêóïêå
   if ((prev < 0) && (curr > 0))
   {
      CloseOrders();

      if (StopLoss    != 0) SL = Bid - StopLoss    * Point;
      if (TakeProffit != 0) TP = Bid + TakeProffit * Point;
      OrderSend(Symbol(), OP_BUY, 0.1, Ask, 3, NormalizeDouble(SL, Digits), 
                                               NormalizeDouble(TP, Digits), "", magic, 0, Red);
      return (0);
   }

   // Ñèãíàë ê ïðîäàæå
   if ((prev > 0) && (curr < 0))
   {
      CloseOrders();

      if (StopLoss    != 0) SL = Ask + StopLoss    * Point;
      if (TakeProffit != 0) TP = Ask - TakeProffit * Point;
      OrderSend(Symbol(), OP_SELL, 0.1, Bid, 3, NormalizeDouble(SL, Digits), 
                                                NormalizeDouble(TP, Digits), "", magic, 0, Red);
      return (0);
   }

   return(0);
}
//+------------------------------------------------------------------+

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 ---