Hi there I would Like to know how can I write some code to count how many orders are currently open on the account ... like If I currently have 5 open orders I would like it to return me a value of 5 ....
thanks alot !!
thanks alot !!
How many strategies are u using and how many pairs do u trade? 0 replies
How many parameters are too many? 0 replies
Number of trades before counting consistency 9 replies
Is there any website show the elliott counting? 8 replies
How many pairs is considered too many? 8 replies
datetime daystart = TimeCurrent() - (TimeCurrent()%(PERIOD_D1 * 60)); datetime dayend = daystart + (PERIOD_D1 * 60); int count=0; for(int i=OrdersHistoryTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if(OrderCloseTime() >= daystart && OrderCloseTime() <dayend) count++; } // count is the number of trades closed today
ObjectSetText ( "fpm_short",DoubleToStr ( countOrders ( OP_SELL,allSymbols ),0 ) ); ObjectSetText ( "fpm_long",DoubleToStr ( countOrders ( OP_BUY,allSymbols ),0 ) ); int countOrders ( int oType,bool allSymbols=false ) { int count=0; for ( int i=0; i<OrdersTotal(); i++ ) if ( OrderSelect ( i,SELECT_BY_POS ) ) if ( allSymbols || OrderSymbol() ==Symbol() ) if ( OrderType() ==oType || oType<0 ) count++; datetime daystart = TimeCurrent() - (TimeCurrent()%(PERIOD_D1 * 60)); datetime dayend = daystart + (PERIOD_D1 * 60); for(int i=OrdersHistoryTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) ); if(OrderCloseTime() >= daystart && OrderCloseTime() <dayend) if ( allSymbols || OrderSymbol() ==Symbol() ) if ( OrderType() ==oType || oType<0 ) count++; } return ( count ); }
Disliked1. Stop Loss in pips.
2. Stop Loss in dollars.
3. Realized gain in pips.
4. Realized gain in dollars.
5. Number of Long or Short positions.
6. Overall risk in dollars of all open positions (on all symbols). This will be the scary number to you if you open multiple positions on multiple pairs at max leverage.
7. Yesterday's account balance, percentage gain for today, dollar gain for today.Ignored
DislikedHere's the indicator I modified from. I'm not a trained programmer so my additions are not clean but ..... as long as it works. I added your code at YDISTANCE=139 (see pink arrow) so that I can test out live today. The existing script showed the number of open BUY and number of open SELL, but quickly reset to 0 when trades are closed. No trades so far so everything is 0 except for account starting balance. At the end of the day if I took 17 trades, I want to see that number stay "17".Ignored
datetime daystart = TimeCurrent() - (TimeCurrent()%(PERIOD_D1 * 60)); datetime dayend = daystart + (PERIOD_D1 * 60); int count=0; for(int i=OrdersHistoryTotal()-1;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if(OrderCloseTime() >= daystart && OrderCloseTime() <dayend && (OrderType()== OP_BUY || OrderType()== OP_SELL) ) count++; } // count is the number of trades closed today
Disliked{quote} Many thanks Gumrai and RaptorUK, I've tested and it works! Sorry to take up your time, I'm solved now.Ignored