错误、漏洞、问题 - 页 2614

 
Andrei Kossarev:
从指标中读取二进制文件不起作用,从EA中读取类似的代码却能顺利工作!

指标中的ChartScreenShot 很可能以异步方式工作。

 
fxsaber:

指标中的ChartScreenShot很可能是异步工作的。

检查过了,这就是为什么我放了一个循环

 
Andrei Kossarev:

我检查过了,这就是为什么我放了一个循环

结束循环并不能保证有一个文件。

 

Andrei Kossarev:
Не работает чтение бинарного файла из индикатора, аналогичный код из советника работает без проблем!

void TestPhoto() {
   string name;
   MqlDateTime  dtLocal;
   TimeToStruct(TimeLocal(), dtLocal);
   string date = IntegerToString(dtLocal.year) + IntegerToString(dtLocal.mon, 2, '0') + IntegerToString(dtLocal.day, 2, '0');
   string time = IntegerToString(dtLocal.hour, 2, '0') + "." + IntegerToString(dtLocal.min, 2, '0') + "." + IntegerToString(dtLocal.sec, 2, '0');
   name = "ScreenShots/" + date + "/" + _Symbol + "_" +date + "_" + time + ".png";
   
   if (!ChartScreenShot(0, name, 1920,1200, ALIGN_RIGHT))
      return;

   ResetLastError();
   
   for (int i=0; i < 100000; i++){
      if (FileIsExist(name,false) && FileSize(name) > 0)
         break;
   }
   //---
   int flags=FILE_READ|FILE_BIN|FILE_SHARE_READ;

   //---
   int file=FileOpen(name,flags);
   if(file<0) {
      Print("Операция FileOpen неудачна, ошибка ",GetLastError());
      return;
}
   uchar photo[];
   FileReadArray(file,photo);
   FileClose(file);
   
   Print(ArraySize(photo));
}

你的代码中存在错误,这难道不令你烦恼吗?

ulong  FileSize( 
   int  file_handle      // handle файла 
   );

FileSize函数 期望的是int变量,而你把字符串...

 
//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots   1
#property indicator_buffers 1
#include <Trident\TCoreMain.mqh>
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   ::EventSetMillisecondTimer(500);
   return(INIT_SUCCEEDED);
  }
  
  void OnDeinit(const int reason) {
   ::EventKillTimer();
}

void OnTimer() {
   ::EventKillTimer();
   TestPhoto();
}
//+------------------------------------------------------------------+
//| 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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

void TestPhoto() {
   string name;
   MqlDateTime  dtLocal;
   TimeToStruct(TimeLocal(), dtLocal);
   string date = IntegerToString(dtLocal.year) + IntegerToString(dtLocal.mon, 2, '0') + IntegerToString(dtLocal.day, 2, '0');
   string time = IntegerToString(dtLocal.hour, 2, '0') + "." + IntegerToString(dtLocal.min, 2, '0') + "." + IntegerToString(dtLocal.sec, 2, '0');
   name = "ScreenShots/" + date + "/" + _Symbol + "_" +date + "_" + time + ".png";
   
   if (!ChartScreenShot(0, name, 1920,1200, ALIGN_RIGHT))
      return;

   ResetLastError();
   
   //---
   int flags=FILE_READ|FILE_BIN|FILE_SHARE_READ;

   //---
   int file=FileOpen(name,flags);
   if(file<0) {
      Print("Операция FileOpen неудачна, ошибка ",GetLastError());
      return;
   }
   
   for (int i=0; i < 100000; i++){
      if (FileSize(file) > 0)
         break;
   }
   
   uchar photo[];
   FileReadArray(file,photo);
   FileClose(file);
   
   Print(ArraySize(photo));
}

纠正了代码,仍然无法工作

 
Andrei Kossarev:

纠正了代码,仍然无法工作

试着把代码分成两个独立的函数。

1.阅读文件并跟进。

2.拍一张截图。

如果结果是空的,那就试着做标记。和序列的函数调用,首先尝试读取,但由标志读取被跳过,然后撇开,由标志被执行和标志被切换。此后,在下一次打勾时,文件被读取。

 

建议 - 添加另一个字段来存储用户信息,经纪人不能更改,并且在翻转时必须保存。

简而言之,一个不可破坏的领域,只能由用户改变。

 
Михаил:

建议 - 添加另一个字段来存储用户信息,经纪人不能更改,并且在翻转时必须保存。

简而言之,一个不可破坏的领域,只能由用户改变。

加100600
 
Vladislav Andruschenko:
加100600

不会的,MT的服务器部分需要重写,已经有10多年没有做了,所以在不久的将来会有的,使用给你的东西--文件、终端的全局变量、DB

我在文件中写下了订单的状态,我使用了我的通用数据库的模板:https://www.mql5.com/ru/forum/85652/page17#comment_12370424

这里是开发商的最新报价--一个SQLite数据库https://www.mql5.com/ru/forum/327940

 
Igor Makanu:

不会的,MT的服务器部分需要重写,已经有10多年没有做了,所以在不久的将来会有的,使用给你的东西--文件、终端的全局变量、DB

我在文件中写下了订单的状态,我使用了我的通用数据库的模板:https://www.mql5.com/ru/forum/85652/page17#comment_12370424

这是开发人员的最新产品--一个SQLite DBhttps://www.mql5.com/ru/forum/327940


是的,我也将信息存储在一个数据库中。但是......但是......但是......。