现成的 送你了 走过的路.....
[C++] 纯文本查看 复制代码//+------------------------------------------------------------------+
//| 显示垂线.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
extern color 垂线颜色=DarkSeaGreen;
extern int 垂线样式=0; // 0实线 1断线 2点线 3断线与点线交替 4断线与双点线交替
extern int 垂线粗细=2;
extern bool 是否全屏=true;
extern bool 于前景画对象=true;
extern int BarNum=0;
extern int ShowWindow=0;
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectDelete("FirstVLine");
ObjectDelete("FirstTLine");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
string VLineName="FirstVLine";
string TLineName="FirstTLine";
datetime BarTime;
{ BarTime=iTime(NULL,0,0)+PeriodSeconds()*BarNum; }
//----
if(是否全屏==true)
{
ObjectDelete(TLineName);
//if(ObjectFind(VLineName)!=0)
{
ObjectCreate(VLineName, OBJ_VLINE, ShowWindow, BarTime, WindowPriceMax(0));
ObjectSet(VLineName, OBJPROP_COLOR, 垂线颜色);
ObjectSet(VLineName, OBJPROP_STYLE, 垂线样式);
ObjectSet(VLineName, OBJPROP_WIDTH, 垂线粗细);
ObjectSet(VLineName, OBJPROP_BACK,于前景画对象);
}
}
else
{
ObjectDelete(VLineName);
//if(ObjectFind(TLineName)!=0)
{
ObjectCreate(TLineName, OBJ_TREND, 0, BarTime, WindowPriceMin(0), BarTime, WindowPriceMax(0));
ObjectSet(TLineName, OBJPROP_COLOR, 垂线颜色);
ObjectSet(TLineName, OBJPROP_STYLE, 垂线样式);
ObjectSet(TLineName, OBJPROP_WIDTH, 垂线粗细);
ObjectSet(TLineName, OBJPROP_RAY,true);
ObjectSet(TLineName, OBJPROP_BACK,于前景画对象);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
|