Pipsometer Cash+Infolines v_1.1
Pipsometer Cash+Infolines v_1.1

Pipsometer Cash+Infolines v_1.1最新版

更新日期:
2022-03-15
分类标签:
语言:
中文
平台:
没限制

15 人已下载 手机查看

描述文字

//+——————————————————————+
//| Pipsometer Cash+Infolines.mq4 |
//+——————————————————————+
#property copyright “© Indalico 03/07/2020”
#property link “http://www.mql4.com”
#property description “Free software, can be freely used, copied or modified.”
#property description “Software libre, puede ser usado, copiado o modificado libremente.”
#property description “———————————————————————————————————————–”
#property description “El indicador cuenta las ganancias/pérdidas en pips, las ganancias/pérdidas”
#property description “flotantes y cerradas en cash, y además también muestra unas líneas con el precio”
#property description “de entrada, stoploss y takeprofit junto a una etiqueta de texto con lotes y pips.”
#property indicator_chart_window

extern bool DisplayInfoLines = true;
extern bool DisplayCashProfit = false;
extern color BuyOpenLineColor = clrYellow;
extern color SellOpenLineColor = clrYellow;
extern color ProfitLineColor = clrLime;
extern color StopLineColor = clrOrange;

extern string IndicatorPosition = “—– Where to locate the indicator options —–“;
extern int WhereToDisplay = 0;
extern ENUM_BASE_CORNER Corner = CORNER_RIGHT_LOWER;
extern int Yposition = 10;
extern int Xposition = 5;
extern int Ystep = 18;
extern int CounterFontSize = 16;
extern int LineTextFontSize = 20;
extern double VerticalTextGap = 1;
extern int HorizontalTextGap = 14;

double k,cen,pips,cash,done,BuyPrice,SelPrice,stop,take;
int i,OpenBuys,OpenSels,OpenTrades;
datetime TextTime;

//——————————————————————-

int deinit()
{
DeleteAll();
ObjectDelete(“ShwMagic”); ObjectDelete(“Pips”);
ObjectDelete(“Float”); ObjectDelete(“Done”);
return(0);
}

//——————————————————————-

int init()
{
if(Digits==5) k=0.0001; if(Digits==4) k=0.001; if(Digits==3) k=0.01; if(Digits==2) k=0.1; if(Digits==1 || Digits==0 ) k=1;

if(DisplayCashProfit)
{
DisplayLabel(“Done”,0,CounterFontSize,”Arial”,clrLime,”Closed: “+DoubleToStr(done,2));
DisplayLabel(“Float”,Ystep,CounterFontSize,”Arial”,clrLime,”Floating: “+DoubleToStr(cash,2));
DisplayLabel(“Pips”,Ystep*2,CounterFontSize,”Arial”,clrLime,”0.0″);
}
else {DisplayLabel(“Pips”,Ystep,CounterFontSize,”Arial”,clrLime,”0.0″);}
return(0);
}

//——————————————————————————

int start()
{
TextTime=TimeCurrent()+HorizontalTextGap*Period()*60;
pips=0; cash=0; OpenTrades=0; OpenBuys=0; OpenSels=0;

for(i=0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol() != Symbol()) continue;
if(OrderType()==OP_BUY) {pips += Bid-OrderOpenPrice(); cash += OrderProfit()+OrderCommission(); OpenTrades++;}
if(OrderType()==OP_SELL){pips += OrderOpenPrice()-Ask; cash += OrderProfit()+OrderCommission(); OpenTrades++;}
}

if(pips>0) ObjectSetText(“Pips”, DoubleToStr(pips/k,1),CounterFontSize*2,”Arial Bold”,clrLime);
else ObjectSetText(“Pips”, DoubleToStr(pips/k,1),CounterFontSize*2,”Calibri Bold”,clrRed);

if(DisplayCashProfit)
{
if(cash>0) ObjectSetText(“Float”,”Floating: “+DoubleToStr(cash,2),CounterFontSize,”Arial”,clrLime);
else ObjectSetText(“Float”,”Floating: “+DoubleToStr(cash,2),CounterFontSize,”Arial”,clrRed);
}

//—————— Draw info lines and text for open positions ——————————

if(DisplayInfoLines)
{
if(OpenTrades != 0)
{
for(i=0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol() != Symbol()) continue;

//—————— Draw lines on longs —————————————

if(OrderType() == OP_BUY)
{
OpenBuys++; BuyPrice=OrderOpenPrice();
if(OpenBuys==2) BuyPrice=BuyPrice-VerticalTextGap; else if(OpenBuys==3) BuyPrice=BuyPrice-(2*VerticalTextGap);
else if(OpenBuys==4) BuyPrice=BuyPrice-(3*VerticalTextGap); else if(OpenBuys==5) BuyPrice=BuyPrice-(4*VerticalTextGap);

ObjectDelete(“OpenLine”+1);
ObjectDelete(“OpenText”+1);
ObjectCreate(“OpenLine”+i,OBJ_HLINE,0,0,OrderOpenPrice());
ObjectSet (“OpenLine”+i,OBJPROP_COLOR,BuyOpenLineColor);

ObjectCreate (“OpenText”+i,OBJ_TEXT,0,TextTime,BuyPrice);
ObjectSetText(“OpenText”+i,”Entrada: “+DoubleToStr(OrderOpenPrice(),5),LineTextFontSize,”Arial”,BuyOpenLineColor);

if(OrderTakeProfit()>0)
{
ObjectDelete(“TakeLine”+1);
ObjectDelete(“TakeText”+1);
ObjectCreate(“TakeLine”+i,OBJ_HLINE,0,0,OrderTakeProfit());
ObjectSet (“TakeLine”+i,OBJPROP_COLOR,ProfitLineColor);
take=(OrderTakeProfit()-OrderOpenPrice())/k;
ObjectCreate (“TakeText”+i,OBJ_TEXT,0,TextTime,OrderTakeProfit());
ObjectSetText(“TakeText”+i,”TP: “+DoubleToStr(OrderTakeProfit(),5)+” ( “+DoubleToStr(take,1)+” pips ) “,LineTextFontSize,”Arial”,ProfitLineColor);
if(ObjectGet(“TakeLine”+i,OBJPROP_PRICE)!=OrderTakeProfit()) {ObjectMove(“TakeLine”+i,0,TextTime,OrderTakeProfit()); ObjectMove(“TakeText”+i,0,TextTime,OrderTakeProfit());}
}
else if(ObjectFind(“TakeText”+i)==0) {ObjectDelete(“TakeText”+i); ObjectDelete(“TakeLine”+i);}

if(OrderStopLoss()>0)
{
ObjectDelete(“StopLine”+1);
ObjectDelete(“StopText”+1);
ObjectCreate(“StopLine”+i,OBJ_HLINE,0,0,OrderStopLoss());
ObjectSet (“StopLine”+i,OBJPROP_COLOR,StopLineColor);
stop=(OrderOpenPrice()-OrderStopLoss())/k;
ObjectCreate (“StopText”+1,OBJ_TEXT,0,TextTime,OrderStopLoss());
ObjectSetText(“StopText”+1,”SL: “+DoubleToStr(OrderStopLoss(),5)+” ( “+DoubleToStr(stop,1)+” pips )”,LineTextFontSize,”Arial”, StopLineColor);
if(ObjectGet(“StopLine”+i,OBJPROP_PRICE)!=OrderStopLoss()) {ObjectMove(“StopLine”+i,0,TextTime,OrderStopLoss()); ObjectMove(“StopText”+i,0,TextTime,OrderStopLoss());}
}
else if(ObjectFind(“StopText”+i)==0) {ObjectDelete(“StopText”+i); ObjectDelete(“StopLine”+i);}
}

//—————— Draw lines on shorts —————————————-

if(OrderType() == OP_SELL)
{
OpenSels++; SelPrice=OrderOpenPrice();
if(OpenSels==2) SelPrice=SelPrice-VerticalTextGap; else if(OpenSels==3) SelPrice=SelPrice-(2*VerticalTextGap);
else if(OpenSels==4) SelPrice=SelPrice-(3*VerticalTextGap); else if(OpenSels==5) SelPrice=SelPrice-(4*VerticalTextGap);

ObjectDelete(“OpenLine”+1);
ObjectDelete(“OpenText”+1);
ObjectCreate(“OpenLine”+i,OBJ_HLINE,0,0,OrderOpenPrice());
ObjectSet (“OpenLine”+i,OBJPROP_COLOR,SellOpenLineColor);

ObjectCreate (“OpenText”+i,OBJ_TEXT,0,TextTime,SelPrice);
ObjectSetText(“OpenText”+i,”Entrada: “+DoubleToStr(OrderOpenPrice(),5),LineTextFontSize,”Arial”,SellOpenLineColor);

if(OrderTakeProfit()>0)
{
ObjectDelete(“TakeLine”+1);
ObjectDelete(“TakeText”+1);
ObjectCreate(“TakeLine”+i,OBJ_HLINE,0,0,OrderTakeProfit());
ObjectSet (“TakeLine”+i,OBJPROP_COLOR,ProfitLineColor);
take=(OrderOpenPrice()-OrderTakeProfit())/k;
ObjectCreate (“TakeText”+i,OBJ_TEXT,0,TextTime,OrderTakeProfit());
ObjectSetText(“TakeText”+i,”TP: “+DoubleToStr(OrderTakeProfit(),5)+” ( “+DoubleToStr(take,1)+” pips ) “,LineTextFontSize,”Arial”,ProfitLineColor);
if(ObjectGet(“TakeLine”+i,OBJPROP_PRICE)!=OrderTakeProfit()) {ObjectMove(“TakeLine”+i,0,TextTime,OrderTakeProfit()); ObjectMove(“TakeText”+i,0,TextTime,OrderTakeProfit());}
}
else if (ObjectFind(“TakeText”+i)==0) {ObjectDelete(“TakeText”+i); ObjectDelete(“TakeLine”+i);}

if(OrderStopLoss()>0)
{
ObjectDelete(“StopLine”+1);
ObjectDelete(“StopText”+1);
ObjectCreate(“StopLine”+i,OBJ_HLINE,0,0,OrderStopLoss());
ObjectSet (“StopLine”+i,OBJPROP_COLOR,StopLineColor);
stop=(OrderStopLoss()-OrderOpenPrice())/k;
ObjectCreate (“StopText”+i,OBJ_TEXT,0,TextTime,OrderStopLoss());
ObjectSetText(“StopText”+i,”SL: “+DoubleToStr(OrderStopLoss(),5)+” ( “+DoubleToStr(stop,1)+” pips )”,LineTextFontSize,”Arial”,StopLineColor);
if(ObjectGet(“StopLine”+i,OBJPROP_PRICE)!=OrderStopLoss()) {ObjectMove(“StopLine”+i,0,TextTime,OrderStopLoss()); ObjectMove(“StopText”+i,0,TextTime,OrderStopLoss());}
}
else if(ObjectFind(“StopText”+i)==0) {ObjectDelete(“StopText”+i); ObjectDelete(“StopLine”+i);}
}
}
}

//————– Calculate history cash done——————————————–

done=0;
for(i=0; i < OrdersHistoryTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) break;
if(OrderCloseTime()<StrToTime(“00:00”)) continue; done += OrderProfit();
}

if(done>0) ObjectSetText(“Done”,”Closed: “+DoubleToStr(done,2),CounterFontSize,”Arial”,clrLime);
else ObjectSetText(“Done”,”Closed: “+DoubleToStr(done,2),CounterFontSize,”Arial”,clrRed);
}

if(OpenTrades==0){DeleteAll();}

return(0);
}

//———————————————————————————————-

void DisplayLabel(string name,int y,int fsize,string font,color clr,string text)
{
if(ObjectFind(name)>=0) ObjectDelete(name);
ObjectCreate(name,OBJ_LABEL,WhereToDisplay,0,0);
ObjectSet(name,OBJPROP_CORNER,Corner);
ObjectSet(name,OBJPROP_XDISTANCE,Xposition);
ObjectSet(name,OBJPROP_YDISTANCE,Yposition+y);
ObjectSet(name,OBJPROP_HIDDEN,true);
ObjectSetText(name,text,fsize,font,clr);
}

//+———————————————————————————–

void DeleteAll()
{

ObjectDelete(“OpenLine”+0); ObjectDelete(“OpenText”+0);
ObjectDelete(“TakeLine”+0); ObjectDelete(“TakeText”+0);
ObjectDelete(“StopLine”+0); ObjectDelete(“StopText”+0);

ObjectDelete(“OpenLine”+1); ObjectDelete(“OpenText”+1);
ObjectDelete(“TakeLine”+1); ObjectDelete(“TakeText”+1);
ObjectDelete(“StopLine”+1); ObjectDelete(“StopText”+1);

ObjectDelete(“OpenLine”+2); ObjectDelete(“OpenText”+2);
ObjectDelete(“TakeLine”+2); ObjectDelete(“TakeText”+2);
ObjectDelete(“StopLine”+2); ObjectDelete(“StopText”+2);

ObjectDelete(“OpenLine”+3); ObjectDelete(“OpenText”+3);
ObjectDelete(“TakeLine”+3); ObjectDelete(“TakeText”+3);
ObjectDelete(“StopLine”+3); ObjectDelete(“StopText”+3);

ObjectDelete(“OpenLine”+4); ObjectDelete(“OpenText”+4);
ObjectDelete(“TakeLine”+4); ObjectDelete(“TakeText”+4);
ObjectDelete(“StopLine”+4); ObjectDelete(“StopText”+4);

ObjectDelete(“OpenLine”+5); ObjectDelete(“OpenText”+5);
ObjectDelete(“TakeLine”+5); ObjectDelete(“TakeText”+5);
ObjectDelete(“StopLine”+5); ObjectDelete(“StopText”+5);

ObjectDelete(“OpenLine”+6); ObjectDelete(“OpenText”+6);
ObjectDelete(“TakeLine”+6); ObjectDelete(“TakeText”+6);
ObjectDelete(“StopLine”+6); ObjectDelete(“StopText”+6);

ObjectDelete(“OpenLine”+7); ObjectDelete(“OpenText”+7);
ObjectDelete(“TakeLine”+7); ObjectDelete(“TakeText”+7);
ObjectDelete(“StopLine”+7); ObjectDelete(“StopText”+7);

ObjectDelete(“OpenLine”+8); ObjectDelete(“OpenText”+8);
ObjectDelete(“TakeLine”+8); ObjectDelete(“TakeText”+8);
ObjectDelete(“StopLine”+8); ObjectDelete(“StopText”+8);

ObjectDelete(“OpenLine”+9); ObjectDelete(“OpenText”+9);
ObjectDelete(“TakeLine”+9); ObjectDelete(“TakeText”+9);
ObjectDelete(“StopLine”+9); ObjectDelete(“StopText”+9);

ObjectDelete(“OpenLine”+10); ObjectDelete(“OpenText”+10);
ObjectDelete(“TakeLine”+10); ObjectDelete(“TakeText”+10);
ObjectDelete(“StopLine”+10); ObjectDelete(“StopText”+10);

ObjectDelete(“OpenLine”+11); ObjectDelete(“OpenText”+11);
ObjectDelete(“TakeLine”+11); ObjectDelete(“TakeText”+11);
ObjectDelete(“StopLine”+11); ObjectDelete(“StopText”+11);

}

//————————————————————————————

如果你对文件有了解,请帮助投票!

If you are familiar with the file, please help vote!

平均评分 0 / 5. 投票数: 0

到目前为止还没有投票!成为第一位投票人。

相关资源

暂无评论

none
暂无评论...