for(counter=0;counter<OrdersTotal();counter++) { if(OrderSelect(counter, SELECT_BY_POS, MODE_TRADES)&& OrderMagicNumber()==mn) {return(0);} }Delete this
when i delete this part
for(counter=0;counter<OrdersTotal();counter++) { if(OrderSelect(counter, SELECT_BY_POS, MODE_TRADES)&& OrderMagicNumber()==mn) {return(0);} }
EA places lot of orders in one minute. as you can see in attached picture. and its still wait for SL or TP. I want open order on every hour
Oh yes, I forgot about that
static int trade_hour=-1; int d = DayOfWeek(); int h = TimeHour(TimeCurrent()); int m = TimeMinute(TimeCurrent()); int ticket, counter, close; double SL=SLpips*Point; double TP=TPpips*Point; int mn=1; if(trade_hour!=h && d<7 && h<24 && m==15 ) { ticket = OrderSend( Symbol(), OP_BUY, lot, Ask, 0, Ask-SL, Ask+TP, NULL, mn, 0, 0); trade_hour=h; }
try this
Oh yes, I forgot about that
try this
marosvrtak: I set in stretegy tester, it always H1. I
| Wrong, it is what you set it to. |
marosvrtak: I set in stretegy tester, it always H1. I | Wrong, it is what you set it to. |
As I said. It doesnt matter which TF is set in strategy. This code
if(trade_hour!=h && d<7 && h<24 && m==15 ) { ticket = OrderSend( Symbol(), OP_BUY, lot, Ask, 0, Ask-SL, Ask+TP, NULL, mn, 0, 0); trade_hour=h; }
always test only on H1. I want to make it universal, it means, when I set in strategy tester H4, EA will places trade every 4 hour, so 00:00 04:00 08:00. when i set M5 it will be like 00:00 00:05 00:10 etc.
if(trade_hour!=h && d<7 && h<24 && m==15 )
Has nothing to do with the period of the chart. Add Print statements before and inside your if's including variable values and your alleged H1 period. I think you will find your if isn't being called at all.
As for the rest, Search "new bar." and drop your hard coded variables.
- 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 open an order of every new candle lets say on H1. i wrote this code, but it always wait for close on opened order. I mean i want open 24 orders per day (H1 TF).
How can I change it to open trade every hour?