i have 4/5 open order in terminal, i need to select last/latest opened order but it showing another order not last one opened.
my code here
datetime a; datetime max=0; int b; string c; string d; for(int i = (OrdersTotal()- 1); i >= 0; i --) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); a = OrderOpenTime(); if(a>max) { max=a; b = OrderTicket(); c = OrderSymbol(); d = OrderComment(); } } Comment (" T#" + b + " Time : " +a + " // " + c + "//" + d ); return(0);
my terminal last opened order is working now but i m in trouble, it open new order only the chart in which pair i m attaching the EA.
suppose my last signal opened order pair is EURUSD, but i attached the EA in GBPUSD pair...in that case its not opening new EURUSD order....its only opening GBPUSD order if last opening signal was GBPUSD....for this i need to attach EA in all pair chart, how can i solve it?
i want to attach the EA in any one chart only but it can open all pair order which last opened order detected in terminal and with specific comment exist there (like A1)
my code here:
int start() { datetime a; datetime max=0; datetime e; int b; string c; string d; string f; for(int i = (OrdersTotal()- 1); i >= 0; i --) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); a = OrderOpenTime(); if(a>max) { max=a; b = OrderTicket(); c = OrderSymbol(); // select order defined symbol d = OrderComment(); e = TimeCurrent(); f = OrderType(); } } if (c != "XAUUSD"){ if (d = "A1"){ // open order only when detected order comment A1 if ((e-a)<30){ int ThisBarTrade = 0; if (Bars != ThisBarTrade ) { ThisBarTrade = Bars; if (f == 0){ int ticket=OrderSend(OrderSymbol(),OP_BUY,0.1,Ask,3,0,0,"",0,0,Green); Sleep(30000); } if (f == 1){ int ticket=OrderSend(OrderSymbol(),OP_SELL,0.1,Bid,3,0,0,"",0,0,Red); Sleep(30000); } } } } }
i m trying to make this EA cause, i m buying signal from mql5 where order opening by signal provider and comment is there, but signal provider acc is standard (0.01 lot per pips 10 cent) and my acc is micro (0.01 lot per pips 1 cent), so i want to put another order as same as signal buy/sell within 30secs with another new one 0.10 lot (10 cents per pips)
MarketInfo(OrderSymbol(),MODE_BID/MODE_ASK)
i got this...and solved
but i m facing another problem in checking comment.
if (d = "A1"){ ************************ }
this condition not working... if comment is blank or anything, order is opening...i want new order open only when last detected order comment is A1.
if (c != "XAUUSD"){ if (d = "A1"){ // this condition not working if ((e-a)<30){ int ThisBarTrade = 0; if (Bars != ThisBarTrade ) { ThisBarTrade = Bars; if (f == 0){ if (c == "EURUSD" ){ int ticket=OrderSend(c,OP_BUY,0.1,MarketInfo(c,MODE_ASK),3,0,0,"",0,0,Green); Sleep(30000); } if (c == "GBPUSD" ){ int ticket1=OrderSend(c,OP_BUY,0.1,MarketInfo(c,MODE_ASK),3,0,0,"",0,0,Green); Sleep(30000); } } if (f == 1){ if (c == "EURUSD" ){ int ticket2=OrderSend(c,OP_SELL,0.1,MarketInfo(c,MODE_BID),3,0,0,"",0,0,Red); Sleep(30000); } if (c == "GBPUSD" ){ int ticket3=OrderSend(c,OP_SELL,0.1,MarketInfo(c,MODE_BID),3,0,0,"",0,0,Red); Sleep(30000); } } } } } }
thanks again for reply

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i have 4/5 open order in terminal, i need to select last/latest opened order but it showing another order not last one opened.
my code here