itime problem

 

Hi All

i read in Forum for functions of iTime() and did not find what is needed.

if somebody can help

i have the EA starts the trade on opening of each Bar, 4Hour chart, 00:00, 04:00,...............

i want to open trade one minute or 30 seconds after new Bar starts

( the reason is to have some time more waiting for the indicator to have its new data, and then get order for sell or buy)

means at 00:01, 04:01,..........

please what to write for iTime(........................) ?

Thanks

 
samirgham:

Hi All

i read in Forum for functions of iTime() and did not find what is needed.

if somebody can help

i have the EA starts the trade on opening of each Bar, 4Hour chart, 00:00, 04:00,...............

i want to open trade one minute or 30 seconds after new Bar starts

( the reason is to have some time more waiting for the indicator to have its new data, and then get order for sell or buy)

means at 00:01, 04:01,..........

please what to write for iTime(........................) ?

Thanks

Hi,

I will code something like that : (I am not checking syntax, it's just to give you ideas) (I took the 1 minute option)

if ( TimeHour(iTime(curreny,PERIOD_H4,0) == TimeHour(CurrentTime()) // it's a new H4 bar regarding the hour of the current time

&& TimeMinute(CurrentTime()) == 1) // so now, just check the minutes

{ opening time is ok

}

and it will be ok until the next minute of the CurrentTime()...

 
Jacques366 wrote >>

Hi,

I will code something like that : (I am not checking syntax, it's just to give you ideas) (I took the 1 minute option)

if ( TimeHour(iTime(curreny,PERIOD_H4,0) == TimeHour(CurrentTime()) // it's a new H4 bar regarding the hour of the current time

&& TimeMinute(CurrentTime()) == 1) // so now, just check the minutes

{ opening time is ok

}

and it will be ok for 1 minute...

Hi Jacques

i tried ( using 5 minutes chart, easier to follow)

if ((TimeHour(iTime(0,PERIOD_M5,0)))==(TimeHour(CurTime()))&&(TimeMinute(CurTime())==1))

it stopped giving buy or sell orders

i also made changements, still open trades on Bar opening time immediately.

question:

Do you have good experience in coding or in modifying the EA to give better results?

Thanks

 
samirgham:

Hi Jacques

i tried ( using 5 minutes chart, easier to follow)

if ((TimeHour(iTime(0,PERIOD_M5,0)))==(TimeHour(CurTime()))&&(TimeMinute(CurTime())==1))

it stopped giving buy or sell orders

i also made changements, still open trades on Bar opening time immediately.

question:

Do you have good experience in coding or in modifying the EA to give better results?

Thanks

LOL

re-read your instruction carefully : if ( (TimeHour(iTime(0,PERIOD_M5,0))) == ( TimeHour(CurTime())) && (TimeMinute(CurTime())==1) )

because your want an hour to be equal to a logical operation result (the &&) and one of its part is one hour! (must be true or false)...... I presume you made some mistake while writing this.

What are you doing with M5 when you work on H4 (refering your first post) ?

 
Jacques366 wrote >>

LOL

re-read your instruction carefully : if ( (TimeHour(iTime(0,PERIOD_M5,0))) == ( TimeHour(CurTime())) && (TimeMinute(CurTime())==1) )

because your want an hour to be equal to a logical operation result (the &&) and one of its part is one hour! (must be true or false)...... I presume you made some mistake while writing this.

What are you doing with M5 when you work on H4 (refering your first post) ?

the reason i tried M5 quicker to get result, not to wait 4Hours,

i will fix, and let you know.

the question i asked about you has no relation about iTime function.

just to know if you willing to help improving the EA, because getting good results till midlle of year, the starts to go down

to see if you able to improve or to see where is the problem, or the market is against the EA these days. ( i put on Demo yesterday, no profits till now... this reason i ask!!!)

i will post graphs of strategy tester later, if you want.

Thanks

 
samirgham:

the reason i tried M5 quicker to get result, not to wait 4Hours,

i will fix, and let you know.

the question i asked about you has no relation about iTime function.

just to know if you willing to help improving the EA, because getting good results till midlle of year, the starts to go down

to see if you able to improve or to see where is the problem, or the market is against the EA these days. ( i put on Demo yesterday, no profits till now... this reason i ask!!!)

i will post graphs of strategy tester later, if you want.

Thanks

There are a lot of strategies that are profitable on a period and then begins to loose what they have won. You have to build one strategy that is profitable and sustainable (profitable over a few years).

Try to analyse why it's not giving you the result you wish you have and then find a solution.It's not easy, you will have to keep it winning when it wins and not loosing too much when it looses... something like that or somthing else.

Of course you can use this forum to get help of any kind to build your EA. Do not hesitate to read the articles too, they might give you some ideas...

Welcome to good sustainable profitable EA building and good luck!

 
samirgham:

Hi All

i read in Forum for functions of iTime() and did not find what is needed.

if somebody can help

i have the EA starts the trade on opening of each Bar, 4Hour chart, 00:00, 04:00,...............

i want to open trade one minute or 30 seconds after new Bar starts

( the reason is to have some time more waiting for the indicator to have its new data, and then get order for sell or buy)

means at 00:01, 04:01,..........

please what to write for iTime(........................) ?

Thanks

I don't know if this function could help you but anyway could be useful:


extern int Period = PERIOD_M30; // Choose the time frame in this example de ea works only after a new 30 min bar is started


if(! Operate)

{
Operate = NewBar(Periodo); // Check if is still the same bar
}


if(Operate) { // The bar is new

Sleep(30000); // if you need to start after 30 seconds

//Trade or do something

Operate = false; // Lock the system until a new bar start

}


bool NewBar(int frame)

{
static int BarTime = 0;
if(BarTime != iTime(Symbol(),frame,0))
{
BarTime = iTime(Symbol(),frame,0);
return(true);
}
else
{
return(false);
}
}
 
samirgham wrote >>

Hi All

i read in Forum for functions of iTime() and did not find what is needed.

if somebody can help

i have the EA starts the trade on opening of each Bar, 4Hour chart, 00:00, 04:00,...............

i want to open trade one minute or 30 seconds after new Bar starts

( the reason is to have some time more waiting for the indicator to have its new data, and then get order for sell or buy)

means at 00:01, 04:01,..........

please what to write for iTime(........................) ?

Thanks

grandemario
wrote
>>

I don't know if this function could help you but anyway could be useful:

extern int Period = PERIOD_M30; // Choose the time frame in this example de ea works only after a new 30 min bar is started

if(! Operate)

{
Operate = NewBar(Periodo); // Check if is still the same bar
}

if(Operate) { // The bar is new

Sleep(30000); // if you need to start after 30 seconds

//Trade or do something

Operate = false; // Lock the system until a new bar start

}

bool NewBar(int frame)

{
static int BarTime = 0;
if(BarTime != iTime(Symbol(),frame,0))
{
BarTime = iTime(Symbol(),frame,0);
return(true);
}
else
{
return(false);
}
}

Hi Mario

thanks for your help

myself, i don't like to use sleep function, because it re-compile the EA and starts trading from begining, specially if it is placed before Openorders.

Also, i don't have problem with trading on new Bar, i trade once per Bar and close end of Bar as one of conditions.

i just want to to delay opening of the trade 1 minute after new Bar starts, better to have signal confirmation from indicator.

tomorrow i will try what Jacques said, now it is night and the Day finished!!!

Thanks

Reason: