Orders Info
Orders_Info
The indicator shows information on orders. You can see the magic order, its profit and how long the order is already in the market.
Also, the indicator shows what profit or loss we will receive when the order is closed by stop-loss or take-profit.
The information is summarized and displayed at the top of the window separately by TP and SL.
Code :
Download : Orders_Info.mq4
The indicator shows information on orders. You can see the magic order, its profit and how long the order is already in the market.
Also, the indicator shows what profit or loss we will receive when the order is closed by stop-loss or take-profit.
The information is summarized and displayed at the top of the window separately by TP and SL.
Code :
//+------------------------------------------------------------------+
//| Orders_Info.mq4 |
//| Copyright 2018, MetaEditor. |
//| https://www.meta-editor.blogspot.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaEditor."
#property link "https://www.meta-editor.blogspot.com"
#property description "https://www.meta-editor.blogspot.com"
#property version "1.00"
#property strict
#property indicator_chart_window
double TICKVALUE;
string AC;
extern bool showm = false; //Show MagicNumber
extern bool showp = true; //Show Profit
extern bool showt = false; //Show Time
extern bool showsl = true; //Show StopLoss
extern bool showtp = true; //Show TakeProfit
extern color plus = clrGreen; //Color Plus
extern color minus = clrMaroon; //Color Minus
//+------------------------------------------------------------------+
int OnInit()
{
TICKVALUE=MarketInfo(Symbol(),MODE_TICKVALUE);
AC=AccountCurrency();
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
double sumsl=0;
double sumtp=0;
ObjectsDeleteAll(0,"sl");
ObjectsDeleteAll(0,"tp");
ObjectsDeleteAll(0,"or");
for(int j=0; j<OrdersTotal(); j++)
{
if(OrderSelect(j,SELECT_BY_POS))
{
int pips=0,OT=OrderType();
double OOP=OrderOpenPrice();
double OTP=OrderTakeProfit();
double OSL=OrderStopLoss();
double OL=OrderLots();
string name=StringConcatenate("or",OrderTicket());
ObjectDelete(0,name);
string txt=NULL;
if(showm) txt=StringConcatenate("Magic ",OrderMagicNumber()," ");
if(showp) txt=StringConcatenate(txt,"Profit ",DoubleToStr(OrderProfit(),2)," ",AC," ");
if(showt) txt=StringConcatenate(txt,"Time ",MathFloor((TimeCurrent()-OrderOpenTime())/60)," Minute ");
TextCreate(0,name,0,Time[0]+Period()*300,OOP,txt,"Arial",8,Color(OrderProfit()<0,minus,plus));
if(OTP!=0)
{
name=StringConcatenate("tp",name);
ObjectDelete(0,name);
if(OT==OP_BUY) pips=(int)((OTP-OOP)/Point);
if(OT==OP_SELL) pips=(int)((OOP-OTP)/Point);
if(showtp) TextCreate(0,name,0,Time[WindowFirstVisibleBar()/2],OTP,StringConcatenate(DoubleToStr(TICKVALUE*pips*OL,2)," ",AC," ",pips),"Arial",8,Color(pips<0,minus,plus));
sumtp+=TICKVALUE*pips*OL;
}
if(OSL!=0)
{
name=StringConcatenate("sl",name);
ObjectDelete(0,name);
if(OT==OP_BUY) pips=(int)((OSL-OOP)/Point);
if(OT==OP_SELL) pips=(int)((OOP-OSL)/Point);
if(showsl) TextCreate(0,name,0,Time[WindowFirstVisibleBar()/2],OSL,StringConcatenate(DoubleToStr(TICKVALUE*pips*OL,2)," ",AC," ",pips),"Arial",8,Color(pips<0,minus,plus));
sumsl+=TICKVALUE*pips*OL;
}
}
}
DrawLABEL("sl",0,300,0,Color(sumsl<0,minus,plus),StringConcatenate("Total SL ",DoubleToStr(sumsl,2)," ",AC));
DrawLABEL("tp",0,300,15,Color(sumtp<0,minus,plus),StringConcatenate("Total TP ",DoubleToStr(sumtp,2)," ",AC));
return(rates_total);
}
//-------------------------------------------------------------------
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0,"sl");
ObjectsDeleteAll(0,"tp");
ObjectsDeleteAll(0,"or");
}
//+------------------------------------------------------------------+
void DrawLABEL(string name,int CORNER,int X,int Y,color clr,string Name)
{
if(ObjectFind(name)==-1)
{
ObjectCreate(name,OBJ_LABEL,0,0,0);
ObjectSet(name,OBJPROP_CORNER,CORNER);
ObjectSet(name,OBJPROP_XDISTANCE,X);
ObjectSet(name,OBJPROP_YDISTANCE,Y);
}
ObjectSetText(name,Name,10,"Arial",clr);
}
//+------------------------------------------------------------------+
bool TextCreate(const long chart_ID=0,
const string name="Text",
const int sub_window=0,
datetime time=0,
double price=0,
const string text="Text",
const string font="Arial",
const int font_size=8,
const color clr=clrRed,
const double angle=0.0,
const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_LOWER,
const bool back=false,
const bool selection=false,
const bool hidden=true,
const long z_order=0)
{
ResetLastError();
if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price))
{
Print(__FUNCTION__,
": Do not remove the object! = ",GetLastError());
return(false);
}
ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
return(true);
}
//+------------------------------------------------------------------+
color Color(bool P,color a,color b)
{
if(P) return(a);
else return(b);
}
//------------------------------------------------------------------
Download : Orders_Info.mq4


