Hapu Arachchilage Tharindu Lakmal:
I need to check either sell or buy positions runs at a time,
also, I need to check either buy stop or sell stop placed in the current symbol.
if you can give me an example for this, I can learn from it.
code base is a good place to start, there are plenty examples there
Hi
Simply go in a loop and find if there are any positions and orders opened:
Int cnt = 0; ulong ticket=-1; for(int i=0;i<PositionsTotal();i++){ if(ticket=PositionGetTicket(index)>0); if(PositionGetString(POSITION_SYMBOL)Symbol){ if(PositionGetString(POSITION_TYPE)==POSITION_TYPE_BUY){ cnt++; } else if(PositionGetString(POSITION_TYPE)==POSITION_TYPE_SELL){ cnt++; } } } } for(int i=0;i<OrdersTotal();i++) { if(ticket=OrderGetTicket(i)>0) { if(OrderGetString(ORDER_SYMBOL)==_Symbol) { if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP) { //buystop opened cnt++; } else if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_STOP) { //sellstop opened cnt++; } } } } If(cnt>0) opened=true;
Best Regards
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I need to check either sell or buy positions runs at a time,
also, I need to check either buy stop or sell stop placed in the current symbol.
if you can give me an example for this, I can learn from it.