Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
3.00 %
Total Trades 105
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -4.80
Gross Profit 18.00
Gross Loss -522.00
Total Net Profit -504.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
21.00 %
Total Trades 186
Won Trades 65
Lost trades 121
Win Rate 0.35 %
Expected payoff -1.28
Gross Profit 65.00
Gross Loss -302.50
Total Net Profit -237.50
-100%
-50%
0%
50%
100%
Matrix
//+------------------------------------------------------------------+
//|                                                  TimeBasedEA.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
//changed by:       "forex4capital@yahoo.ca"

// Time frame: M5 and higher

extern int     MagicNumber = 20080122;
extern int     OpenHour     = 8;        
extern int     OpenMinute   = 55;      
extern double  TakeProfit  = 10;
extern double  StopLoss    = 10;
extern double  Lots        = 0.1;
extern bool    OpenBuy     = true;
extern bool    OpenSell    = false;
extern int     NumBuys     = 1;
extern int     NumSells    = 1;
extern int     Slippage    = 3;

//---- Close input parameters
extern int   CloseHour     = 7;      // Âðåìÿ çàêðûòèÿ, ÷àñû
extern int   CloseMinute   = 0;      // Âðåìÿ çàêðûòèÿ, ìèíóòû
bool  UseCurrSymbol = True;  // Èñïîëüçîâàòü òîëüêî îäèí èíñòðóìåíò
extern color clCloseBuy    = Blue;   // Öâåò çàêðûòèÿ ïîêóïêè
extern color clCloseSell   = Red;    // Öâåò çàêðûòèÿ ïðîäàæè.....

//+------------------------------------------------------------------+
//|                        S T A R T                                 |
//+------------------------------------------------------------------+
int start()
  {
   int cnt, ticket, total;
   //int ct;
//-------------------------------------+
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  
     }
//-------------------------------------+
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);  // check TakeProfit
     }
//-------------------------------------+

///////////////////////////////////////////////////////////////////////////////////////////////////
double pBid,pAsk;


  if (Hour()==CloseHour && Minute()>=CloseMinute)
   {
    for (int i=OrdersTotal()-1; i>=0; i--) 
    {
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
      {
        if (!UseCurrSymbol || OrderSymbol()==Symbol()) 
        {
          if (OrderType()==OP_BUY) 
            {
               pBid=MarketInfo(OrderSymbol(), MODE_BID);
               OrderClose(OrderTicket(), OrderLots(), pBid, Slippage, clCloseBuy);
            }
            if (OrderType()==OP_SELL)  
               {
               pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
               OrderClose(OrderTicket(), OrderLots(), pAsk, Slippage, clCloseSell);
               }
        }
      }
    }
  }





   //ct = Hour() * 100 + Minute();
   total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if (Hour()==OpenHour && Minute()>=OpenMinute && OpenBuy)
      //if(ct == StartHour && Close[1]>Open[1] && OpenBuy)
      //if(ct == StartHour && High[1]<Open[0] && OpenBuy)
        {
         for ( cnt = 0; cnt < NumBuys; cnt++)
         {
           ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",MagicNumber,0,Blue);
           if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
           else Print("Error opening BUY order : ",GetLastError()); 
         }
         return(0); 
        }
      // check for short position (SELL) possibility
      if (Hour()==OpenHour && Minute()>=OpenMinute && OpenSell)
      //if(ct == StartHour && Close[1]<Open[1] && OpenSell)
      //if(ct == StartHour && Low[1]>Open[0] && OpenSell)
        {
         for ( cnt = 0; cnt < NumSells; cnt++)
         {
           ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red);
           if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
           else Print("Error opening SELL order : ",GetLastError());
         } 
         return(0); 
        }
     }
   return(0);
  }
// the end

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