Add a function to existing code or create a new indicator:
PositionMonitor();
void PositionMonitor(){ int buyPositions, sellPositions, buyLimit, sellLimit, buyStop, sellStop; for(int i = OrdersTotal()-1; i >= 0; i--){ OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(OrderType() == OP_BUY) buyPositions++; if(OrderType() == OP_SELL) sellPositions++; if(OrderType() == OP_BUYLIMIT) buyLimit++; if(OrderType() == OP_SELLLIMIT) sellLimit++; if(OrderType() == OP_BUYSTOP) buyStop++; if(OrderType() == OP_SELLSTOP) sellStop++; } Comment( "\n"+ buyPositions + " Buy Positions \n"+ sellPositions + " Sell Positions \n"+ buyLimit + " Buy Limit Orders \n"+ sellLimit + " Sell Limit Orders \n"+ buyStop + " Buy Stop Orders \n"+ sellStop + " Sell Stop Orders \n"); return(0); }
Works! Thank you very much
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
Hello
I have a lot of open buy and sell 0.1 unit positions.
I need to know exactly how many of them are opened. Instead of counting them manually, is there a script which counts the number of open positions i.e. "you have 57 open buy positions" ?