anyone with simple code for trade only once for each 1 hour?
so that within one hour, it will only open one trade.
simple code would be appreciate.
so that within one hour, it will only open one trade.
simple code would be appreciate.
Why does 4 hour bar close 1 hour later than daily bar? 6 replies
average true range for 1 hour and 4 hour charts 2 replies
X-1102 1 hour , 4 hour and daily Tf trades 7 replies
Create a verticle line at certain hour for every certain hour 16 replies
Code for Trade hour 7 replies
Dislikedput...
extern ORDERDELAY_Minutes=60;
double timedelay=0;
if(TimeCurrent()>=timedelay, .. other order conditions ..)
{
//In order loop
//Remember to use ticket=OrderSend(...
if(ticket>0){timedelay=TimeCurrent()+(ORDERDELAY_Minutes*60);}
}Ignored
bool DecideToOpenTrade() { int total = OrdersTotal(); if (total > 0) { for(int cnt=0;cnt<total;cnt++) { if(OrderSelect(cnt,SELECT_BY_POS)) { if(OrderSymbol()==Symbol() && OrderMagicNumber() == MAGIC_NUM) { if (iTime(NULL,PERIOD_H1,0) <= OrderOpenTime()) // don't open a new position if we're still on the same candle { return (false); } } } } } // in case trades has already opened and closed within the candle int histotal = OrdersHistoryTotal(); if (histotal > 0) { for(cnt=0;cnt<histotal;cnt++) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)) { if(OrderSymbol()==Symbol() && OrderMagicNumber() == MAGIC_NUM) { if (iTime(NULL,PERIOD_H1,0) <= OrderOpenTime()) // don't open a new position if we're still on the same candle { return (false); } } } } } return (true); } int start() { //... some of your codes... // assuming now there's a buy or sell signal if (DecideToOpenTrade()) { // trade opening codes go here. } return (0); }
DislikedWhat I look for is simple code for allowing only one trade taken during the trading hours...example in hour 1, only one trade, in hour 2, only one trade..etc..
I try using flag:
if(total<1 && Minute()==0)
{flag=true;
}
and after the buy command/sell command, I put flag==false;Ignored