Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
58.00 %
Total Trades 79
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.40
Gross Profit 155.60
Gross Loss -266.50
Total Net Profit -110.90
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
60.00 %
Total Trades 38
Won Trades 16
Lost trades 22
Win Rate 0.42 %
Expected payoff -2.01
Gross Profit 112.90
Gross Loss -189.20
Total Net Profit -76.30
-100%
-50%
0%
50%
100%
amer
//+------------------------------------------------------------------+
//|                                                         amer.mq4 |
//|                                                             Olek |
//|                                                                  |
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int TrailingStop = 50;
extern int StopLoss=50;
extern int TakeProfit = 200;
extern int per = 700;
extern int vremya = 0;
extern int DayWeek = 2;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double Mov1= 0, Mov2=0;
   int cnt, ticket, total;
   
   Mov1= iMA(0,0,per,0,0,0,1);
   Mov2= iMA(0,0,per,0,0,0,2);

   int  h=0; 

int       hour0=0; 
int       hour1=0; 
int       hour2=0; 
int       hour3=0; 
int       hour4=0; 
int       hour5=0; 
int       hour6=0; 
int       hour7=0; 
int       hour8=0; 
int       hour9=0; 
int       hour10=0; 
int       hour11=0; 
int       hour12=0; 
int       hour13=0; 
int       hour14=0; 
int       hour15=0; 
int       hour16=0; 
int       hour17=0; 
int       hour18=0; 
int       hour19=0; 
int       hour20=0; 
int       hour21=0; 
int       hour22=0; 
int       hour23=0; 

if (DayOfWeek() == 1)  {hour0=1;hour1=1;hour2=1;hour3=0;hour4=1;hour5=1;hour6=0;hour7=0;hour8=1;hour9=1;hour10=1;hour11=1; 
             hour12=0;hour13=1;hour14=0;hour15=1;hour16=1;hour17=1;hour18=0;hour19=0;hour20=0;hour21=0;hour22=0;hour23=1;} 
else   if (DayOfWeek() == 2)  {hour0=1;hour1=1;hour2=1;hour3=0;hour4=1;hour5=1;hour6=0;hour7=0;hour8=1;hour9=1;hour10=1;hour11=1; 
             hour12=0;hour13=1;hour14=0;hour15=1;hour16=1;hour17=1;hour18=0;hour19=0;hour20=0;hour21=0;hour22=0;hour23=1;} 
else   if (DayOfWeek() == 3)  {hour0=1;hour1=1;hour2=1;hour3=0;hour4=1;hour5=1;hour6=0;hour7=0;hour8=1;hour9=1;hour10=1;hour11=1; 
             hour12=0;hour13=1;hour14=0;hour15=1;hour16=1;hour17=1;hour18=0;hour19=0;hour20=0;hour21=0;hour22=0;hour23=1;} 
else   if (DayOfWeek() == 4)  {hour0=1;hour1=1;hour2=1;hour3=0;hour4=1;hour5=1;hour6=0;hour7=0;hour8=0;hour9=0;hour10=0;hour11=0; 
             hour12=0;hour13=0;hour14=0;hour15=0;hour16=0;hour17=0;hour18=0;hour19=0;hour20=0;hour21=0;hour22=0;hour23=1;} 
else   if (DayOfWeek() == 5)  {hour0=1;hour1=1;hour2=1;hour3=0;hour4=1;hour5=1;hour6=0;hour7=0;hour8=1;hour9=1;hour10=0;hour11=0; 
             hour12=0;hour13=0;hour14=0;hour15=0;hour16=0;hour17=0;hour18=0;hour19=0;hour20=0;hour21=0;hour22=0;hour23=0;} 
  
       if(Hour()== 0) h=hour0; 
else   if(Hour()== 1) h=hour1; 
else   if(Hour()== 2) h=hour2; 
else   if(Hour()== 3) h=hour3; 
else   if(Hour()== 4) h=hour4; 
else   if(Hour()== 5) h=hour5; 
else   if(Hour()== 6) h=hour6; 
else   if(Hour()== 7) h=hour7; 
else   if(Hour()== 8) h=hour8; 
else   if(Hour()== 9) h=hour9; 
else   if(Hour()== 10) h=hour10; 
else   if(Hour()== 11) h=hour11; 
else   if(Hour()== 12) h=hour12; 
else   if(Hour()== 13) h=hour13; 
else   if(Hour()== 14) h=hour14; 
else   if(Hour()== 15) h=hour15; 
else   if(Hour()== 16) h=hour16; 
else   if(Hour()== 17) h=hour17; 
else   if(Hour()== 18) h=hour18; 
else   if(Hour()== 19) h=hour19; 
else   if(Hour()== 20) h=hour20; 
else   if(Hour()== 21) h=hour21; 
else   if(Hour()== 22) h=hour22; 
else   if(Hour()== 23) h=hour23;    

if(  h==1 ) 

   total=OrdersTotal();
   if(total<1 && Hour() == vremya && DayOfWeek()>= DayWeek) 
     {
      
      if( Mov1 < Mov2 )
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"",12,0,Red);
         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(Mov1 > Mov2 )
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"",12,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);
     }
      
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   
         OrderSymbol()==Symbol())  
        {
         if(OrderType()==OP_BUY)   
           {
            
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else 
           {
            
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),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 ---