Author: Copyright � 2008 Grib
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
4.00 %
Total Trades 3
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2028.67
Gross Profit 221.00
Gross Loss -6307.00
Total Net Profit -6086.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
3.00 %
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 0.67 %
Expected payoff -2498.33
Gross Profit 194.00
Gross Loss -7689.00
Total Net Profit -7495.00
-100%
-50%
0%
50%
100%
RndTrade
//+------------------------------------------------------------------+
//|                                                     RndTrade.mq4 |
//|                                            Copyright © 2008 Grib |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008 Grib"
#property link      ""

#define NUM_BUY  20050611
#define NUM_SELL  20050612
int ticket;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
if(OrdersTotal() == 0)
{
   checkForOpen();
}
else
{
   checkForClose();
}

//----
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Ïðîâåðêà íà îòêðûòèå ïîçèöèè                                    |
//+------------------------------------------------------------------+
void checkForOpen()
{
int a = 0;
MathSrand(TimeLocal());
  // Îòîáðàæàåò 10 ÷èñåë.
  for(int i=0;i<10;i++ )
    if(i==5)
    {
      a = MathRand();
      if(a > 16383.5)
      {
      // Ñîâåðøàåì ïîêóïêó
        ticket = OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,"TestDrawSell",NUM_BUY);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïîêóïêè");
      }
      else
      {
      //Ñîâåðøàåì ïðîäàæó
        ticket = OrderSend(Symbol(),OP_SELL,1,Bid,3,0,0,"TestDrawBuy",NUM_SELL);
        if (ticket == -1) Alert("Îøèáêà ïðè ñîâåðøåíèè îïåðàöèè ïðîäàæè");
      }
    }
    else
    {
      a = MathRand();
    } 
}
//+------------------------------------------------------------------+
//| Ïðîâåðêà íà çàêðûòèå ïîçèöèè                                     |
//+------------------------------------------------------------------+
void checkForClose()
{
  if(OrderSelect(0, SELECT_BY_POS)==true)
  {
    if( (OrderOpenTime()+14400) < TimeLocal() )
       if(OrderClose(OrderTicket(),1,Ask,3) == false)
          Print("Îøèáêà ïðè çàêðûòèè ïîçèöèè");
  }
  else
  {
    Print("OrderSelect() âåðíóë îøèáêó - ",GetLastError());
  }
}
//+------------------------------------------------------------------+

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