How to add hour to hour trade on an ea?

 

How to add hour to hour trade on an ea?

 

can u explain more about your question?

 

I have the same question (may be), for example : I want to trade every 30 minutes or every 1 one hour

 

I want to add to ea option to trade on gmt 12-15

 
ndisyh:
I have the same question (may be), for example : I want to trade every 30 minutes or every 1 one hour

you can use the iTime() function

like this

bool allowtrade=true;

for (int cnt = 0 ; cnt < OrdersTotal() ; cnt++)

{

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNo)

{

int lastopentime = OrderOpenTime();

if(lastopentime>iTime(Symbol(),PERIOD_H1,0))

allowtrade = false;

}

}

//---------

if(allowtrade)

{

OrderSend(..........);

}

 
jyrik:
I want to add to ea option to trade on gmt 12-15

do you mean, you want to trade only after 00:00 O'clock of your gmt 12 time?

anyway

1st you need to know the server time

then convert it to the gmt time

and use the iTime(Symbol(),PERIOD_D1,0) as a reference ,

it's the 00:00 O'clock of the server time

if server time is on gmt +2

then only allow to trade only after iTime(Symbol(),PERIOD_D1,0)+(10*60*60)

like

if(CurTime()>iTime(Symbol(),PERIOD_D1,0)+(10*60*60))

{

OrderSend(.....);

}

-------------

hope it helps

 

Thank you phoenix...

Reason: