MacdPatternTraderv03

Author: FORTRADER.RU
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself
Indicators Used
MACD HistogramMoving average indicator
1 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
MacdPatternTraderv03
//+------------------------------------------------------------------+
//|                                            MacdPatternTrader.mq4 |
//|                                                     FORTRADER.RU |
//|                                              http://FORTRADER.RU |
//+------------------------------------------------------------------+
 
/*

Îáðàáàòûâàåì ïàòòåðí ãîëîâà è ïëå÷è
 
Original description strategies:
http://www.unfx.ru/strategies_to_trade/strategies_134.php
 
Ïîäðîáíîå îïèñàíèå ïàðàìåòðîâ ñîâåòíèêà äîñòóïíî â íîìåðå æóðíàëà îò 23 Èþíÿ, 
ïðåäëîæåíèÿ è îòçûâû ìû áóäåì ðàäû âèäåòü â íàøåé ýëåêòðîïî÷òå: letters@fortrader.ru
http://www.fortrader.ru/arhiv.php
 
A detailed description of the parameters adviser available issue of the journal dated Iune 23, 
suggestions and feedback we will be glad to see in our e-mail: letters@fortrader.ru
http://www.fortrader.ru/arhiv.php
 
Looking for an interpreter for the English version of the magazine on partnership.
 
 
*/
 
#property copyright "FORTRADER.RU"
#property link      "http://FORTRADER.RU"
 
extern int stoplossbars = 6;
extern int takeprofitbars = 20;
extern int otstup = 10; 
extern int lowema=5;
extern int fastema=13;

extern int sum_bars_bup=10;
extern double maxur=0.0045;
extern double maxur1=0.0030;
extern double minur=-0.0045;
extern double minur1=-0.0030;
 
extern string x="Íàñòðîéêè MA:";
extern  int perema1=7;
extern  int perema2=21;
extern  int persma3=98;
extern  int perema4=365;
 
extern double Lots=1;
 
int buy,sell;int nummodb,nummods;int flaglot,bars_bup;
int start()
  {   
 
      AOPattern(lowema,fastema,maxur,minur);
      ActivePosManager(perema1,perema2,persma3,perema4);
 
   return(0);
  }
int aop_maxur,aop_minur,aop_oksell,aop_okbuy,S,S1,H,H2,bS,bS1,bH,bH2,stops,stops1,sstops,sstops1;
double max1,max2,max3,min1,min2,min3;
int AOPattern(double FastEMA,double SlowEMA,double maxur,double minur)
{
   //çàãðóæàåì èíäèêàòîðû
   double macdcurr =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,1);
   double macdlast =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,2);
   double macdlast3 =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,3);
   
   

   if(macdcurr>maxur1){S=1;bars_bup=bars_bup+1;}
    
   if(S==1 && macdcurr<macdlast && macdlast>macdlast3 && macdlast>max1 && stops==0){max1=macdlast;Print("m1"+max1);}
   
   if(max1>0 &&macdcurr<maxur){stops=1;}
   
   if(macdcurr<maxur1 ){stops=0;max1=0;S=0;}
   
   /*******************************************************************************************/
   
    if(stops==1 && macdcurr>maxur&& macdcurr<macdlast && macdlast>macdlast3 && macdlast>max1 && macdlast>max2 && stops1==0){max2=macdlast;Print("m2"+max2);} 
    
    if(max2>0 &&macdcurr<maxur){stops1=1;}
   
   if(macdcurr<maxur1 ){stops1=0;max2=0;}
   
   /*******************************************************************************************************************/
   
   if(stops1==1 && macdcurr<maxur&& macdlast<maxur&& macdlast3<maxur&&  macdcurr<macdlast && macdlast>macdlast3 && macdlast<max2 && aop_oksell==0){max3=macdlast;Print("m3"+max3);aop_oksell=1;} 

   if(macdcurr<maxur1 ){aop_oksell=0;}

   /*******************************************************************************************************************/
   
   if(aop_oksell==1 /*&& max3<max2 && max3<max1*/)
   {max1=0;max2=0;max3=0;
      OrderSend(Symbol(),OP_SELL,Lots,Bid,3,StopLoss(0),TakeProfit(0),"FORTRADER.RU",16385,0,Red);
      aop_oksell=0;
      aop_maxur=0;
      nummods=0;
      flaglot=0;
      bars_bup=0;
   }
   
   
   if(macdcurr<minur){bS=1;}
    
   if(bS==1 && macdcurr>macdlast && macdlast<macdlast3 && macdlast<min1 && sstops==0){min1=macdlast;Print("mi1"+min1);}
   
   if(min1<0 &&macdcurr>minur){sstops=1;bS=0;}
   
   if(macdcurr>minur1 ){sstops=0;min1=0;bS=0;}
   
   /*******************************************************************************************/
   
    if(sstops==1 && macdcurr<maxur&& macdcurr>macdlast && macdlast<macdlast3 && macdlast<min1 && macdlast<min2 && sstops1==0){min2=macdlast;Print("mi2"+min2);} 
    
    if(min2<0 &&macdcurr>minur){sstops1=1;sstops=0;}
   
   if(macdcurr>minur1 ){sstops1=0;min2=0;}
   
   /*******************************************************************************************************************/
   
   if(sstops1==1 && macdcurr>minur&& macdlast>minur&& macdlast3>minur&&  macdcurr>macdlast && macdlast<macdlast3 && macdlast>min2 && aop_okbuy==0){min3=macdlast;Print("mi3"+min3);aop_okbuy=1;sstops1=0;} 

   if(macdcurr>maxur1 ){aop_okbuy=0;}

   
   
   if(aop_okbuy==1 )
   {
       OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss(1),TakeProfit(1),"FORTRADER.RU",16385,0,Red);
      aop_okbuy=0;
      aop_minur=0;
      nummodb=0;
      flaglot=0;
      sstops1=0;
      min1=0;
      min2=0;
      min3=0;
   }
 
}
 
double StopLoss(int type)
{double stoploss;
if(type==0)
{
  stoploss=High[iHighest(NULL,0,MODE_HIGH,stoplossbars,1)]+otstup*Point;
 return(stoploss);
}
if(type==1)
{
  stoploss=Low[iLowest(NULL,0,MODE_LOW,stoplossbars,1)]-otstup*Point;
 return(stoploss);
}
 
}
 
double TakeProfit(int type)
{ int x=0,stop=0;double takeprofit;
  
  if(type==0)
   {
   while(stop==0)
         {
           takeprofit =Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x)];
          if(takeprofit>Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x+takeprofitbars)])
            {
            takeprofit =Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x+takeprofitbars)];
            x=x+takeprofitbars;
            }
          else
            {
             stop=1;return(takeprofit);
            }
         }
   }
   
   if(type==1)
   {
   while(stop==0)
         {
           takeprofit =High[iHighest(NULL,0,MODE_HIGH,takeprofitbars,x)];
          if(takeprofit<High[iHighest(NULL,0,MODE_HIGH,takeprofitbars,x+takeprofitbars)])
            {
            takeprofit =High[iHighest(NULL,0,MODE_HIGH,takeprofitbars,x+takeprofitbars)];
            x=x+takeprofitbars;
            }
          else
            {
             stop=1;return(takeprofit);
            }
         }
   }
                
}
 
int  ActivePosManager(int perema1, int perema2, int persma3, int perema4)
{
   double ema1 =iMA(NULL,0,perema1,0,MODE_EMA,PRICE_CLOSE,1);
    double ema2 =iMA(NULL,0,perema2,0,MODE_EMA,PRICE_CLOSE,1);
     double sma1 =iMA(NULL,0,persma3,0,MODE_SMA,PRICE_CLOSE,1);
      double ema3 =iMA(NULL,0,perema4,0,MODE_EMA,PRICE_CLOSE,1);
 
   for( int i=0;i<OrdersTotal();i++)
      {
              OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
              if(OrderType()==OP_BUY && OrderProfit()>5 && Close[1]>ema2 && nummodb==0)
              {  
                 OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/3,2),Bid,3,Violet); 
                 nummodb++;
              }
              
                 if(OrderType()==OP_BUY && OrderProfit()>5 && High[1]>(sma1+ema3)/2 && nummodb==1)
              {  
                 OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),Bid,3,Violet); 
                 nummodb++;
              }
              
                if(OrderType()==OP_SELL && OrderProfit()>5 && Close[1]<ema2 && nummods==0)
              {  
                 OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/3,2),Ask,3,Violet); 
                 nummods++;
              }
              
                   if(OrderType()==OP_SELL && OrderProfit()>5 && Low[1]<(sma1+ema3)/2 && nummods==1)
              {  
                 OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),Ask,3,Violet); 
                 nummods++;
              }
      }
 
}

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