# Need Help on this?

7310

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))`
Moderator
18018

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

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

Moderator
31599

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" ?
7310

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

}```
7310

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

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

}```
Moderator
31599

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[].

15051

```   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.
7310

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.

```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))```
15051

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