10评论

3收藏

点差

avatar zzjianchi | 1226 人阅读 | 10 人评论 | 2018-08-19

//+------------------------------------------------------------------+
//|                                                SpreadMonitor.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql4.com |
//+------------------------------------------------------------------+
#property indicator_chart_window

input int XAxis = 25;
input int YAxis = 25;
input int FontSize = 10;
input int LineSpace = 7;

double dLastSpread = 0.0;

int OnInit()
  {
//--- indicator buffers mapping
//---
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
{
   for (int i=0;i<14;i++)
      ObjectDelete(StringConcatenate("SpreadMonitor_",i));
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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 dCurrentSpread = Ask-Bid;

   SetLabel("SpreadMonitor_0","卖价:",XAxis,YAxis,"Arial",FontSize,Tomato);
   SetLabel("SpreadMonitor_1",DoubleToString(Ask,Digits),XAxis+FontSize*7,YAxis,"Arial",FontSize,Tomato);
   SetLabel("SpreadMonitor_2","买价:",XAxis,YAxis+LineSpace+FontSize,"Arial",FontSize,Aqua);
   SetLabel("SpreadMonitor_3",DoubleToString(Bid,Digits),XAxis+FontSize*7,YAxis+LineSpace+FontSize,"Arial",FontSize,Aqua);
   SetLabel("SpreadMonitor_4","点差: ",XAxis,YAxis+2*(LineSpace+FontSize),"Arial",FontSize,Red);
   SetLabel("SpreadMonitor_5",DoubleToString(dCurrentSpread,Digits),XAxis+FontSize*7,YAxis+2*(LineSpace+FontSize),"Arial",FontSize,Red);
   SetLabel("SpreadMonitor_6","交易商时间: ",XAxis,YAxis+3*(LineSpace+FontSize),"Arial",FontSize-2,White);
   SetLabel("SpreadMonitor_7",TimeToString(TimeCurrent(),TIME_DATE|TIME_MINUTES|TIME_SECONDS),XAxis+FontSize*7,YAxis+3*(LineSpace+FontSize),"Arial",FontSize-2,White);


   //--- return value of prev_calculated for next call

   dLastSpread = dCurrentSpread;

   return(rates_total);

}  

void SetLabel(string nm,string tx,int xd,int yd,string fn,int fs,color ct)
{

   if(ObjectFind(nm)<0)
      ObjectCreate(nm,OBJ_LABEL,0,0,0);  //--- create the Label object

   ObjectSet(nm,OBJPROP_STYLE,STYLE_SOLID);               
   ObjectSet(nm,OBJPROP_XDISTANCE,xd);               
   ObjectSet(nm,OBJPROP_YDISTANCE,yd);                    
   ObjectSet(nm,OBJPROP_COLOR,ct);              
   ObjectSetText(nm,tx,fs,fn,ct);                    

}

""
还没有人打赏,支持一下

评论|共 10 个

蒲公英的约定

发表于 2018-9-1 14:51:46 | 显示全部楼层

楼主辛苦了

ewmwd

发表于 2020-1-15 20:48:01 | 显示全部楼层

LZ真是人才

幻视

发表于 2020-4-17 21:58:23 | 显示全部楼层

学习了,不错,讲的太有道理了

rxj54cap

发表于 2020-6-26 16:12:00 | 显示全部楼层

小手一抖,积分到手!

ea工厂

发表于 2020-7-11 10:01:00 | 显示全部楼层

帮你顶下哈!!

tnlbv

发表于 2020-7-11 10:52:16 | 显示全部楼层

谢谢楼主分享

eetzoysc

发表于 2020-7-19 15:25:50 | 显示全部楼层

帮你顶下哈!!

tmd

发表于 2020-7-24 12:56:40 | 显示全部楼层

学习了,不错

红烧蛋疼

发表于 2020-9-3 11:07:34 | 显示全部楼层

谢谢楼主分享

12下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则