Hello everyone,,hope everyone doing well,,,
i need an indicator or tool to show me the ' sum of positive open buy orders and sum of positive open sell orders ' .
thank you.
search codebase or marketplace or create a job on freelance for small fee.
This forum is mostly for asking questions regarding mt4/5 issues; and/or coding advice.
There are many forums on the web where general discussion and requests are encouraged. This is not one of those.
Lots Weighted Average Price = ∑ op(i) × lot(i) ÷ ∑ lot(i) . This is the break even price of all orders combined. Use negative lots for sell orders.
Hello everyone,,hope everyone doing well,,,
i need an indicator or tool to show me the ' sum of positive open buy orders and sum of positive open sell orders ' .
thank you.
i think it is obvious that you did not do a search. see first link in search page. But there are several different indicators and eas on there that show the same thing. Next time do a search please.
https://www.mql5.com/en/search#!keyword=weighted%20price&module=mql5_module_codebase
Hello everyone,,hope everyone doing well,,,
i need an indicator or tool to show me the ' sum of positive open buy orders and sum of positive open sell orders ' .
thank you.
Use this function in your EA:
double PositiveFloat(int type) { double result = 0; int total = OrdersTotal(); double price = (type == OP_BUY)?Bid:Ask; for(int i=total-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol() != Symbol() || OrderType() != type) continue; if(OrderProfit()+OrderCommission()+OrderSwap() > 0 && MathAbs(price-OrderOpenPrice()) > 0) { result += OrderProfit()+OrderCommission()+OrderSwap(); } } return(result); }
i think it is obvious that you did not do a search. see first link in search page. But there are several different indicators and eas on there that show the same thing. Next time do a search please.
https://www.mql5.com/en/search#!keyword=weighted%20price&module=mql5_module_codebase
Here's an example for MT4:
Александр, 2009.11.23 13:41
It shows a brief information about all of the positions opened. It can be useful, if yours expert advisor trades many positions simultaneously.The heavy guts of the calculation are:
Forum on trading, automated trading systems and testing trading strategies
Morimil, 2020.06.22 11:31
This code is better
//+------------------------------------------------------------------+ //| TOTAL_PROFIT_OF_OPEN_POSITIONS | //+------------------------------------------------------------------+ double TOTAL_PROFIT_OF_OPEN_POSITIONS() { double Total_Profit=0; double deal_commission=0; for(int i=0; i<PositionsTotal(); i++) { ulong position_ticket=PositionGetTicket(i); // ticket of the position ulong magic=PositionGetInteger(POSITION_MAGIC); // MagicNumber of the position string comment=PositionGetString(POSITION_COMMENT); // position comment long position_ID=PositionGetInteger(POSITION_IDENTIFIER); // Identifier of the position if(magic==EXPERT_MAGIC || comment==IntegerToString(EXPERT_MAGIC)) { HistorySelect(POSITION_TIME,TimeCurrent()); for(int j=0; j<HistoryDealsTotal(); j++) { ulong deal_ticket=HistoryDealGetTicket(j); if(HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID) == position_ID) { deal_commission=HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION)*2; break; } } Total_Profit+=PositionGetDouble(POSITION_PROFIT)+PositionGetDouble(POSITION_SWAP)+deal_commission; } } return(Total_Profit); }
Then you can print Comments or draw Labels/Text that incorporate the returned value onto your chart. This the easy part (Label):
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,,hope everyone doing well,,,
i need an indicator or tool to show me the ' sum of positive open buy orders and sum of positive open sell orders ' .
thank you.