量化交易之MQL4篇 - MT4盘面上添加线、矩形、文本

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window

int start() {
   
   //CreateColorRect("rect", High[2], Low[0], Red);
   
   /*
   string foo = DoubleToString(Bid, Digits);
   foo += foo;
   
   CreateText("text", Time[4], High[5], foo);
   */
   
   // CreateLine("line", High[0], Red); 
   
   return 0;


void CreateColorRect(string objectName, double startValue, double endValue, color colorValue) {
   

   ObjectDelete(objectName);

   // Time[3]: left of rect.   startValue: top of rect.   Time[0]: right of rect.    endValue: bottom of rect;
   ObjectCreate(objectName, OBJ_RECTANGLE, 0, Time[3], startValue, Time[0], endValue);
   ObjectSet(objectName, OBJPROP_COLOR, colorValue);
   ObjectSet(objectName, OBJPROP_WIDTH, 1);
   ObjectSet(objectName, OBJPROP_STYLE, 0);
   // false: rect中间是透明的. true: rect中间不是透明的
   ObjectSet(objectName, OBJPROP_BACK, false);
   
}

void CreateText(string objectName, datetime timeValue, double dataValue, string stringValue) {
   
   ObjectDelete(objectName);
   // timeValue: middle of text is equal to middle of timeValue. dataValue: top of text is equal to top of dataValue.
   ObjectCreate(objectName, OBJ_TEXT, 0, timeValue, dataValue);
   ObjectSetText(objectName, stringValue, 10, "Arial", Yellow);
   
}

void CreateLine(string objectName, double data, color colorValue) {
   
   ObjectDelete(objectName);
   // data: top of line
   ObjectCreate(objectName, OBJ_HLINE, 0, 0, data);
   ObjectSet(objectName, OBJPROP_COLOR, colorValue);
   
}

int deinit(){

   ObjectsDeleteAll();
   
   return 0;




  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值