Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1269

 
Aleksei Lesnikov:

Alexei, thank you! It's clear now that it's not possible.

It's true, I don't have exactly mql4. I'm trying to change data through the CiOpen class. I'm confused by the Update method, which should change the element at a specified position of the array.

Copy it into your variables / arrays and work with them already.
 
Valeriy Yastremskiy:
Copy into your variables / arrays and work with them already.

So I did.

 

I'm very grateful for your help! I am quite new to programming.

While studying, I have faced difficulties in implementing the code. There is an article at https://www.mql5.com/ru/articles/3336 I cannot understand how comparison is performed

if(!CompareTiks(n_tiks[i], m_ticks[k]))

I suspect that "Template Data Collections" is used and there is such a global method"Compare".But the article listing does not give anywhere how to make the compiler understand that I should use "Compare" from "Data Template Collections". I haven't found any examples of global methods from"Data Template Collections".

The following entry in the global method description will not change the result

template<typename T>
int Compare(
T x, // first value
T y // second value
);

As a result, I have the following code (or rather, the code has me)

#ifndef MyInclude
#define MyInclude


//template<typename T>
//interface ICollection
//#include <Generic\Interfaces\ICollection.mqh>
template<typename T>
int Compare(
T x, // first value
T y // second value
);

class CMarketBook
{
private:
string m_symbol;
MqlTick m_ticks[];
MqlTick LastTicks[];

protected:

public:
void CMarketBook::CompareTicks(void);
};
//+------------------------------------------------------------------+
//|Compare two ticks colllection and find new ticks |
//+------------------------------------------------------------------+
void CMarketBook::CompareTicks(void)
{
MqlTick n_ticks[];
ulong T_begin = (TimeCurrent()-(1*20))*1000;//20sec ago
m_symbol = Symbol();
int Total = CopyTicks(m_symbol, n_ticks, COPY_TICKS_ALL, T_begin, 1000);
if (Total < 1) {printf("Failed to get ticks"); return;}
if (ArraySize(m_ticks) == 0) {ArrayCopy(m_ticks, n_ticks, 0, 0, WHOLE_ARRAY); return;}

int k = ArraySize(m_ticks)-1;
int n_t = 0;
int Limit_comp = 20;
int Comp_success = 0;

// Try new received ticks
for (int i = ArraySize(n_ticks)-1; i>=0 && k>=0; i--)
{
if (!Compare(n_ticks[i], m_ticks[k]))
{
n_t = ArraySize(n_ticks) - i;
k = ArraySize(m_ticks) - 1;
Comp_success = 0;
}
else
{
Comp_success += 1;
if (Comp_success >= Limit_comp) break;
k--;
};
};
//Memorize received ticks
ArrayResize(m_ticks, Total);
ArrayCopy(m_ticks, n_ticks, 0, 0, WHOLE_ARRAY);
//Calculate start index of new ticks and copy it into the buffer for access
ArrayResize(LastTicks, n_t);
if (n_t > 0)
{
int index = ArraySize(n_ticks) - n_t;
ArrayCopy(LastTicks, m_ticks, 0, index, n_t);
};
};
#endif

When compiling, an error is generated - "object is passed by reference only" to the line if (!Compare(n_ticks[i], m_ticks[k])) pointing ton_ticks[i]

Пишем скальперский стакан цен на основе графической библиотеки CGraphic
Пишем скальперский стакан цен на основе графической библиотеки CGraphic
  • www.mql5.com
Именно с этой, улучшенной и дополненной версией мы и начнем работать, чтобы постепенно превратить ее в скальперский стакан цен. Краткий обзор графической библиотеки CPanel Созданию пользовательских интерфейсов в MQL5 посвящено много статей. Среди них особенно выделяется серия Анатолия Кажарского "Графические интерфейсы", после которой сложно...
 
When using mobile internet, no SendNotification... When connecting to wi-fi, they come (even the ones that didn't come when using mobile internet). Is this a problem on ISP side? I think all permissions are enabled in mobile internet settings...
 

Good afternoon everyone.

I am testing an Alpari MT4 Expert Advisor. Before I do the test, MT suggests me to set the spread (either the current value or a specific one).


At Alpari, the spread is floating. That is why the above-mentioned spread size settings do not suit me.

Q. Which function displays on history the spread values for each historical tick?
Or, how should I make my EA open and close orders considering the spread values valid at the moment the order is opened or closed?

Thank you all for your help.

 
ANDREY:

Good afternoon everyone.

I am testing an Alpari MT4 Expert Advisor. Before testing MT suggests me to set spread value ( current or any particular value from offered).


At Alpari the spread is floating. That is why the aforementioned spread values do not work for me.

Q. Which function displays on the history the spread values for each historical tick?
Or, how should we make our EA open and close orders considering the spread values valid at the moment the order is opened or closed?

Thank you all for your help.

You cannot do that in MT4, but you can in MT5

 
Vladimir Pastushak:

Not in MT 4, in MT 5 you can

Thank you very much for the valuable information.

I will start studying mql5. They say that it's very similar to mql4. I would be very grateful to you if you could tell me how to implement my idea in mql5.

 
ANDREY:

Thank you very much for the valuable information.

I will start studying mql5. They say that it is very similar to mql4. I would be very grateful to you if you could tell me how mql5 implements my idea.

You do not need to do anything with mt5.
Everything happens automatically and EA trades with floating spread in strategy tester.
 
Vladislav Andruschenko:
In mt5 you don't need to invent anything.
Everything happens automatically and the EA trades with a floating spread in the strategy tester .

This is cool. Thanks for the valuable information.

If you want to quickly switch from mql4 to mql5, you better read the manuals for mql4 and mql5 simultaneously and pay attention to differences between them. Everything is learned by comparison.....
 

Good day to all!

I have started studying mql5. I started by studying how orders are opened. I have understood that the code for opening an order is written in a separate include file. I have now mastered this code and its final variant for trading. I was amazed that the order opening in mql4 is much easier and simpler than in mql5.

I would like to ask if I am sure I already have the file with the code to open the order and I don't need to write this code. If such a file is available somewhere, then I only need to connect it to my EA and set the values of the order parameters I need? If there is such a file, where and how it should be found, and what its name is.

I will be happy to give you the name of the file.