3_Otkat_Sys_v1.2

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

GBP/USD Oct 2024 - Jan 2025
11.00 %
Total Trades 35
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -15.80
Gross Profit 70.00
Gross Loss -623.00
Total Net Profit -553.00
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
4.00 %
Total Trades 22
Won Trades 7
Lost trades 15
Win Rate 0.32 %
Expected payoff -34.05
Gross Profit 35.00
Gross Loss -784.00
Total Net Profit -749.00
-100%
-50%
0%
50%
100%
3_Otkat_Sys_v1.2

extern double TakeProfit = 5;
extern double StopLoss = 55;
extern double Lots = 1.0;
extern double Otkat = 18;
extern double KoridorOC = 33;
extern double KoridorOt = 4;

//+------------------------------------------------------------------+
//| Ñèñòåìà ïî îòêàòàì íà 5 ÷àñîâ                                    |
//+------------------------------------------------------------------+
int start()
  {
   int cnt, ticket, total;
   double OpCl=0,ClOp=0,ClLo=0,HiCl=0,OpD=0;
// on a chart of less than 100 bars
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  
     }
   if(TakeProfit<4)
     {
      Print("TakeProfit less than 10");
      return(0);  // check TakeProfit
     }

   total=OrdersTotal();
   // Çàêðûâàåì îðäåðà
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
              if(total>0 && Hour()==22 && Minute()>45)
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 return(0); // exit
                }
           }
         else // go to short position
           {
            // should it be closed?
            if(total>0 && Hour()==22 && Minute()>45)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
              }
           }
        }
     } // Êîíåö çàêðûâàíèÿ îðäåðîâ
   if(total<1) 
     {
     OpCl=Open[29]-Close[1];
     ClOp=Close[1]-Open[29];
     ClLo=Close[1]-Low[Lowest(NULL,60,MODE_LOW,29,0)];
     HiCl=High[Highest(NULL,60,MODE_HIGH,29,0)]-Close[1];
     OpD=Open[0];
     //Lots=AccountFreeMargin()/(Ask*1000); // Òîðãóåì íà ìàêñèìóì ëîòîâ
      // no opened orders identified
      if(AccountFreeMargin()<(Ask*1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if(Hour()==5 && Minute()<=3 && DayOfWeek()!=1 && DayOfWeek()!=5 && OpCl>KoridorOC*Point && ClLo<(Otkat-KoridorOt)*Point)
      {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,OpD,10,OpD-StopLoss*Point,OpD+(TakeProfit+3)*Point,"Sys",16384,0,LawnGreen);
         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);
      }
      if(Hour()==5 && Minute()<=3 && DayOfWeek()!=1 && DayOfWeek()!=5 && ClOp>KoridorOC*Point && HiCl>(Otkat+KoridorOt)*Point)
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,OpD,10,OpD-StopLoss*Point,OpD+(TakeProfit+3)*Point,"Sys",16384,0,LawnGreen);
         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()==5 && Minute()<=3 && DayOfWeek()!=1 && DayOfWeek()!=5 && ClOp>KoridorOC*Point && HiCl<(Otkat-KoridorOt)*Point)
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,OpD,10,OpD+StopLoss*Point,OpD-TakeProfit*Point,"Sys",16384,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); 
        }
      if(Hour()==5 && Minute()<=3 && DayOfWeek()!=1 && DayOfWeek()!=5 && OpCl>KoridorOC*Point && ClLo>(Otkat+KoridorOt)*Point)
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,OpD,10,OpD+StopLoss*Point,OpD-TakeProfit*Point,"Sys",16384,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);
     }
   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 ---