Reversal_EA_MT4

Author: Copyright � 2007, Metex Investments Inc.
Orders Execution
It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reachedChecks for the total of open orders
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
35.00 %
Total Trades 524
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -18.42
Gross Profit 5156.00
Gross Loss -14807.00
Total Net Profit -9651.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
27.00 %
Total Trades 395
Won Trades 261
Lost trades 134
Win Rate 0.66 %
Expected payoff -23.44
Gross Profit 3401.00
Gross Loss -12658.00
Total Net Profit -9257.00
-100%
-50%
0%
50%
100%
Reversal_EA_MT4
//+------------------------------------------------------------------+
//|                                              Reversal_EA_MT4.mq4 |
//|                         Copyright © 2007, Metex Investments Inc. |
//|                                       http://www.metexinvest.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Metex Investments Inc."
#property link      "http://www.metexinvest.com"

#include <stdlib.mqh>

//+------------------------------------------------------------------+
//| Common External variables                                        |
//+------------------------------------------------------------------+
extern double Lots = 1.00;
extern double StopLoss = 99.00;
extern double TakeProfit = 15.00;
extern double TrailingStop = 7.00;

//+------------------------------------------------------------------+
//| External variables                                               |
//+------------------------------------------------------------------+
extern double Slippage = 3;
extern double risklevel = 3;

//+------------------------------------------------------------------+
//| Special Convertion Functions                                     |
//+------------------------------------------------------------------+

int LastTradeTime;

bool MOrderModify( int ticket, double price, double stoploss, double 
takeprofit, datetime expiration, color arrow_color=CLR_NONE)
{
  LastTradeTime = TimeCurrent();
  price = MathRound(price*10000)/10000;
  stoploss = MathRound(stoploss*10000)/10000;
  takeprofit = MathRound(takeprofit*10000)/10000;
  return ( OrderModify( ticket, price, stoploss, takeprofit, 
expiration, arrow_color) );
}

int MOrderSend( string symbol, int cmd, double volume, double price, 
int slippage, double stoploss, double takeprofit, string comment="", int 
magic=0, datetime expiration=0, color arrow_color=CLR_NONE)
{
  LastTradeTime = TimeCurrent();
  price = MathRound(price*10000)/10000;
  stoploss = MathRound(stoploss*10000)/10000;
  takeprofit = MathRound(takeprofit*10000)/10000;
  return ( OrderSend( symbol, cmd, volume, price, slippage, stoploss, 
takeprofit, comment, magic, expiration, arrow_color ) );
}

int OrderValueTicket(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderTicket());
}

int OrderValueType(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderType());
}

double OrderValueOpenPrice(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderOpenPrice());
}

double OrderValueStopLoss(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderStopLoss());
}

double OrderValueTakeProfit(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderTakeProfit());
}

string OrderValueSymbol(int index)
{
  OrderSelect(index, SELECT_BY_POS);
  return(OrderSymbol());
}

//+------------------------------------------------------------------+
//| End                                                              |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+

int init()
{
   return(0);
}
int start()
{
//+------------------------------------------------------------------+
//| Local variables                                                  |
//+------------------------------------------------------------------+
double temp = 0;
double lotss = 0;
int i = 0;
double OpenTrades = 0;
int cnt = 0;

lotss=MathCeil((AccountBalance()*risklevel*Ask)/100000);

if ((Open[2]>Close[2] && Close[1]>Open[1] && Open[2]-Close[2]>0 && Close[1]-Open[1]>1*Point) )
  
  {
 OpenTrades = 0;
  	for(i =1;i <=OrdersTotal();i ++){
        if( OrderValueSymbol(i) == Symbol() ) 
             OpenTrades++;
  		}
   if( OpenTrades<1 ) 
	    {
MOrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,"",16384,0,Blue);
	    }
  }

if( TrailingStop>0 ) 
{
for(cnt=1;cnt<=OrdersTotal();cnt++){
   if( OrderValueType(cnt) == OP_BUY && OrderValueSymbol(cnt) == Symbol() ) 
     {
      if( (Bid-OrderValueOpenPrice(cnt))>(TrailingStop*Point) ) 
      	{
         if( OrderValueStopLoss(cnt)<(Bid-TrailingStop*Point) ) 
           {
            
MOrderModify(OrderValueTicket(cnt),OrderValueOpenPrice(cnt),         
Bid-TrailingStop*Point,OrderValueTakeProfit(cnt),0,Blue);
            return(0); 
           }
        }
     }
  }

if (Close[2]>Open[2] && Open[1]>Close[1] && Close[2]-Open[2]>0 && Open[1]-Close[1]>1*Point) 
 
  {
	 OpenTrades = 0;
  	for(i =1;i <=OrdersTotal();i ++){
        if( OrderValueSymbol(i) == Symbol() ) 
             OpenTrades++;
  		}
  		
   if( OpenTrades<1 ) 
    	{
MOrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,"",16384,0,Red);
	    }
  }

   for(cnt=1;cnt<=OrdersTotal();cnt++){
     if( OrderValueType(cnt) == OP_SELL && OrderValueSymbol(cnt) == Symbol() )    
     {
      if( (OrderValueOpenPrice(cnt)-Ask)>(TrailingStop*Point) ) 
     	{
         if( OrderValueStopLoss(cnt)>(Ask+TrailingStop*Point) ||
            OrderValueStopLoss(cnt) == 0 ) 
           {
            
MOrderModify(OrderValueTicket(cnt),OrderValueOpenPrice(cnt),Ask+TrailingStop*Point,OrderValueTakeProfit(cnt),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 ---