First we remember the size of the array, then we pre-check the index for no more than the size of the array.
When looking for extrema, I don't know how many there will be either. I store how many I found in the variable. After that, I check if the number of extrema found is not coming out. I am working with static arrays where an overstepping is fraught with null or random values.
I do not like dynamic arrays, but your case is quite large.
I understood your task as looking for the same daily minima.
I would solve it this way. First, I would memorize the minimum extrema into the array (in the picture you have it exactly like that, and in the condition you are comparing all the daily Low prices). And then I would look for the same ones with some accuracy.
4)Aleksey Stepanenko- A man who is not just talking but has written a code from scratch, but the problem remains.
5) And all the rest.
Here we go: I have tested the code writtenby Aleksei Stepanenko#property version "2.00".
See screenshot 1
What we see is that Day1 and DayMin are at one parallel 0.67366 ,
Further: if there would be no history for this instrument, it would be normal.
We look at screenshot 2
We open the tool, cast the lines; it does not wobble in the tester
and go by the history manually.
We look atthe screenshot 3
In the history of 2019.10.16 at 15.00 we find the daily low
Let's cast the line and go backward
We look atscreenshot 4
And then we understand that something is wrong here and the level (value) of DayMin on the screenshot 1 should be = 67233
I'm just starting to learn MQL4 it's hard for me to understand codeby Aleksei Stepanenko(there's a class in the class, arrays are rewriting things, etc.).
I have a question for experts on how your indicators and all your products work (I'd be ashamed of it)
On page 9 of the post the reason for the appeal in expanded form#88 https://www.mql5.com/ru/forum/357558/page9#comment_19689951
The algorithm does what it says, not what you think it does. I also print to a file and see what's counted, and often it's not what I think it is, but what I've written.
The algorithm does what it says, not what you think. I also print to a file and see what is calculated there, and often, not at all what I planned, but what I wrote.
I don't know how anyone writes code.
But personally, I write everything simply and clearly for myself in the current styles and I can’t get random values.
but it is clear from where the legs grow. and if out of range it is so, and not whistled further.
(the algorithm does what is written, and not as you think ) the algorithm should do as you think and not as it wants. otherwise it is a drain of the deposit. And personally, this option does not suit me.
example global variables (Although this may seem like an antediluvian to some)
//+------------------------------------------------------------------+//| new_test.mq4 |//| Copyright 2020, MetaQuotes Software Corp. |//| https://www.mql5.com |//+------------------------------------------------------------------+#property copyright"Copyright 2020, MetaQuotes Software Corp."#property link"https://www.mql5.com"#property version"1.4"#property strict//------------------------------------------------------------------+int Order_MagicNumber; // для авто торговли int Magic = 0 ; //для ручная торговля//------------------------------------------------------------------+externcolor Color = Black; // Color линия Bidexternbool Objects = true ; // Удалять объекты созданные Cоветникомexternint In_Time = 3 ; // Время входа эксперта на рынок (время терминала)externint Out_Time = 23 ; // Время выхода эксперта с рынка (время терминала)externint Time_End_Friday = 18 ; // Время после которого не торгуем в пятницу (время терминала)externstring r_t = "" ; // + externint Step = 10 ; // Step trailing stop ( Шаг трал стопа ) //--------------------------------------------------------------------------------------------------------externstring R_T = "Параметры" ; // ===================== Ручная Торговля ====================externint Take_Profit = 5000 ; // Take Profit externint Stop_Loss = 1200 ; // Stop Loss externint Stop_Loss_Profit = 15 ; // Stop loss without loss ( Стоп-лосс без убытка )externint Start_Profit = 50 ; // Start Trailing Stop ( Старт трейлинг стоп )externstring a_t = "" ; // + //--------------------------------------------------------------------------------------------------------externstring A_T = "Параметры" ; // ================ Автоматическая торговля =================externint Take_Profit_A = 2500 ; // Take Profit externint Stop_Loss_A = 1200 ; // Stop Loss externint Stop_Loss_Profit_A = 15 ; // Stop loss without loss ( Стоп-лосс без убытка )externint Start_Profit_A = 50 ; // Start Trailing Stop ( Старт трейлинг стоп ) //------------------------------------------------------------------+//--------------------------------------------------------------------------------------------------------externstring A_S = "Параметры" ; // ======================= Scalping =========================externint Take_Profit_S = 10000 ; // Take Profit externint Stop_Loss_S = 1500 ; // Stop Loss externint Stop_Loss_Profit_S = 15 ; // Stop loss without loss ( Стоп-лосс без убытка )externint Start_Profit_S = 30 ; // Start Trailing Stop ( Старт трейлинг стоп ) //------------------------------------------------------------------+string symbol_EURUSD = "EURUSD" ;
string symbol_GBPUSD = "GBPUSD" ;
string symbol_AUDUSD = "AUDUSD" ;
string symbol_NZDUSD = "NZDUSD" ;
string symbol_USDCHF = "USDCHF" ;
string symbol_USDJPY = "USDJPY" ;
string symbol_USDCAD = "USDCAD" ;
string symbol_USDCNH = "USDCNH" ;
string symbol_SPX500 = "SPX500" ;
//-------------------------------------------------------------------+double Rvi_Blue_H1;
double Rvi_Red_H1;
double Rvi_Blue_H4;
double Rvi_Red_H4;
double Rvi_Blue_D1;
double Rvi_Red_D1;
double Rvi_Blue_W1;
double Rvi_Red_W1;
//-------------------------------------------------------------------+double TakeProfit = NormalizeDouble (Take_Profit* _Point , _Digits ); // Тейк-профит ручная торговляdouble StopLoss = NormalizeDouble (Stop_Loss* _Point , _Digits ); // Стоп-лосс ручная торговляdouble StopLossProfit = NormalizeDouble (Stop_Loss_Profit* _Point , _Digits ); // Стоп-лосс безубытка ручная торговляdouble StartProfit = NormalizeDouble (Start_Profit* _Point , _Digits ); // Стрт-профит ручная торговля//-------------------------------------------------------------------+double TakeProfit_S = NormalizeDouble (Take_Profit_S* _Point , _Digits ); // Тейк-профит Scalping double StopLoss_S = NormalizeDouble (Stop_Loss_S* _Point , _Digits ); // Стоп-лосс Scalping double StopLossProfit_S = NormalizeDouble (Stop_Loss_Profit_S* _Point , _Digits ); // Стоп-лосс безубытка Scalping double StartProfit_S = NormalizeDouble (Start_Profit_S* _Point , _Digits ); // Стрт-профит Scalping //-------------------------------------------------------------------+ double TakeProfit_B = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит Breakdown автоматической торговли double TakeProfit_C = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит Center автоматической торговли double TakeProfit_ATR = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит ATR автоматической торговлиdouble TakeProfit_H1 = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит H1 автоматической торговлиdouble TakeProfit_H4 = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит H4 автоматической торговлиdouble TakeProfit_D1 = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит D1 автоматической торговлиdouble TakeProfit_W1 = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит W1 автоматической торговлиdouble TakeProfit_TB = NormalizeDouble (Take_Profit_A* _Point , _Digits ); // Тейк-профит Trend_Bar автоматической торговлиdouble StopLoss_B = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс Breakdown автоматической торговлиdouble StopLoss_C = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс Cente автоматической торговлиdouble StopLoss_ATR = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс ATR автоматической торговлиdouble StopLoss_H1 = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс H1 автоматической торговлиdouble StopLoss_H4 = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс H4 автоматической торговлиdouble StopLoss_D1 = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс D1 автоматической торговлиdouble StopLoss_W1 = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс W1 автоматической торговлиdouble StopLoss_TB = NormalizeDouble (Stop_Loss_A* _Point , _Digits ); // Стоп-лосс Trend_Bar автоматической торговлиdouble StopLossProfit_B = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка Breakdown автоматической торговлиdouble StopLossProfit_C = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка Center автоматической торговлиdouble StopLossProfit_ATR = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка ATR автоматической торговлиdouble StopLossProfit_H1 = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка H1 автоматической торговлиdouble StopLossProfit_H4 = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка H4 автоматической торговлиdouble StopLossProfit_D1 = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка D1 автоматической торговлиdouble StopLossProfit_W1 = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка W1 автоматической торговлиdouble StopLossProfit_TB = NormalizeDouble (Stop_Loss_Profit_A* _Point , _Digits ); // Стоп-лосс безубытка Trend_Bar автоматической торговлиdouble StartProfit_B = NormalizeDouble (Start_Profit_A* _Point , _Digits ); // Стрт-профит Breakdown автоматической торговлиdouble StartProfit_C = NormalizeDouble (Start_Profit_A* _Point , _Digits ); // Стрт-профит Center автоматической торговлиdouble StartProfit_ATR = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит ATR автоматической торговлиdouble StartProfit_H1 = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит H1 автоматической торговлиdouble StartProfit_H4 = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит H4 автоматической торговлиdouble StartProfit_D1 = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит D1 автоматической торговлиdouble StartProfit_W1 = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит W1 автоматической торговлиdouble StartProfit_TB = NormalizeDouble ((Start_Profit_A* 2 )* _Point , _Digits ); // Стрт-профит Trend_Bar автоматической торговлиdouble step = NormalizeDouble (Step* _Point , _Digits ); // Шаг трал стопа ручная торговля//-------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Функция Level
//+------------------------------------------------------------------+
double Bar_data_D1 [][6]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров D1
int ACR_D1; // Возвращает количество скопированных баров D1
double Bar_data_W1 [][6]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров W1
int ACR_W1; // Возвращает количество скопированных баров W1
double Bar_data_MN1 [][6]; // Копирует в массив данные баров указанного графика и возвращает количество скопированных баров MN1
int ACR_MN1; // Возвращает количество скопированных баров MN1
double High_D1_Level; // Возвращает значение максимальной цены бара D1
double Low_D1_Level; // Возвращает значение минимальной цены бара D1
double High_W1_Level; // Возвращает значение максимальной цены бара W1
double Low_W1_Level ; // Возвращает значение минимальной цены бара W1
double High_MN1_Level; // Возвращает значение максимальной цены бара MN1
double Low_MN1_Level; // Возвращает значение минимальной цены бара MN1
double Max_D_Level; // ближайшей максимальный D уровень
double Min_D_Level ; // ближайшей минимальный D уровень
double Max_W_Level ; // ближайшей максимальный W уровень
double Min_W_Level ; // ближайшей минимальный W уровень
double Max_MN_Level ; // ближайшей максимальный MN уровень
double Min_MN_Level ; // ближайшей минимальный MN уровень
//+------------------------------------------------------------------+
double Lots; // переменная для расчёта лота и вывода в кнопке
string lots; // переменная для отоброжения имя кнопки Lots
string sell; // переменная для отоброжения имя кнопки Sell
string bay; // переменная для отоброжения имя кнопки Bay
string balance; // переменная для отоброжения имя кнопки balance
int avto_torgovlya; // объекта «Кнопка» Авто_торговля
int avto_tral_stop; // объекта «Кнопка» Авто_трал_стоп
int break_even; // объекта «Кнопка» Безубыток
int scalper; // объекта «Кнопка» scalper
//-------------------------------------------------------------------+
int Time_Seconds; // сохроняем секунду
int Time_Minute; // сохроняем минуту
int Time_Hour; // сохроняем час
int ticks_to_close = 10; // количество тиков до снятия эксперта с терменала
int ExtRVIPeriod = 10;
datetime Order_datetime_S;
datetime Time_Day;
//-------------------------------------------------------------------+
string String_Order; // описание сигнала Bay или Sell
int Signal_Order_1; // если 1 то Bay - если -1 то сел (обнуляем 1 раз в день)
double BuyTralStop_S, SellTralStop_S;
int N1_Order_Bay_Time; // записываем время последней сделки (обнуляем 1 раз в день)
int N1_Order_Sell_Time; // записываем время последней сделки (обнуляем 1 раз в день)
int tframe[] = { 1 , 5 , 15 , 30 , 60 , 240 , 1440 , 10080 , 43200 };
string tf[] = { "M1" , "M5" , "M15" , "M30" , " H1" , " H4" , "D1" , "W1" , "MN1" };
int tfnumber = 9 ;
int ADX_Period = 14 ;
int ADX_Price = PRICE_CLOSE ;
double Step_Psar = 0.02 ;
double Max_Psar = 0.2 ;
color UpColor = clrBlue ;
color DownColor = clrRed ; // Trend_Barcolor FlatColor = clrLime ;
color TextColor = clrGreen ;
int Corner = 0 ;
double Psar;
double PADX,NADX;
string TimeFrameStr;
double IndVal[ 9 ];
//-------------------------------------------------------------------+string lots; // переменная для отображения имя кнопки Lotsstring sell; // переменная для отображения имя кнопки Sellstring bay; // переменная для отображения имя кнопки Baystring balance; // переменная для отображения имя кнопки balanceint avto_torgovlya; // объекта «Кнопка» Авто_торговляint avto_tral_stop; // объекта «Кнопка» Авто_трал_стопint break_even; // объекта «Кнопка» Без убытокint scalper; // объекта «Кнопка» scalper //-------------------------------------------------------------------+double Lots; // переменная для расчёта лотаint Time_Seconds; // сохраняем секунду int Time_Minute; // сохраняем минуту int Time_Hour; // сохраняем часint Friday; //переменная для торговли в пятницу если равно 0 торговля разрешена 1 торговля запрещена int ticks_to_close = 10 ; // количество тиков до снятия эксперта с терминалаint ExtRVIPeriod = 10 ;
datetime Order_datetime_S;
//-------------------------------------------------------------------+string File_Name;
int file_handle;
int Signal[ 100 ]; // Signal [0] текущий день Signal [10] Shaping_Signal Bay // Signal [1] H1 Signal [11] Shaping_Signal Sell// Signal [2] H4 Signal [12] // Signal [3] D1 Signal [13]// Signal [4] W1 Signal [14]// Signal [5] Scalper Signal [15]// Signal [6] Breakdown Signal [16]// Signal [7] Center Signal [17]// Signal [8] ATR Signal [18]// Signal [9] Trend_Bar Signal [19]//-------------------------------------------------------------------+int ATR_Period = 5 ;
double beginner = 0 ;
int timeshift = 0 , timeshifts = 0 ;
double H4, L4, H4t, L4t;
double fullatr;
double ATR_Level_5, ATR_Level_6;
double rates_d1 [][ 6 ];
double ATR_Level [ 10 ]; //Сохраняем в массиве Signal[100] значение линий //ATR_Level[0] line BAY//ATR_Level[1] line SELL //ATR_Level[2] line Center//ATR_Level[3] line High_d1 Предыдущий день//ATR_Level[4] line Low_d1 Предыдущий день //ATR_Level[5] line D_max от line SELL//ATR_Level[6] line D_min от line BAY //-------------------------------------------------------------------+double BuyTralStop, SellTralStop;
double BuyTralStopS, SellTralStopS;
double BuyTralStopH1, SellTralStopH1;
double BuyTralStopH4, SellTralStopH4;
double BuyTralStopD1, SellTralStopD1;
double BuyTralStopW1, SellTralStopW1;
double BuyTralStop_C, SellTralStop_C;
double BuyTralStop_B, SellTralStop_B;
double BuyTralStop_ATR, SellTralStop_ATR;
double BuyTralStop_TB, SellTralStop_TB;
//-------------------------------------------------------------------+int S_Order_Time[ 2 ]; // [0] Bay// [1] Sellstring S_Order; // описание сигнала
Глобальные переменные создаются путем размещения их объявлений вне описания какой-либо функции. Глобальные переменные определяются на том же уровне, что и функции, т. е. не локальны ни в каком блоке. Область видимости глобальных переменных - вся программа, глобальные переменные доступны из всех функций, определенных в программе...
But personally, I write everything simply and clearly for myself in this style , and I don't get random values.
But it's clear where the legs are growing from. And if out of range is true, it's not flying by with a whistle further.
I don't think so, but it's clear where the legs come from. if out of range is like that, then it's not going to fly further.(The algorithm does what it says, not what you think.) The algorithm should do what you think, not what it wants. otherwise it will wipe out the deposit. I personally do not like this option.
There is no logic. You don't have random values, but there is an outlier in the array.
And the main contradiction is that the algorithm does not do as it wants, but as it is written. Without any correlation with the wants.
One Click Close The script allows users to easily close positions if their profit/loss reaches or exceeds a value specified in pips. Please set slippage value first. Sometimes some positions do not close due to high volatility of the market. Please set larger slippage or restart the script. The free demo version is: ...
Fourth day... all of progressive humanity...
And he's out of range.
We're waiting for you!
I don't quite understand .
First we remember the size of the array, then we pre-check the index for no more than the size of the array.
When looking for extrema, I don't know how many there will be either. I store how many I found in the variable. After that, I check if the number of extrema found is not coming out. I am working with static arrays where an overstepping is fraught with null or random values.
I do not like dynamic arrays, but your case is quite large.
I understood your task as looking for the same daily minima.
I would solve it this way. First, I would memorize the minimum extrema into the array (in the picture you have it exactly like that, and in the condition you are comparing all the daily Low prices). And then I would look for the same ones with some accuracy.
We invite our experts:
1) Vitaly Muzichenko is the most important expert of our post (Guru) judging by the products written by him.
2)Valeriy Yastremskiy
3)Alexey Tarabanov
4)Aleksey Stepanenko- A man who is not just talking but has written a code from scratch, but the problem remains.
5) And all the rest.
Here we go: I have tested the code writtenby Aleksei Stepanenko#property version "2.00".
See screenshot 1
What we see is that Day1 and DayMin are at one parallel 0.67366 ,
further: if there was no history for this tool it would be normal.
We open the tool, draw lines; it does not roll back in the tester.
and go by the history manually.
In the history of 2019.10.16 at 15.00 we find the daily low
we cast a line and go backwards.
And then we realize something is wrong here and the level (value) of DayMin on screen 1 should be = 67233
I'm just starting to study MQL4 it's hard for me to understand codeby Aleksei Stepanenko(class in class, arrays overwrite arrays, etc.).
I have a question for experts on how your indicators and all your products work (I'd be ashamed of it)
On page 9 of the post the reason for the address in expanded form#88 https://www.mql5.com/ru/forum/357558/page9#comment_19689951
We invite our experts:
1) Vitaly Muzichenko is the most important expert of our post (Guru) judging by the products written by him.
2)Valeriy Yastremskiy
3)Alexey Tarabanov
4)Aleksey Stepanenko- A man who is not just talking but has written a code from scratch, but the problem remains.
5) And all the rest.
Here we go: I have tested the code writtenby Aleksei Stepanenko#property version "2.00".
See screenshot 1
What we see is that Day1 and DayMin are at one parallel 0.67366 ,
Further: if there would be no history for this instrument, it would be normal.
We look at screenshot 2
We open the tool, cast the lines; it does not wobble in the tester
and go by the history manually.
We look atthe screenshot 3
In the history of 2019.10.16 at 15.00 we find the daily low
Let's cast the line and go backward
We look atscreenshot 4
And then we understand that something is wrong here and the level (value) of DayMin on the screenshot 1 should be = 67233
I'm just starting to learn MQL4 it's hard for me to understand codeby Aleksei Stepanenko(there's a class in the class, arrays are rewriting things, etc.).
I have a question for experts on how your indicators and all your products work (I'd be ashamed of it)
On page 9 of the post the reason for the appeal in expanded form#88 https://www.mql5.com/ru/forum/357558/page9#comment_19689951
The algorithm does what it says, not what you think it does. I also print to a file and see what's counted, and often it's not what I think it is, but what I've written.
The algorithm does what it says, not what you think. I also print to a file and see what is calculated there, and often, not at all what I planned, but what I wrote.
I don't know how anyone writes code.
But personally, I write everything simply and clearly for myself in the current styles and I can’t get random values.
but it is clear from where the legs grow. and if out of range it is so, and not whistled further.
(the algorithm does what is written, and not as you think ) the algorithm should do as you think and not as it wants. otherwise it is a drain of the deposit. And personally, this option does not suit me.
example global variables (Although this may seem like an antediluvian to some)
Fourth day... all of progressive humanity...
And he's out of range.
We're waiting for you!
As I see it.
Looking forward to seeing you !
Look it up, isn't it?
But personally, I write everything simply and clearly for myself in this style , and I don't get random values.
But it's clear where the legs are growing from. And if out of range is true, it's not flying by with a whistle further.
I don't think so, but it's clear where the legs come from. if out of range is like that, then it's not going to fly further.(The algorithm does what it says, not what you think.) The algorithm should do what you think, not what it wants. otherwise it will wipe out the deposit. I personally do not like this option.
There is no logic. You don't have random values, but there is an outlier in the array.
And the main contradiction is that the algorithm does not do as it wants, but as it is written. Without any correlation with the wants.
Why don't you ask the authors?
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link "https://www.mql5.com"