Author: Alksnis Gatis
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
MACD Histogram
1 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
124.00 %
Total Trades 96
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 90.52
Gross Profit 45031.00
Gross Loss -36341.00
Total Net Profit 8690.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
49.00 %
Total Trades 42
Won Trades 11
Lost trades 31
Win Rate 0.26 %
Expected payoff -196.64
Gross Profit 8059.00
Gross Loss -16318.00
Total Net Profit -8259.00
-100%
-50%
0%
50%
100%
AG
//+------------------------------------------------------------------+
//|                                                           AG.mq4 |
//|                                                    Alksnis Gatis |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Alksnis Gatis"
#property link      "http://www.metaquotes.net"

extern double     Lots=     1;
extern double     F_EMA=   15;
extern double     S_EMA=   18;
extern double     SMA=     30;
extern double     ORDER=   10;
extern int        chk=      0;
//+------------------------------------------------------------------+
//|          expert start making money - sometimes                   |
//+------------------------------------------------------------------+
int start()
  {
   int  ticket, total;
   double SAR,SA;
   SAR=iMACD(Symbol(),0,F_EMA,S_EMA,SMA,PRICE_WEIGHTED,MODE_MAIN,1);
   SA=iMACD(Symbol(),0,F_EMA,S_EMA,SMA,PRICE_WEIGHTED,MODE_SIGNAL,1);
   double SAR1,SA1;
   SAR1=iMACD(Symbol(),0,S_EMA*2,F_EMA*2,SMA*2,PRICE_WEIGHTED,MODE_MAIN,1);
   SA1=iMACD(Symbol(),0,S_EMA*2,F_EMA*2,SMA*2,PRICE_WEIGHTED,MODE_SIGNAL,1);
  
   
   total=OrdersTotal();
   if(total<ORDER)
     {
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("NO MONEY = ", AccountFreeMargin());
         return(0);
        }
     
        {
         chk=1;
         Print("OK OK OK OK OK!");
        }
      if(chk==1)
        {
//------------------ OPEN SEEL ---------------------//
      if((SAR<SA)&&(SA>0)&&(SAR1<SA1)&&(SA1>0))
           {
            ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,
            "SAR position:",16385,0,Red);
            if(ticket<1)
              {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==False)
                  Print("OPEN SELL ORDER :  ",OrderOpenPrice());
              }
            else
              {
               Print("-----ERROR-----  opening SEEL order : ",GetLastError());
               return(0);
              }
           }
//------------------ OPEN BUY ---------------------//
         if((SAR>SA)&&(SA<0)&&(SAR1>SA1)&&(SA1<0))
           {
            ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,
            "SAR position:",16385,0,Blue);
            if(ticket<1)
              {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)==False)
                  Print("OPEN BUY ORDER ",OrderOpenPrice());
              }
            else
              {
               Print("-----ERROR-----  opening BUY order : ",GetLastError());
               return(0);
              }
           }
        }
      return(0);
     }
 //------------------ CLOSE BUY ---------------------//
     {
      OrderSelect(SELECT_BY_POS, MODE_TRADES);
         if(OrderType()==OP_BUY && OrderSymbol()==Symbol()) 
            if((SAR1<SA1)&&(SA>0))
              {
               OrderClose(OrderTicket(),OrderLots(),Bid,3,Black); // OUT
               return(0); 
 //------------------ CLOSE SELL --------------------//       
              }
        OrderSelect(SELECT_BY_POS, MODE_TRADES);
          if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
           if((SAR1>SA1)&&(SA<0))
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,White); // OUT
               return(0);
              }
           
           }
  return(0);
  }
//+-------------------- GAME OWER --------------------------------+

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