Good afternoon! Can't you transfer from .mqh to the indicator? Or is there some trick to not reset every time when compiling the indicator? I made such a variant, but it resets when compiling the indicator:
#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/en/code/22166#include <GlobalVariables.mqh> // https://www.mql5.com/ru/forum/189649#comment_4854618const RESOURCEDATA<MqlTick>m_Resource("::"+__FILE__); // Resource for data transfer (ticks)class CMyTicks
{
protected:
public:
//+------------------------------------------------------------------+//| Constructor.|//+------------------------------------------------------------------+ void CMyTicks()
{
_GlobalVariableSet("ResourceName",m_Resource.GetFullName()); // Write the full name of the resource (read-only) to the global variable
}
//+------------------------------------------------------------------+//| Destructor.|//+------------------------------------------------------------------+ void ~CMyTicks()
{
//_GlobalVariableDel("ResourceName");
}
//+------------------------------------------------------------------+ void CollectTicks()
{
MqlTick m_Ticks[];
CopyTicks(_Symbol,m_Ticks,COPY_TICKS_ALL,0,5); // Generated data
m_Resource=m_Ticks; // Recorded the data
}
};
//+------------------------------------------------------------------+
// Data retrieval#property indicator_chart_window#property indicator_plots0#include <Test_Keep_Info_13.mqh>
CMyTicks Test;
#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/en/code/22166#include <GlobalVariables.mqh> // https://www.mql5.com/ru/forum/189649#comment_4854618staticconst RESOURCEDATA<MqlTick>Resource(_GlobalVariableGet<string>("ResourceName")); // Created a resource based on the full name passed in the global variable MqlTick Ticks[];
intOnCalculate(constint rates_total,constint prev_calculated,constint,constdouble &[])
{
if(prev_calculated==0)
{
Resource.Get(Ticks); // Read data from the resource.ArrayPrint(Ticks); // Print the obtained dataif(ArraySize(Ticks)<1)
{
Test.CollectTicks();
Print(" SAVE TICKS ");
}
Resource.Get(Ticks); // Read data from the resource.ArrayPrint(Ticks); // Print the obtained data
}
return(rates_total);
}
//+------------------------------------------------------------------+
And on the account of "someone else will explain", so I already know the answer, will be "ask the author". Thank you!
Good afternoon! Can't you transfer from .mqh to the indicator? Or is there some trick to not reset every time the indicator is compiled? I made such a variant, but it resets when compiling the indicator:
And on the account of "someone else will explain", so I already know the answer, will be "ask the author". Thank you!
The object is static, but the data is destroyed. What is wrong in my example?
Unfortunately, you have big gaps in your understanding of OOP, so you are not getting what you intended. Ask on the forum for help with general OOP questions.
// Example of exchanging any data (including string arrays).#include <fxsaber\TradeTransactions\ResourceData.mqh> // https://www.mql5.com/en/code/22166#define PRINT(A) Print(#A + " = " + (string)(A));
voidOnStart()
{
// Arbitrary data for the examplestring Str[] = {"123", "Hello World!"};
double Num = 5;
MqlTick Tick = {0};
Tick.bid = 1.23456;
const RESOURCEDATA<uint> Resource; // Resource for data sharing
CONTAINER<uint> Container; // Create a container - everything will be stored in an array of a simple type (uint is chosen in the example)// Fill the container with different data
Container[0] = Str;
Container[1] = Num;
Container[2] = Tick;
// Print the types of data stored in the containerfor (int i = 0; i < Container.GetAmount(); i++)
PRINT(Container[i].GetType())
Resource = Container.Data; // Sent the data for exchange
CONTAINER<uint> Container2; // This is where we will get the data
Resource.Get(Container2.Data); // Got the data// Get the data in its original formstring Str2[];
Container[0].Get(Str2); // Got the arrayArrayPrint(Str2);
PRINT(Container[1].Get<double>()) // We got a number
PRINT(Container[2].Get<MqlTick>().bid) // We got the structure
}
According to the first tests, I assume that for double and datetime we should make separate resources and name of global variables. Is this correct?
According to the first tests, I assume that for double and datetime we should make separate resources and name of global variables. Is this correct?
Unfortunately, it is very difficult to reach your level of programming language proficiency. Perhaps someone else will explain it to you.
Unfortunately, it is very difficult to get to your level of programming language proficiency. Perhaps someone else will explain it to you.
Well, the main thing is that everything works for me so far.
Update ResourceData.mqh and try these indicators
Good afternoon! Can't you transfer from .mqh to the indicator? Or is there some trick to not reset every time when compiling the indicator? I made such a variant, but it resets when compiling the indicator:
And on the account of "someone else will explain", so I already know the answer, will be "ask the author". Thank you!
Good afternoon! Can't you transfer from .mqh to the indicator? Or is there some trick to not reset every time the indicator is compiled? I made such a variant, but it resets when compiling the indicator:
And on the account of "someone else will explain", so I already know the answer, will be "ask the author". Thank you!
Unfortunately, I can't understand the question.
Unfortunately, I can't understand the question.
The object is static, but the data is destroyed. What is wrong in my example?
The object is static, but the data is destroyed. What is wrong in my example?
Unfortunately, you have big gaps in your understanding of OOP, so you are not getting what you intended. Ask on the forum for help with general OOP questions.
Unfortunately, you have big gaps in your understanding of OOP, so it doesn't work out as intended. Ask the forum for help with general OOP questions.
Okay, thanks.
The library sources contain Convert.mqh, which quickly converts an array of one type into an array of another type.
You can exchange anything through Resources.