hello, how can I say of the Expert no enter on the same candle if you take profit or stoploss?
if(OrderOpenTime() > Time[0]) return(0);
if(OrderCloseTime()> Time[0]) return(0);
if(!IsTradeAllowed())
if it is incorrect, how can I write ?
- How to avoid opening of new order
- How to code?
- determine bar where stop loss or take profit was taken
Function:
datetime GetLastOrder() { datetime last_order = 0; for(int i=OrdersHistoryTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue; if(OrderSymbol()!=_Symbol) continue; // if(OrderMagicNumber() != magic_no) continue; if(OrderType()>1) continue; datetime close_time = OrderCloseTime(); if(close_time>last_order) last_order=close_time; } return(last_order); }
Call:
if(GetLastOrder() >= Time[0]) return;
or just remember when
static datetime lastBarOpened=0; if(Time[0] != lastBarOpened && tbdOpenNowCondition ){ int ticket = OrderSend( ... ); if(ticket < 0) ... else lastBarOpened = Time[0]; }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register