Quote:
Originally Posted by syedks
I am working on a EA that I want to stop trading 2 hours before news come out and wait for another hour after, for any of the symbol the EA is attached to. for example if this ea is attached to GBPUSD chart then any news related to GBP or USD which is of high importance should get picked up by this ea and stop trading based on the time of the news ... can anyone please help?
thanks heaps in advance.
|
Try to use slightly different function TimetoOpen()(from NewsTrader) in your EA:
bool TimeToOpen()
{
bool result = false;
for (int i=0; i<=NewsNum; i++)
{
datetime OpenTime = dt[i] - TimeGap*60; //ex. 2h = 120
if((TimeCurrent() < OpenTime && TimeCurrent() >= OpenTime+TimeGap*60))
{result=true; break;}
}
return(result);
}
Сall of this function you should place in the main condition of orders opening.
Ex. if (MA1>MA2.... && TimeToOpen()) ...