Author: emsjoflo
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
MACD HistogramMovement directional index
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
145.00 %
Total Trades 20
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 2.18
Gross Profit 139.60
Gross Loss -96.00
Total Net Profit 43.60
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
105.00 %
Total Trades 19
Won Trades 2
Lost trades 17
Win Rate 0.11 %
Expected payoff 0.27
Gross Profit 104.30
Gross Loss -99.20
Total Net Profit 5.10
-100%
-50%
0%
50%
100%
macd_adx
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                     macd_adx.mq4 |
//|                                                     emsjoflo     |
//+------------------------------------------------------------------+
#property copyright "emsjoflo"
//If you make money with this expert, please let me know emsjoflo@yaho.com
// I also accept donations ;)
//It is only a bare-bones expert with no safeties.  Let me know if you want me to modify it for your purposes.



//---- input parameters
extern int       DMILevels=25;
extern int       ADXLevel=15; 
extern double    lots=0.1;
extern int       StopLoss=60 ;
extern int       Slippage=4;
//I'm not sure where the best place to define variables is...so I put them here and it works
double   macd,macdsig,ADX,PlusDI,MinusDI,ADXpast,PlusDIpast,MinusDIpast,SL;
int      i, buys, sells;
datetime lasttradetime;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
//get moving average info
macd=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
macdsig=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
ADX=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,1);
PlusDI=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);
MinusDI=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);
ADXpast=iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,2);
PlusDIpast=iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,2);
MinusDIpast=iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,2);


//check for open orders first 
if (OrdersTotal()>0)
   {
   buys=0;
   sells=0;
   for (i=0;i<OrdersTotal();i++)
      {
      OrderSelect(i,SELECT_BY_POS);
      if (OrderSymbol()==Symbol())
         {
         if (OrderType()== OP_BUY)
            {
            if (macd > 0 && macdsig > 0 && macd < macdsig) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Orange);
            else buys++;
            }
         if (OrderType()== OP_SELL) 
            {
            if (macd < 0 && macdsig < 0 && macd > macdsig) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Lime);
            else sells++;
            }
         }
      }
   }
if (ADX > ADXpast && ADX> ADXLevel && PlusDI > MinusDI && PlusDI > PlusDIpast && PlusDI > DMILevels && macd < 0 && macdsig < 0 && macd > macdsig && buys == 0 && (CurTime()-lasttradetime)/60 > Period())
   {
   //Print("Buy condition");
   if (StopLoss >1) SL=Ask-StopLoss*Point;
   OrderSend(Symbol(),OP_BUY,lots,Ask,Slippage,SL,0,"macd_adx",123,0,Lime);
   lasttradetime=CurTime();
   
   }
if (ADX > ADXpast && ADX> ADXLevel && PlusDI < MinusDI && MinusDI > MinusDIpast && MinusDI > DMILevels && macd > 0 && macdsig > 0 && macd < macdsig && sells ==0 && (CurTime()-lasttradetime)/60 > Period())
   {
   //Print ("Sell condition");
   if (StopLoss>1) SL=Bid+StopLoss*Point;
   OrderSend(Symbol(),OP_SELL,lots,Bid,Slippage,SL,0,"macd_adx",123,0,Red);
   }   
   
   
   
//----
   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 ---