|
//计算爆仓距离,指定有一款适合你,此五ea 作者平衡
- //+------------------------------------------------------------------+
- //| 爆仓距离显示.mq4 |
- //| Copyright 2013, MetaQuotes Software Corp. |
- //| http://www.metaquotes.net |
- //+------------------------------------------------------------------+
- #property copyright "Copyright 2013, MetaQuotes Software Corp."
- #property link "http://www.metaquotes.net"
- #property indicator_chart_window
- double 爆仓距离 = 0;
- double 爆仓点位 = 0;
- extern color FontColor=DeepSkyBlue;
- extern int FontSize=12;
- extern string FontType="Arial";
- extern int WhatCorner=4;
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //---- indicators
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
- ObjectDelete("Market_Price_Label");
- ObjectDelete("Market_Price_Label2");
- ObjectDelete("爆仓点位线");
- Comment("");
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- if(TotalLots()!=0){
- 爆仓距离=(AccountEquity()-AccountMargin()*0.2)/TotalLots()/10; //0.2代表平台强平线为20%
- 爆仓点位=Bid+爆仓距离/10000;
-
-
- ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0);
- ObjectSetText("Market_Price_Label", "爆仓距离: "+DoubleToStr(爆仓距离,2)+"(点)", FontSize, FontType, FontColor);
- ObjectSet("Market_Price_Label", OBJPROP_CORNER, WhatCorner);
- ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 1);
- ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, 20);
-
- ObjectCreate("Market_Price_Label2", OBJ_LABEL, 0, 0, 0);
- ObjectSetText("Market_Price_Label2", "爆仓点位: "+DoubleToStr(爆仓点位,5), FontSize, FontType, FontColor);
- ObjectSet("Market_Price_Label2", OBJPROP_CORNER, WhatCorner);
- ObjectSet("Market_Price_Label2", OBJPROP_XDISTANCE, 1);
- ObjectSet("Market_Price_Label2", OBJPROP_YDISTANCE, 40);
-
-
- ObjectDelete("爆仓点位线");
- ObjectCreate("爆仓点位线",OBJ_HLINE,0,0,爆仓点位);
- ObjectSet("爆仓点位线",OBJPROP_COLOR,Red);
- ObjectSet("爆仓点位线",OBJPROP_STYLE,STYLE_DOT);
- }
-
- else{
-
- ObjectDelete("爆仓点位线");
-
- ObjectCreate("Market_Price_Label", OBJ_LABEL, 0, 0, 0);
- ObjectSetText("Market_Price_Label", "爆仓距离: "+"N/A", FontSize, FontType, FontColor);
- ObjectSet("Market_Price_Label", OBJPROP_CORNER, WhatCorner);
- ObjectSet("Market_Price_Label", OBJPROP_XDISTANCE, 1);
- ObjectSet("Market_Price_Label", OBJPROP_YDISTANCE, 20);
-
- ObjectCreate("Market_Price_Label2", OBJ_LABEL, 0, 0, 0);
- ObjectSetText("Market_Price_Label2", "爆仓点位: "+"N/A", FontSize, FontType, FontColor);
- ObjectSet("Market_Price_Label2", OBJPROP_CORNER, WhatCorner);
- ObjectSet("Market_Price_Label2", OBJPROP_XDISTANCE, 1);
- ObjectSet("Market_Price_Label2", OBJPROP_YDISTANCE, 40);
- }
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- double TotalLots()
- {
- double TotalLots=0;
- int Order;
- for(int i=0;i<OrdersTotal();i++)
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
- {
- if(OrderType()==OP_BUY || OrderType()==OP_SELL)
- {
- TotalLots=TotalLots+OrderLots();
- }
- }
- else
- {
- Print("OrderSelect返回的错误:",GetLastError());
- }
- }
- return(TotalLots);
- }
复制代码 |
评分
-
查看全部评分
|