Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
46.00 %
Total Trades 4069
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.21
Gross Profit 4226.90
Gross Loss -9160.00
Total Net Profit -4933.10
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
60.00 %
Total Trades 5341
Won Trades 1028
Lost trades 4313
Win Rate 0.19 %
Expected payoff -1.25
Gross Profit 10095.10
Gross Loss -16793.90
Total Net Profit -6698.80
-100%
-50%
0%
50%
100%
Stub
//+------------------------------------------------------------------+
//|                                                  MACD Sample.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

extern int SystemMagicNumber = 100;
extern int StopLoss = 100;
extern int TakeProfit = 100;
extern double Lots = 0.1;

int start() 
{
  int cnt, total;
  double ma5, ma30;
  double mStop, mTake;

  ma5 = iMA(NULL,0,5, 0,MODE_EMA, PRICE_CLOSE, 0);
  ma30 = iMA(NULL,0,30, 0,MODE_EMA, PRICE_CLOSE, 0);
  total=OrdersTotal();
  if(total<1)
  { 
     if( ma5 < ma30 ) 
     {
        if (StopLoss > 0) mStop = Bid+StopLoss* Point; else mStop = 0;
        if (TakeProfit > 0) mTake = Bid- TakeProfit* Point; else mTake = 0; 
        OrderSend(Symbol( ),OP_SELL, Lots,Bid, 3 * Point,mStop,mTake,"", SystemMagicNumber,0,Red);     
        return(0); 
     } 
    
     if( ma5 > ma30) 
     { 
        if (StopLoss > 0) mStop = Ask - StopLoss* Point; else mStop = 0;
        if (TakeProfit > 0) mTake = Ask + TakeProfit* Point; else mTake = 0; 
        OrderSend(Symbol( ),OP_BUY, Lots,Ask, 3 * Point,mStop,mTake,"", SystemMagicNumber,0,Blue) ; 
        return(0); 
     }
     return(0);
   }
   
   for(cnt=total - 1;cnt >= 0;cnt--)
   {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if ( OrderSymbol()==Symbol() && OrderMagicNumber() == SystemMagicNumber)  // check for symbol and magic number
      {
          if (OrderType() ==OP_SELL) 
          {          
             if (ma5>ma30) 
             { 
                OrderClose(OrderTicket(), OrderLots(),Ask,3* Point, Red) ;       
               
             } 
          } 
    
          if (OrderType() ==OP_BUY) 
          { 
            if (ma5<ma30) 
            { 
              OrderClose(OrderTicket(), OrderLots(),Bid,3* Point, Blue) ; 
            }      
               
          } 
      }
   }
} 
    

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