Discussion of article "Data Exchange between Indicators: It's Easy"

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
200895
MetaQuotes Software Corp.  

New article Data Exchange between Indicators: It's Easy is published:

The article describes an easy method to develop a program environment for the MetaTrader terminal, that would provide means for accessing indicator buffers from other MQL programs.

Author: Алексей

brisully
45
brisully  

I've noticed that with the new MT4 builds the SetIndicatorValue() function doesn't work, but GetIndicatorValue() does. Is this just me, or is there something in the new builds (I think the change happened somewhere after Build 225) that broke that function? If so, any suggestions on how to get the methodologies in this article to work on the new MT4 builds? The fact that the old builds aren't supported anymore is causing me a problem in this regard, as I'd really like to have indicator calculations happen only once, in an EA, but still be displayed on charts by pushing the calculated values to the indicator buffers' pointers. (BTW, I was really grateful to find this article and to be able to apply its techniques - thank you for writing it.)

A related question is that I noticed that on the release notes for Build 392 of MT4 on 3/17/2011, it says, "3. Removed unnecessary recalculations of indicators when displaying them on a chart." Does this improvement effectively negate the need for the techniques in this article in that using custom indicators in the way they were intended will no longer be slower than using the pointer-based techniques taught in this article? Thank you.

brisully
45
brisully  
brisully:

I've noticed that with the new MT4 builds the SetIndicatorValue() function doesn't work, but GetIndicatorValue() does. Is this just me, or is there something in the new builds (I think the change happened somewhere after Build 225) that broke that function? If so, any suggestions on how to get the methodologies in this article to work on the new MT4 builds? The fact that the old builds aren't supported anymore is causing me a problem in this regard, as I'd really like to have indicator calculations happen only once, in an EA, but still be displayed on charts by pushing the calculated values to the indicator buffers' pointers. (BTW, I was really grateful to find this article and to be able to apply its techniques - thank you for writing it.)

A related question is that I noticed that on the release notes for Build 392 of MT4 on 3/17/2011, it says, "3. Removed unnecessary recalculations of indicators when displaying them on a chart." Does this improvement effectively negate the need for the techniques in this article in that using custom indicators in the way they were intended will no longer be slower than using the pointer-based techniques taught in this article? Thank you.

It seems I was mistaken, and that the indicator files attached to the article do work in the new builds of MT4. Sorry for the false alarm, and thanks again for this work.
Kourosh Davallou
63148
Kourosh Davallou  
thank you
Guo Wei Long
190
Guo Wei Long  
ponter address should be unsigned int, not just int
HarriMQL5
330
HarriMQL5  
This is most excellent! Ive adjusted the code so that the functions work with something a little more useful than a double (in my case) - a structure - specifically MqlRates.
Files:
cpp.zip 44 kb
exchng.mqh 2 kb
exchng.mq4 12 kb
JamesMQL
6
JamesMQL  
How can modify this code so that it can be capable to exchange array having struct type element not only double?
fxsaber
10636
fxsaber  
JamesMQL:
How can modify this code so that it can be capable to exchange array having struct type element not only double?

Форум по трейдингу, автоматическим торговым системам и тестированию торговых стратегий

Библиотеки: TradeTransactions

fxsaber, 2018.09.20 16:23

// Пример хранения/обмена данными через Ресурсы внутри Терминала
#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/ru/code/22166

void OnStart()
{  
  const RESOURCEDATA<int> ResourceINT("::int"); // Ресурс для обмена int-ами. const - как доказательство, что ничего не пишется в объект класса
  
  int ArrayINT[] = {1, 2, 3};
  int Num = 5;
  
  ResourceINT = ArrayINT;  // Ресурс хранит массив.
  ResourceINT += Num;      // Добавили в ресурс еще значение.
  ResourceINT += ArrayINT; // Добавили массив.
  
  int ArrayINT2[];  
  ResourceINT.Get(ArrayINT2); // Считали данные из ресурса.
  ArrayPrint(ArrayINT2);      // Вывели: 1 2 3 5 1 2 3

  ResourceINT.Free();                // Удалили данные из ресурса
  Print(ResourceINT.Get(ArrayINT2)); // Убедились, что данных нет: 0

  const RESOURCEDATA<MqlTick> ResourceTicks("::Ticks"); // Ресурс для обмена тиками. const - как доказательство, что ничего не пишется в объект класса
  MqlTick Tick;
  
  if (SymbolInfoTick(_Symbol, Tick))
    for (int i = 0; i < 3; i++)
      ResourceTicks += Tick; // Добавили в ресурс тики

  MqlTick Ticks[];
  ResourceTicks.Get(Ticks); // Считали данные из ресурса.
  ArrayPrint(Ticks);        // Вывели.
  
  // Это полное имя ресурса для обращения из другой программы
  const string NameOut = StringSubstr(MQLInfoString(MQL_PROGRAM_PATH), StringLen(TerminalInfoString(TERMINAL_PATH)) + 5) + "::Ticks";  
  Print(NameOut); // Вывели полное имя ресурса.
  
  const RESOURCEDATA<MqlTick> Resource(NameOut); // Ресурс для доступа к данным (read-only) из другой программы
  
  MqlTick TicksOut[];
  Resource.Get(TicksOut); // Считали данные из ресурса.
  ArrayPrint(TicksOut);   // Вывели.
  
  Resource.Free();   // Не получится повлиять на данные read-only-ресурса.
  Print(_LastError); // ERR_INVALID_PARAMETER - Ошибочный параметр при вызове системной функции.
}
JamesMQL
6
JamesMQL  
fxsaber:

Thank you for your help, but

- I don't understand this code. Where the struct in it?

- I need MQL4 solution

To add comments, please log in or register