MTF Code Issue

 

Hi,

I was chatting with a developer and he has told me that MT4 has problems using multiple time frames in an EA.

I use the following to identify forward trend and then look for lower time frame entry points:

         StDev=iStdDev(NULL,PERIOD_D1,10,0,MODE_EMA,PRICE_MEDIAN,index+1);
         StDevBack1=iStdDev(NULL,PERIOD_D1,10,0,MODE_EMA,PRICE_MEDIAN,index+2);
         StDevBack2=iStdDev(NULL,PERIOD_D1,10,0,MODE_EMA,PRICE_MEDIAN,index+3);
         StDevBack3=iStdDev(NULL,PERIOD_D1,10,0,MODE_EMA,PRICE_MEDIAN,index+4);
         StDevAverage=(StDev+StDevBack1+StDevBack2+StDevBack3)/4;     
         //---End Daily Trend                
         //---Price
         DailyPrice=(iHigh(NULL,PERIOD_D1,index+1)+iLow(NULL,PERIOD_D1,index+1))/2;
         DailyPrice1=(iHigh(NULL,PERIOD_D1,index+2)+iLow(NULL,PERIOD_D1,index+2))/2;
         DailyPrice2=(iHigh(NULL,PERIOD_D1,index+3)+iLow(NULL,PERIOD_D1,index+3))/2;  

         SmaH4200=iMA(NULL,PERIOD_H4,200,0,MODE_SMA,PRICE_MEDIAN,index+1);

         Price=(High[index+1]+Low[index+1])/2;(on 1H chart)

if(DailyPrice>DailyPrice1 && DailyPrice1>DailyPrice2 && StDev>StDevAverage)
         if(Price>SmaH4200)

          then further if parameters on lower time frames

Is it true that EAs on MT4 have problems operating longer to shorter time frame parameters when producing a trade signal?

Any guidance would be helpful ??

Regards Mike

 
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. On MT4: Unless the current chart is the specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

  3.  DailyPrice=(iHigh(NULL,PERIOD_D1,index+1)+iLow(NULL,PERIOD_D1,index+1))/2;
    
             SmaH4200=iMA(NULL,PERIOD_H4,200,0,MODE_SMA,PRICE_MEDIAN,index+1);
    
     Price=(High[index+1]+Low[index+1])/2;(on 1H chart)
    You don't show your code's context. We have no idea what index is, but it can't be a shift for the D1, a shift for the H4, and a shift for the chart period (H1 according to your comment) at the same time.
              Don't mix apples and oranges.
 

int index = 0;

I have added the same post to the automated trading section.

My question is this: 

Is it true that EAs on MT4 have problems operating longer to shorter time frame parameters when producing a trade signal?

 
Michael Green:

int index = 0;

I have added the same post to the automated trading section.

Is it true that EAs on MT4 have problems operating longer to shorter time frame parameters when producing a trade signal?

  1. If it isn't zero, then index+1 makes no sense: #1 № 3
  2. What part of asking MT4 questions in the MT4 section was unclear? Your post was moved. Now you broke another rule. Don't double post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  3. Your question was answered: #1 № 2