//+------------------------------------------------------------------+//| TestCopy.mq4 |//| Copyright 2016, Artem A. Trishkin, Skype artmedia70 |//| https://login.mql5.com/ru/users/artmedia70 |//+------------------------------------------------------------------+#property copyright"Copyright 2016, Artem A. Trishkin, Skype artmedia70"#property link"https://login.mql5.com/ru/users/artmedia70"#property version"1.00"#property strict#property script_show_inputsenum enumYN
{
enYes=1, // Да
enNo=0, // Нет
};
//--- input parametersinputint Search_Period=10; // Количество копируемых свечейint searchPeriod=(Search_Period<1)?1:Search_Period;
inputint Delta=2; // Количество пунктов допускаint delta=(Delta<0)?0:Delta;
input enumYN AsSeries=enYes; // Массив array как таймсерияMqlRates array[]; // Массив структур для копирования Open, High, Low, Close, Timestruct DataCandle // Структура для хранения всех совпадений
{
int number_matched; // Количество совпаденийMqlRates reference_candle; // Данные эталонной свечиMqlRates matched_candles[]; // Массив свечей, совпадающих с эталонной по нужному критерию
};
DataCandle dataCandle[]; // Массив структур данных свечей и их совпадений//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
//---int copy_bars=(int)fmin(Search_Period,Bars(Symbol(),Period())); // количество копируемых свечейint copied=CopyRates(Symbol(),PERIOD_CURRENT,1,copy_bars,array); // копируем данныеif(copied>0) { // если скопировалиArraySetAsSeries(array,AsSeries); // задаём массив как таймсерию или нетArrayResize(dataCandle,copied); // задаём размер структуры равным числу скопированных данныхZeroMemory(dataCandle); // Обнуляем данные в структуре//--- основной цикл по "эталонным" свечам в массиве array. Их параметры будем искать в доп. циклеfor(int i=0; i<copy_bars-1; i++) { // цикл по скопированным данным от начала до "на один меньше размера массива"
dataCandle[i].reference_candle.high=array[i].high; // ищем этот high
dataCandle[i].reference_candle.low=array[i].low; // запомнили low для сравнения
dataCandle[i].reference_candle.time=array[i].time; // запомнили time для вывода в журнал//--- поиск совпадений с эталонной свечой, индексируемой индексом основного цикла iint size=0; // размер массива совпадающих свечейArrayResize(dataCandle[i].matched_candles,size); // Размер массива совпадений в ноль
dataCandle[i].number_matched=size; // Инициализируем количество совпадений нулём//--- теперь ищем совпадения по high свечей в цикле j с high эталонной свечи с индексом ifor(int j=0; j<copy_bars; j++) { // в цикле от i+1 до copy_barsif(j==i) continue; // пропустим свечу "саму себя"//--- если совпадают high эталонной свечи (i) и свечи с индексом j (с допуском на величину Point)if(NormalizeDouble(delta*Point()-fabs(array[i].high-array[j].high),Digits())>=0) {
size++;
ArrayResize(dataCandle[i].matched_candles,size); // увеличим размер массива совпадающих свечей
dataCandle[i].number_matched=size; // запишем количество совпадений
dataCandle[i].matched_candles[size-1].high=array[j].high; // запишем в массив high совпадающей свечи
dataCandle[i].matched_candles[size-1].low=array[j].low; // запишем в массив low совпадающей свечи
dataCandle[i].matched_candles[size-1].time=array[j].time; // запишем в массив время совпадающей свечи//Print("Время свечи ",i," :",TimeToString(dataCandle[i].reference_candle.time=array[i].time),", high=",DoubleToString(dataCandle[i].reference_candle.high=array[i].high,Digits()),". Совпадение со свечой ",TimeToString(dataCandle[i].matched_candles[size-1].time=array[j].time),", её high ",DoubleToString(dataCandle[i].matched_candles[size-1].high=array[j].high,Digits()),". Совпадений: ",(string)dataCandle[i].number_matched);
}
}
}
}
//--- Посмотрим чего понаписали в массивыAlert("Array is series: ",ArrayIsSeries(array),
"\ntime array[0]: ",TimeToString(array[0].time,TIME_DATE|TIME_MINUTES),
"\ntime array[",string(searchPeriod-1),"]: ",TimeToString(array[ArraySize(array)-1].time,TIME_DATE|TIME_MINUTES));
for(int i=0; i<ArraySize(dataCandle)-1; i++) {
string refs_txt="";
string matched_txt="";
refs_txt="Свеча "+IntegerToString(i,2,'0')+": время "+TimeToString(dataCandle[i].reference_candle.time)+", high: "+DoubleToString(dataCandle[i].reference_candle.high,Digits())+" имеет совпадений: "+(string)dataCandle[i].number_matched+" шт. ";
if(dataCandle[i].number_matched>0) {
for(int j=0; j<ArraySize(dataCandle[i].matched_candles); j++) {
matched_txt="Совпадение "+IntegerToString(j+1)+": "+TimeToString(dataCandle[i].matched_candles[j].time)+", high: "+DoubleToString(dataCandle[i].matched_candles[j].high,Digits());
}
}
Print(refs_txt,matched_txt);
}
}
//+------------------------------------------------------------------+
Andrey Voytenko: Is it possible to know the PPI(pixels per inch) value through the graphics parameters? I really need it for my panel. WinAPI is not an option.
Found in announcements:
MQL5: Added TERMINAL_SCREEN_DPI value to ENUM_TERMINAL_INFO_INTEGER client terminal properties list - resolution of screen output is measured in number of points per linear inch (DPI). Knowing this parameter allows you to size graphical objects so that they look the same on monitors with different resolutions.
When writing an article, when trying to insert a picture, there is no "pictures only" filter - the selected folder shows absolutely all files, even those that have nothing to do with pictures at all.
so, when the indicator is attached to the chart - the comment does not display the current position of the mouse cursor,
If you click on the chart - it displays the last coordinates, and further does not change them when moving, i.e. the CHARTEVENT_MOUSE_MOVE parameter does not work in this case
The problem can only be solved in the following way
when any Expert Advisor is attached to a chart - further the indicator updates the comment normally, i.e. it follows the cursor and displays its coordinates.
Even if you then remove the Expert Advisor from the chart - the indicator normally displays the cursor coordinates.
The sequence of actions:
1. open a new chart
2. Throw the test indicator
3. Comment does not display theCHARTEVENT_MOUSE_MOVE flag(id=0)
4. I put any Expert Advisor on the chart
5. The indicator starts displaying theCHARTEVENT_MOUSE_MOVE (id=10) action normally
The home page of the website displays HTML characters in the text. Chrome 64 Win 10 64.
Compilation error
ArrayIsSeries() always produces false in this script:
Is it possible to know the PPI(pixels per inch) value through the graphics parameters? I really need it for my panel. WinAPI is not an option.
Found in announcements:
MQL5: Added TERMINAL_SCREEN_DPI value to ENUM_TERMINAL_INFO_INTEGER client terminal properties list - resolution of screen output is measured in number of points per linear inch (DPI). Knowing this parameter allows you to size graphical objects so that they look the same on monitors with different resolutions.
Found it in the announcement: TERMINAL_SCREEN_DPI
Will this help?
Please help with the error,
Forum on trading, automated trading systems and testing trading strategies
ERROR!!! OnChartEvent in the indicator does not work CHARTEVENT_MOUSE_MOVE until you load it on the EA chart.
Vladislav Andruschenko, 2016.05.13 12:29
OnChartEvent does not work in the indicator CHARTEVENT_MOUSE_MOVE, until you load it on the chart of Expert Advisor
The actual sabotage.
2016.05.13:23:49.434 Windows 7 Ultimate (x64 based PC), IE 11.00, 8 x Intel Core i7-6700 @ 3.40GHz, RAM: 22784 / 32684 Mb, HDD: 16315 / 1498122 Mb, GMT+02:00
So.
there is a check indicator
the code is minimal:
so, when the indicator is attached to the chart - the comment does not display the current position of the mouse cursor,
If you click on the chart - it displays the last coordinates, and further does not change them when moving, i.e. the CHARTEVENT_MOUSE_MOVE parameter does not work in this case
The problem can only be solved in the following way
when any Expert Advisor is attached to a chart - further the indicator updates the comment normally, i.e. it follows the cursor and displays its coordinates.
Even if you then remove the Expert Advisor from the chart - the indicator normally displays the cursor coordinates.
The sequence of actions:
1. open a new chart
2. Throw the test indicator
3. Comment does not display theCHARTEVENT_MOUSE_MOVE flag(id=0)
4. I put any Expert Advisor on the chart
5. The indicator starts displaying theCHARTEVENT_MOUSE_MOVE (id=10) action normally
OnChartEvent in the indicator, CHARTEVENT_MOUSE_MOVE does not work, until you download the Expert Advisor on the chart
Please help with the error,
The first question the developers will ask you is is CHART_EVENT_MOUSE_MOVE on?
Thank you. Something I didn't know. ... .. .... ...