Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
all_stoploss_sum
//+------------------------------------------------------------------+
//| All_StopLoss_sum.mq4 |
//| © Tecciztecatl |
//+------------------------------------------------------------------+
#property copyright "© Tecciztecatl 2016"
#property link "https://www.mql5.com/en/users/tecciztecatl"
#property version "1.00"
#property description "This script will calculate the total amount of lots, loss, profit."
#property script_show_inputs
#property strict
enum choice0 {yes=0,no=1};
input choice0 add_pending=yes; //Add the pending orders
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
int sell_orders=0;
double sell_Loss=0;
double sell_Profit=0;
double sell_Lots=0;
int buy_orders=0;
double buy_Loss=0;
double buy_Profit=0;
double buy_Lots=0;
string not_all_sl="";
string not_all_tp="";
double Tick_Value=MarketInfo(Symbol(),MODE_TICKVALUE);
int totalOrders=OrdersTotal();
if(totalOrders>0)
{
for(int i=0;i<totalOrders;i++)
{
bool i2=false; while(i2==false && !IsStopped()) i2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=_Symbol) continue;
if(OrderType()==OP_SELL || (add_pending==yes && (OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP)))
{
sell_orders++;
if(OrderStopLoss()>0) sell_Loss+=(OrderOpenPrice()-OrderStopLoss())/_Point*OrderLots()*Tick_Value;
else not_all_sl="\nNot all orders have a stop loss!";
if(OrderTakeProfit()>0) sell_Profit+=(OrderOpenPrice()-OrderTakeProfit())/_Point*OrderLots()*Tick_Value;
else not_all_tp="\nNot all orders have a take profit!";
sell_Lots+=OrderLots();
}
if(OrderType()==OP_BUY || (add_pending==yes && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP)))
{
buy_orders++;
if(OrderStopLoss()>0) buy_Loss+=(OrderStopLoss()-OrderOpenPrice())/_Point*OrderLots()*Tick_Value;
else not_all_sl="\nNot all orders have a stop loss!";
if(OrderTakeProfit()>0) buy_Profit+=(OrderTakeProfit()-OrderOpenPrice())/_Point*OrderLots()*Tick_Value;
else not_all_tp="\nNot all orders have a take profit!";
buy_Lots+=OrderLots();
}
}
if(sell_orders>0 || buy_orders>0)
Alert(StringFormat("BUY Orders: %d Lots: %.2f LossSumm: %.2f ProfitSumm: %.2f\nSell Orders: %d Lots: %.2f LossSumm: %.2f ProfitSumm: %.2f\n",
buy_orders, buy_Lots, buy_Loss, buy_Profit, sell_orders, sell_Lots, sell_Loss, sell_Profit) + not_all_sl + not_all_tp);
}
else Alert("No orders");
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---