Experts: Multi Time Frame Trader - page 2

 

Hi,

it's nice idea. I was watching it. Seems may help STOP orders with some time delletion not catched orders.

 

Thank you for this indicator, c0d3. I really enjoy it. I have one question about the EA, however.

Whenever I run it on even 1 pair, it consumes memory continuously, until the machine locks up. The indicator itself, when attached to charts, doesn't do that. Is there an explanation/fix/workaround for this?


Thanks in advance.

--Cody

 

Thanks for the EA, I really like your ideas. ...and posting the links for background.

When I ran the backtest overnight for a time-frame of a month, it never finished. Could you give some simplified

instructions/suggestions for backtesting?

 

Hi c0d3,

I still cant get this EA to run, either in backtesting or forward testing, it loops, loading and unloading its data (Indicator data). I have tried as suggested below to eliminate Timeframes from the code but with the same results. One by one to the minimum, with no change .

Do you have a solution?

What are the parameters passed to and from this Indicator, and their types?

Thanks c0d3.

Micky

 
cody_r:

Thank you for this indicator, c0d3. I really enjoy it. I have one question about the EA, however.

Whenever I run it on even 1 pair, it consumes memory continuously, until the machine locks up. The indicator itself, when attached to charts, doesn't do that. Is there an explanation/fix/workaround for this?


Thanks in advance.

--Cody

There is a way around it, and the time frame entries is what the problem is, the EA is using 1M, 5M and 1H charts, since there is new data every tick of everyminute, the EA is continuously running, by loading and unloading the indicator. The way out is to program the EA for different time frames for entry, like 15m, 30m, and 4H

 
Soquell:

Thanks for the EA, I really like your ideas. ...and posting the links for background.

When I ran the backtest overnight for a time-frame of a month, it never finished. Could you give some simplified

instructions/suggestions for backtesting?

I'm not sure how backtesting works on this since it is using multiple time frames for entries. I did not do any type of backtesting on this EA, only forward testing, and it is breaking even. It looses many times, and then regains it back, and just keeps on loosing and regaining, hence the breakeven.

 
Micky52:

Hi c0d3,

I still cant get this EA to run, either in backtesting or forward testing, it loops, loading and unloading its data (Indicator data). I have tried as suggested below to eliminate Timeframes from the code but with the same results. One by one to the minimum, with no change .

Do you have a solution?

What are the parameters passed to and from this Indicator, and their types?

Thanks c0d3.

Micky

You might of messed something up in the code?


Try downloading the original, make sure the indicator is in the indicator folder, and run the EA again, and make sure EA is allowed to trade in your MT4 settings.

 

LinRegrBuf is a great piece of code, i was wondering if anyone thought it would be possible to write code that looked not only for trend channels, but Wedges, triangles, pennants, Etc. Basically, an MQL4 indicator that showed Chart Patterns. I Haven't had much luck finding anything like this so far.


Thanks,


-E-

 
I've made some adjustments so the EA will scan the indicator once per bar, at bar open only. Please, use it on M1 charts so it'll be executed every minute.

The changes have been performed so the EA will not scan the indicator values on every tick, therefore overloading the CPU when attached to several pairs.

I've been testing it for 2 days and it's working all right in 6 pairs. It's been configured to work with H1, M5 and M1 time-frames.

Thanks.

//+------------------------------------------------------------------+
//|                                      Multi Time-Frame Trader.mq4 |
//|                                       korostelev.andre@gmail.com |
//|                                                                  |
//|                                  Changes performed by beto21_cwb |
//|              The EA will scan the indicator once per M1 bar only |
//|    instead of on every tick. This way CPU overloading is avoided |
//|         when runnng it on several pairs. Attach it to a M1 chart |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "korostelev.andre@gmail.com"
extern bool trade=true;
extern int barstocount=50;
extern double lots=0.1;
extern int slippage=2;
extern int magicnumber=11;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
if(trade==true)
{
  static datetime tmp;
 
  if (tmp!= Time[0])
  {
    tmp =  Time[0];
         
   //M1
   double M1_resistance=iCustom(NULL,PERIOD_M1,"!LinRegrBuf","true",barstocount,2,0);
   double M1_resistance_p=iCustom(NULL,PERIOD_M1,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double M1_line=iCustom(NULL,PERIOD_M1,"!LinRegrBuf","true",barstocount,0,0);
   double M1_support=iCustom(NULL,PERIOD_M1,"!LinRegrBuf","true",barstocount,1,0);
   double slopeM1=((M1_resistance-M1_resistance_p)/barstocount)/Point; 
   
   //M5
   double M5_resistance=iCustom(NULL,PERIOD_M5,"!LinRegrBuf","true",barstocount,2,0);
   double M5_resistance_p=iCustom(NULL,PERIOD_M5,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double M5_line=iCustom(NULL,PERIOD_M5,"!LinRegrBuf","true",barstocount,0,0);
   double M5_support=iCustom(NULL,PERIOD_M5,"!LinRegrBuf","true",barstocount,1,0);
   double slopeM5=((M5_resistance-M5_resistance_p)/barstocount)/Point;
   //H1
   double H1_resistance=iCustom(NULL,PERIOD_H1,"!LinRegrBuf","true",barstocount,2,0);
   double H1_resistance_p=iCustom(NULL,PERIOD_H1,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double H1_line=iCustom(NULL,PERIOD_H1,"!LinRegrBuf","true",barstocount,0,0);
   double H1_support=iCustom(NULL,PERIOD_H1,"!LinRegrBuf","true",barstocount,1,0);
   double slopeH1=((H1_resistance-H1_resistance_p)/barstocount)/Point; 
/*   
   //M15
   double M15_resistance=iCustom(NULL,PERIOD_M15,"!LinRegrBuf","true",barstocount,2,0);
   double M15_resistance_p=iCustom(NULL,PERIOD_M15,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double M15_line=iCustom(NULL,PERIOD_M15,"!LinRegrBuf","true",barstocount,0,0);
   double M15_support=iCustom(NULL,PERIOD_M15,"!LinRegrBuf","true",barstocount,1,0);
   double slopeM15=((M15_resistance-M15_resistance_p)/barstocount)/Point;
   
   //M30
   double M30_resistance=iCustom(NULL,PERIOD_M30,"!LinRegrBuf","true",barstocount,2,0);
   double M30_resistance_p=iCustom(NULL,PERIOD_M30,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double M30_line=iCustom(NULL,PERIOD_M30,"!LinRegrBuf","true",barstocount,0,0);
   double M30_support=iCustom(NULL,PERIOD_M30,"!LinRegrBuf","true",barstocount,1,0);
   double slopeM30=((M30_resistance-M30_resistance_p)/barstocount)/Point;   
   
   //H4 
   double H4_resistance=iCustom(NULL,PERIOD_H4,"!LinRegrBuf","true",barstocount,2,0);
   double H4_resistance_p=iCustom(NULL,PERIOD_H4,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double H4_line=iCustom(NULL,PERIOD_H4,"!LinRegrBuf","true",barstocount,0,0);
   double H4_support=iCustom(NULL,PERIOD_H4,"!LinRegrBuf","true",barstocount,1,0);
   double slopeH4=((H4_resistance-H4_resistance_p)/barstocount)/Point; 
   
   //D1
   double D1_resistance=iCustom(NULL,PERIOD_D1,"!LinRegrBuf","true",barstocount,2,0);
   double D1_resistance_p=iCustom(NULL,PERIOD_D1,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double D1_line=iCustom(NULL,PERIOD_D1,"!LinRegrBuf","true",barstocount,0,0);
   double D1_support=iCustom(NULL,PERIOD_D1,"!LinRegrBuf","true",barstocount,1,0);
   double slopeD1=((D1_resistance-D1_resistance_p)/barstocount)/Point;    
   
   //W1
   double W1_resistance=iCustom(NULL,PERIOD_W1,"!LinRegrBuf","true",barstocount,2,0);
   double W1_resistance_p=iCustom(NULL,PERIOD_W1,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double W1_line=iCustom(NULL,PERIOD_W1,"!LinRegrBuf","true",barstocount,0,0);
   double W1_support=iCustom(NULL,PERIOD_W1,"!LinRegrBuf","true",barstocount,1,0);
   double slopeW1=((W1_resistance-W1_resistance_p)/barstocount)/Point;     
   
   //MN1
   double MN1_resistance=iCustom(NULL,PERIOD_MN1,"!LinRegrBuf","true",barstocount,2,0);
   double MN1_resistance_p=iCustom(NULL,PERIOD_MN1,"!LinRegrBuf","true",barstocount,2,barstocount-1);
   double MN1_line=iCustom(NULL,PERIOD_MN1,"!LinRegrBuf","true",barstocount,0,0);
   double MN1_support=iCustom(NULL,PERIOD_MN1,"!LinRegrBuf","true",barstocount,1,0);
   double slopeMN1=((MN1_resistance-MN1_resistance_p)/barstocount)/Point;        
   
   //Alert(DoubleToStr(slopeM1,2)+" "+DoubleToStr(slopeM5,2)+" "+DoubleToStr(slopeM15,2)+" "+DoubleToStr(slopeM30,2)+" "+DoubleToStr(slopeH1,2));   
*/   
   
   Comment(
   "\n","M1  Slope | ",slopeM1,
   "\n","M5  Slope | ",slopeM5,
//   "\n","M15 Slope | ",slopeM15,
//   "\n","M30 Slope | ",slopeM30,
   "\n","H1  Slope | ",slopeH1);
//   "\n","H4  Slope | ",slopeH4,
//   "\n","D1  Slope | ",slopeD1,
//   "\n","W1  Slope | ",slopeW1,
//   "\n","MN1 Slope | ",slopeMN1);
  
  //SHORT ENTRY
  if(slopeH1<0 && IsTradeAllowed()==true)
  {
        bool shortopen=false;
        int ord_cnt1=OrdersTotal();
        for (int start1=0;start1<ord_cnt1;start1++)   
        {
           OrderSelect(start1, SELECT_BY_POS, MODE_TRADES);
           if(OrderMagicNumber()==magicnumber && OrderType()==OP_SELL)
              {shortopen=true;}
        }
  if(shortopen==false)
        {      
         double M5High=iHigh(Symbol(),PERIOD_M5,0);
         if(M5High>=M5_resistance)
              {
               double M1High=iHigh(Symbol(),PERIOD_M1,1);
               if(M1High>=M1_resistance)
                   {
                       double shortSL=(M5_resistance-M5_line)/2;
                          //if(slopeM15<0){lots=lots*2;}
                          //if(slopeM30<0){lots=lots*3;}
                          //if(slopeM15<0 && slopeM30<0){lots=lots*4;}
                       int shortticket=OrderSend(Symbol(),OP_SELL,lots,Bid,slippage,Bid+shortSL,M5_line,DoubleToStr(slopeM1,2)+" "+DoubleToStr(slopeM5,2)+" "+DoubleToStr(slopeH1,2),magicnumber,0,Green);
                          if(shortticket<0)
                            {
                             Comment("Short OrderSend failed with error #",GetLastError());
                             return(0);
                            }
                   }
              }
         }
  } 
 
  
  //LONG ENTRY
  if(slopeH1>0 && IsTradeAllowed()==true)
  {
        bool longopen=false;
        int ord_cnt=OrdersTotal();
        for (int start=0;start<ord_cnt;start++)   
        {
           OrderSelect(start, SELECT_BY_POS, MODE_TRADES);
           if(OrderMagicNumber()==magicnumber && OrderType()==OP_BUY)
              {longopen=true;}
        }
   if(longopen==false)
   {
     double M5Low=iLow(Symbol(),PERIOD_M5,0);
     if(M5Low<=M5_support)
       {
        double M1Low=iLow(Symbol(),PERIOD_M1,1);
        if(M1Low<=M1_support)
          { 
            double longSL=(M5_line-M5_support)/2;
                //if(slopeM15>0){lots=lots*2;}
                //if(slopeM30>0){lots=lots*3;}
                //if(slopeM15>0 && slopeM30>0){lots=lots*4;}
            int longticket=OrderSend(Symbol(),OP_BUY,lots,Ask,slippage,Ask-longSL,M5_line,DoubleToStr(slopeM1,2)+" "+DoubleToStr(slopeM5,2)+" "+DoubleToStr(slopeH1,2),magicnumber,0,Green);
        if(longticket<0)
           {
             Comment("Long OrderSend failed with error #",GetLastError());
             return(0);
           } 
          }
       }
   }
  }
   
   } // closes the if (tmp!= Time[0])   
   
}
//----
   return(0);
}
//+------------------------------------------------------------------+

 

Hello,

I attached the EA on several charts (either one by one  or Simultaneously). All slopes are always ZERO for me. the zero didn't change for hours, neither + nor negative.

whats wrong with that?

Best regards