Quote:
|
Originally Posted by Nightmasks
I need to detect when the new bar for any timeframe commences and then put out an alert if a certain condition is met. I am new to this and just completed my first indicator but my alerts occur for every tick.
Also, how do I return a specific bar's commencing server or local time. Does each bar have a time "label"?
The documentation tells me how to get current time in seconds since 1970 and there are functions to extract components such as hour or day. Is there any function that can convert to a specified format?
All help appreciated.
|
You may use iClose():
Code:
double iClose( string symbol, int timeframe, int shift),
where shift is number of bar starting from 0 (curent bar).
Or indicator/EA may look back to some bars to search the condition:
Code:
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars<0) counted_bars=0;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//----
for(int i = 0 ;i < limit ;i++)
{
double f1u = iCustom(...,i);
double f2u = iCustom(...,i+1);
So if you want to find the bar in the history which meets your condition so it is not difficult.
If you know the time for the bar (11:00 GMT for example) and you want to find condition for that bar so I don't know.