Need Help on this?

 

Hi!

I have written EA using 2 strategy. first strategy i use 30 minutes and 2nd strategy i use 4hrs and for JPY pairs.

I run EA with 30min tf. for second strategy i used BB indicator at 4hr timeframe and once per bar.

I validate the below conditions once per bar. problom is EA check every 30 minute candle, bcoz i run ea by 30m timeframe. how to make this ea to run second strategy with 4hr timeframe. please give me support.

  if (Close[2] > iBands(NULL, PERIOD_H4,20,2.0,0,PRICE_CLOSE,MODE_UPPER,2))
 
sheriffonline:

Hi!

I have written EA using 2 strategy. first strategy i use 30 minutes and 2nd strategy i use 4hrs and for JPY pairs.

I run EA with 30min tf. for second strategy i used BB indicator at 4hr timeframe and once per bar.

I validate the below conditions once per bar. problom is EA check every 30 minute candle, bcoz i run ea by 30m timeframe. how to make this ea to run second strategy with 4hr timeframe. please give me support.

How do you do this ? do the same but for the H4 timeframe . . .
 
sheriffonline:

Hi!

I have written EA using 2 strategy. first strategy i use 30 minutes and 2nd strategy i use 4hrs and for JPY pairs.

I run EA with 30min tf. for second strategy i used BB indicator at 4hr timeframe and once per bar.

I validate the below conditions once per bar. problom is EA check every 30 minute candle, bcoz i run ea by 30m timeframe. how to make this ea to run second strategy with 4hr timeframe. please give me support.

  if (Close[2] > iBands(NULL, PERIOD_H4,20,2.0,0,PRICE_CLOSE,MODE_UPPER,2)) 

Close[2] is a value from your 30M chart

do you want that value or is it you needed a value from bar2 H4 chart to compare ??

if you check first the time candle 0 H4 and you check newbar according to that candletime ....

 
sheriffonline:

Hi!

I have written EA using 2 strategy. first strategy i use 30 minutes and 2nd strategy i use 4hrs and for JPY pairs.

I run EA with 30min tf. for second strategy i used BB indicator at 4hr timeframe and once per bar.

I validate the below conditions once per bar. problom is EA check every 30 minute candle, bcoz i run ea by 30m timeframe. how to make this ea to run second strategy with 4hr timeframe. please give me support.

How do you check "once per bar" ?
 
   datetime Bartime; 
   if (BarTime < Time[0])
{
    // we have a new bar opened
    BarTime = Time[0]; // keep the new bar open time

}
 
deVries:

Close[2] is a value from your 30M chart

do you want that value or is it you needed a value from bar2 H4 chart to compare ??

if you check first the time candle 0 H4 and you check newbar according to that candletime ....

Yes.currently it takes value value of Close[2] at 30m tf. but i need to take value Close[2] for 4hr tf applying 30m chart.
 
RaptorUK:
How do you do this ? do the same but for the H4 timeframe . . .


   datetime Bartime; 
   if (BarTime < Time[0])
{
    // we have a new bar opened
    BarTime = Time[0]; // keep the new bar open time

}
 
sheriffonline:

So if you want your condition about H4 to be run only once per H4 bar, you have to use anothor method. What you post here only detect a new bar on current chart. Use iTime() instead of Time[].

 
   datetime Bartime; 
   if (BarTime < Time[0]){ BarTime = Time[0]; // keep the new bar open time
     :
   }
Won't work. as Bartime will ALWAYS be zero. Code runs every tick. Search once per bar and learn the difference.
 
angevoyageur:

So if you want your condition about H4 to be run only once per H4 bar, you have to use anothor method. What you post here only detect a new bar on current chart. Use iTime() instead of Time[].


Changed code changing iTime(). works fine now.

Thanks for your support angevoyageur,RaptorUK,WHRoeder



datetime Bartime;
if (BarTime < iTime(NULL,PERIOD_H4,0))
{
    // we have a new bar opened
    BarTime = iTime(NULL,PERIOD_H4,0); // keep the new bar open time
    
}


if (iClose(NULL,PERID_H4,2) > iBands(NULL, PERIOD_H4,20,2.0,0,PRICE_CLOSE,MODE_UPPER,2))
 
Are you hard of reading? Won't work as Bartime will ALWAYS be zero. Code runs every tick. Search once per bar and learn the difference.