| 两个 K 线之间连线是屏显的重要内容。以下源码范例提交了静态和动态连线的方法: 
 
 复制代码#property copyright "Copyright 2012, laoyee"
#property link "http://www.docin.com/yiwence"
//新价格到达时运行一次
int start()
{
//两点间静态连线
iTwoPointsLine("15-5",Time[15],High[15],Time[5],High[5],0,Red);
//两点间动态连线
ObjectDelete("动态虚线");
iTwoPointsLine("动态虚线",Time[5],High[5],Time[0],Close[0],2,Blue);
return(0);
}
//程序加载时运行一次
int init()
{
return(0);
}
//程序卸载时运行一次
int deinit()
{
return(0);
}
/*
函 数:两点间连线(主图)
输入参数:string myLineName 线段名称
int myFirstTime 起点时间
int myFirstPrice 起点价格
int mySecondTime 终点时间
int mySecondPrice 终点价格
int myLineStyle 线型 0-实线 1-断线 2-点线 3-点划线 4-双点划线
color myLineColor 线色
输出参数:在指定的两点间连线
算法说明:
*/
void  iTwoPointsLine(string  myLineName,int  myFirstTime,double  myFirstPrice,int  mySecondTime,double  mySecondPrice,int
myLineStyle,color myLineColor)
{
ObjectCreate(myLineName,OBJ_TREND,0,myFirstTime,myFirstPrice,mySecondTime,mySecondPrice);//确定两点坐标
ObjectSet(myLineName,OBJPROP_STYLE,myLineStyle); //线型
ObjectSet(myLineName,OBJPROP_COLOR,myLineColor); //线色
ObjectSet(myLineName,OBJPROP_WIDTH, 1); //线宽
ObjectSet(myLineName,OBJPROP_RAY,false);
}
 静态线命名为“15-5” ,将第 15 根 k 线和第 5 根 k 线的最高价连线。动态线命名为“动态虚线”将第 5 根 k 线的最高价与当前报价连线,由于每次新价格不同,所以先删除原有线段再重新画线,完成动态连线的任务。
 
 
 
 
   
 |