外汇MT4编程:一种画线数值的编写方法

更新时间:2024-06-30 19:15:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

外汇MT4编程:一种画线数值的编写方法

外汇MT4编程:

一种获得画线数值的编写方法 非本人杰作,相信会对一些朋友有用

如何获得 所画的横线 竖线 趋势线 横竖线

趋势线的价格相信用来做 半自动EA 或指标比较实用

//下面这个函数 可以获得 最后一根横线的价格HlineBar 竖线的位置VlineBar 趋势线最后对应的价格 TrendArrayPrice[0],

实际上是TrendArrayPrice[] VlineTimeArray[] HlineArrayPrice[]

如果设置为全局数组可以把屏幕上的横线 竖线 趋势线都获得 改变数组的下标就可以了

//===========================================================int 自动获取物件()

{

RefreshRates();

int VlineCount=0;

int HlineCount=0;

int TrendCount=0;

int obj_total = ObjectsTotal();

ArrayResize(VlineTimeArray, obj_total);

ArrayResize(HlineArrayPrice, obj_total);

ArrayResize(TrendArrayPrice, obj_total);

VlineTimeArray[0]=NULL;

HlineArrayPrice[0]=NULL;

TrendArrayPrice[0]=NULL;

string name,text; int i, j;

for(i = 0; i < obj_total; i++) {

name = ObjectName(i);

if(ObjectType(name) == OBJ_VLINE) {

VlineTimeArray[VlineCount]=ObjectGet(name,OBJPROP_TIME1);

VlineCount++;

}if(ObjectType(name) == OBJ_HLINE) {

HlineArrayPrice[HlineCount]=ObjectGet(name,OBJPROP_PRICE1);

HlineCount++; }

if(ObjectType(name)==OBJ_TREND) //ObjectGetValueByShift {

TrendArrayPrice[TrendCount]=ObjectGetValueByShift(name,0);

TrendCount++;

}

}//for(i = 0; i < obj_total;

i++)VlineBar=iBarShift(Symbol(),0,VlineTimeArray[0],true);

HlineBar=HlineArrayPrice[0];

if(显示开关) {

//_Show(\订单号,0,200,0);

_ShowStr(\划线文字X位置,划线文字Y位置);

_Show(\划线文字X位置,划线文字Y位置+20,文字颜色);

_Show(\划线文字X位置,划线文字Y位置+40,文字颜色);

int obj_total = ObjectsTotal();

ArrayResize(VlineTimeArray, obj_total);

ArrayResize(HlineArrayPrice, obj_total);

ArrayResize(TrendArrayPrice, obj_total);

VlineTimeArray[0]=NULL;

HlineArrayPrice[0]=NULL;

TrendArrayPrice[0]=NULL;

string name,text; int i, j;

for(i = 0; i < obj_total; i++)

{

name = ObjectName(i);

if(ObjectType(name) == OBJ_VLINE) {

VlineTimeArray[VlineCount]=ObjectGet(name,OBJPROP_TIME1);

VlineCount++;

}if(ObjectType(name) == OBJ_HLINE) {

HlineArrayPrice[HlineCount]=ObjectGet(name,OBJPROP_PRICE1);

HlineCount++;

}

if(ObjectType(name)==OBJ_TREND) //ObjectGetValueByShift {

TrendArrayPrice[TrendCount]=ObjectGetValueByShift(name,0);

TrendCount++; }

}//for(i = 0; i < obj_total;

i++)VlineBar=iBarShift(Symbol(),0,VlineTimeArray[0],true);

HlineBar=HlineArrayPrice[0];

if(显示开关) {

//_Show(\订单号,0,200,0);

_ShowStr(\划线文字X位置,划线文字Y位置);

_Show(\划线文字X位置,划线文字Y位置+20,文字颜色);

_Show(\划线文字X位置,划线文字Y位置+40,文字颜色);

_Show(\划线文字X位置,划线文字Y位置+60,文字颜色); }

if(!显示开关) {

// ObjectDelete(\

ObjectDelete(\

ObjectDelete(\

ObjectDelete(\

ObjectDelete(\ }}

//====================================================================================== 4 在屏幕上显示自定义文字_show() 可以用来 显示 整形 double 数据

_showStr() 可以用来显示字符串可以见3 中的使用方法

//======================================================================================

void _Show(string Str,double dTemp,int dNum,int xOffset,int

yOffset,color 文字颜色) {

string Signal;

Signal=Str+\

_writetext(Str,Signal,划线文字X位置+xOffset,划线文字Y位置+yOffset,文字颜色,划线字体大小); }

//----------------------------------

void _ShowStr(string Str,string StrTemp,int xOffset,int yOffset) {

string Signal;

Signal=Str+\

_writetext(Str,Signal,划线文字X位置+xOffset,划线文字Y位置+yOffset,文字颜色,划线字体大小);

}void _writetext(string Labelname,string data,int x,int y,color ColorValue,int FontSize) {

RefreshRates();

ObjectDelete(Labelname);

ObjectCreate(Labelname, OBJ_LABEL, 0, 0, 0);

ObjectSetText(Labelname, data, FontSize, \ColorValue);

ObjectSet(Labelname, OBJPROP_CORNER, 0);

ObjectSet(Labelname, OBJPROP_XDISTANCE, x);

ObjectSet(Labelname, OBJPROP_YDISTANCE, y); }

//========================================================================================

本文来源:https://www.bwwdw.com/article/l6u3.html

Top