I think he needs more than that.
OK
static datetime lastbarstart=0; if (Time[1] != lastbaarstart) // this is true for the first tick of a new bar { Print("We have a new bar . . ."); lastbaarstart = Time[1]; }
Great solution, thx for help,
one more question, what if i want to buy/sell on close bar ? Is't any way to detect last ticks without Minute()==59? Maybe it's better to use minutes from windows clock not trending clock and when minute is 59 then buy/sell? What do you think ? Someone try ?
Great solution, thx for help,
one more question, what if i want to buy/sell on close bar ? Is't any way to detect last ticks without Minute()==59? Maybe it's better to use minutes from windows clock not trending clock and when minute is 59 then buy/sell? What do you think ? Someone try ?
You cannot detect the close of a bar . . . you detect the open of the next. Until you get a tick nothing happens, if there is no tick on H1 from 14:59:55 until 15:00:05 technically speaking the bar has closed but you don't know it has until a tick arrives.
You need to keep in mind that start() is tick driven . . .
Great solution, thx for help,
one more question, what if i want to buy/sell on close bar ? Is't any way to detect last ticks without Minute()==59? Maybe it's better to use minutes from windows clock not trending clock and when minute is 59 then buy/sell? What do you think ? Someone try ?
Do not use the Windows system clock for trading. Always use server time.
You can always trade on the next tick after any arbitrary time in hours, minutes and seconds.
I am a begginer and was also having problems with getting the EA to only open 1 trade per bar.
I found this soluting someonewhere on this site....can't remember where, but it uses a boolean
function:
int start
{
if (NewBar())
......
........
.........
return(0);
}
bool NewBar()
{
static datetime OldTime = 0;
if(OldTime < Time[0])
{
OldTime = Time[0];
return(true);
}
else
{
return(false);
}
}
Hope this helps.
I am a begginer and was also having problems with getting the EA to only open 1 trade per bar.
I found this soluting someonewhere on this site....can't remember where, but it uses a boolean
function
Listen to the experts and use Time[1]. At the first tick after starting MT or network reconnecting the Time[0] changes immediately, but Time[1] and the rest of all price arrays remains the same, arrays are under refreshment, and should not be used. Using Time[1] filteres this.
I cant test now (because of weekend) but there is another issue around Time and price arrays refreshing, that is more tricky to overcome, read this:

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi
i want to send order buy or sell when new bar is appear. But i don't want to use function minute() to check.
Right know i check new bars with function Minute() == 0 then i send order, but last time i don't have any transaction in 0 minute and my order was not send.
Any idea ?