I don't even know what else to add... I've basically given the basic examples. This is the code. That's why you may ask me what's unclear.
Greetings ! Igor a clear example of how to get a value . I have a line Low_D1_Level find the nearest bar in the history which value will be lower than Low_D1_Level
If I work with Structure without array, I get the same result as in the last code.
Write an example , and if you don't mind a description .
//+------------------------------------------------------------------+//| Dark_Level.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.00"#property strict
double Low_D1_Level;
struct BarData
{
datetime time; // время начала периода double open; // цена открытия double high; // наивысшая цена за период double low; // наименьшая цена за период double close; // цена закрытия long tick_volume; // тиковый объем
};
BarData Bar_data_D1[]; // обьявляем массив структуры в памяти //+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
Low_D1_Level = iLow (_Symbol,PERIOD_D1,1); // Возвращает значение минимальной цены бара D1// Bar_data_D1.low [i]; //Минимум свечи// Bar_data_D1.low [i]= iLow (_Symbol,PERIOD_D1,1);
}
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: ...
If Low_D1_Level is the level of the previous day, then Min_D_Level is searched fromLow_D1_Level and it is equal to i=1 , or am I mistaken?
Sorry, I didn't get into the code, I asked to make sure you were doing it consciously.
Can you tell me what you want to get as a result. Any daily levels or what? Looking at the first line, constantly copying an array in ArrayCopyRates and then loops through it is not the most economical option. You could find a more elegant solution.
I apologize, I did not delve into the code, I asked to make sure that you are doing this consciously.
You can say what you want to get in the end. Any daily levels or what? Looking at the first line, constantly copying the array to ArrayCopyRates and then looping through it is not the most economical option. You can find a more elegant solution.
I have been on the stock exchange for more than 5 years, and at the moment I live completely ( you do this consciously ). A year ago, when the understanding of trading on the stock exchange was already more or less strengthened,
It was decided to automate their knowledge in the trade, want to do a good DIY.
This is how MQL4 consciously came to me, at the moment the EA has 6000+ lines.
here is an example code when calculating the lot 1 year ago.
// Примитивно но работало //+-------------------------------------------------------------------------+// Функция расчета лота от прибыли + +//+-------------------------------------------------------------------------+// double Lots; //string lots; double FloatingLots()
{
double Lots1= 1200 ,Lots2= 2200 ,Lots3= 3200 ,Lots4= 4200 ,Lots5= 5200 ,Lots6= 6200 ,Lots7= 7200 ,Lots8= 8200 ,Lots9= 9200 ,Lots10= 10200 ;
if (AccountBalance()<=Lots1){Lots= 0.1 ;}
if (AccountBalance()>=Lots1 && AccountBalance()<=Lots2){Lots= 0.2 ;}
if (AccountBalance()>=Lots2 && AccountBalance()<=Lots3){Lots= 0.3 ;}
if (AccountBalance()>=Lots3 && AccountBalance()<=Lots4){Lots= 0.4 ;}
if (AccountBalance()>=Lots4 && AccountBalance()<=Lots5){Lots= 0.5 ;}
if (AccountBalance()>=Lots5 && AccountBalance()<=Lots6){Lots= 0.6 ;}
if (AccountBalance()>=Lots6 && AccountBalance()<=Lots7){Lots= 0.7 ;}
if (AccountBalance()>=Lots7 && AccountBalance()<=Lots8){Lots= 0.8 ;}
if (AccountBalance()>=Lots8 && AccountBalance()<=Lots9){Lots= 0.9 ;}
if (AccountBalance()>=Lots9){Lots= 1 ;}
return (Lots);
}
And here is the same function after half a year
//+-------------------------------------------------------------------------+// Функция расчета лота от прибыли V 1.1 +//+-------------------------------------------------------------------------+//double Lots; // переменная для расчёта лота и вывода в кнопке double FloatingLots()
{
double S_lots = 0.1 ;
double i;
for ( i = 1000 ; i <= AccountBalance();i+= 1000 )
{
if (i > (AccountBalance())- 1000 )
{
Lots = S_lots; break ;
}
else S_lots+= 0.1 ;
}
return (S_lots);
Here's the reason for creating this thread.
I noticed purely by chance and visually when I started to run the adviser on long periods, if the second condition was removed in the cycle, an error occurred (out of the array) and the second condition simply masked the actual error.
Here is the Function that needs to be debugged, and it's time to study Structures, Classes.
You're asking me why it doesn't work, and I'm trying to get the gist in words, because there might be a better solution to your problem, which is what I'm trying to find out.
You ask me why it doesn't work, and I'm trying to get the gist in words, because there might be a better solution to your problem, which is what I'm trying to find out.
There is a levelLow_D1_Level , then we need to get the value of the next level Min_D_Level, which will be the next lowest in the history and will be lower than Low_D1_Level.
I do not know how to explain further. If you run the code in the tester with the visualization in my opinion everything is visible.
And in general, if you come to the post, please be so kind as to at least read the essence.
That's completely beside the point:
What's the "XY problem"?
It's a mistake that often wastes the time of both the person asking for help and the people trying to answer it. It is also called the "Hammer Problem". In short, people tend to ask about their unsuccessful attempts to solve the problem, rather than about the problem itself. It ends up going something like this:
A person wants to do X.
He doesn't know how to do X, but guesses that doing Y might lead to success.
However, the person also doesn't know how to do Y.
At this point he decides to ask other people for help.
Everyone tries to help the person with problem Y, wondering because it is unclear why anyone would even need such a thing.
After a lot of questioning and a lot of wasted time, it finally becomes clear that the person really wanted to solve X, and that Y can't help him at all.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I don't even know what else to add... I've basically given the basic examples. This is the code. That's why you may ask me what's unclear.
Greetings ! Igor a clear example of how to get a value . I have a line Low_D1_Level find the nearest bar in the history which value will be lower than Low_D1_Level
If I work with Structure without array, I get the same result as in the last code.
Write an example , and if you don't mind a description .
If Low_D1_Level is the level of the previous day, then Min_D_Level is searched fromLow_D1_Level and it is equal to i=1 , or am I mistaken?
Sorry, I didn't get into the code, I asked to make sure you were doing it consciously.
Can you tell me what you want to get as a result. Any daily levels or what? Looking at the first line, constantly copying an array in ArrayCopyRates and then loops through it is not the most economical option. You could find a more elegant solution.
I apologize, I did not delve into the code, I asked to make sure that you are doing this consciously.
You can say what you want to get in the end. Any daily levels or what? Looking at the first line, constantly copying the array to ArrayCopyRates and then looping through it is not the most economical option. You can find a more elegant solution.
I have been on the stock exchange for more than 5 years, and at the moment I live completely ( you do this consciously ). A year ago, when the understanding of trading on the stock exchange was already more or less strengthened,
It was decided to automate their knowledge in the trade, want to do a good DIY.
This is how MQL4 consciously came to me, at the moment the EA has 6000+ lines.
here is an example code when calculating the lot 1 year ago.
And here is the same function after half a year
Here's the reason for creating this thread.
I noticed purely by chance and visually when I started to run the adviser on long periods, if the second condition was removed in the cycle, an error occurred (out of the array) and the second condition simply masked the actual error.
Here is the Function that needs to be debugged, and it's time to study Structures, Classes.
Do not judge strictly for writing code -:)
Here's the function to debug.
OK, and can you tell me what you want to end up with?
Ok, can you tell me what you want to end up with?
Here is the shortened version run on AUDUSD 2020
Why doesn't it go further in the array ?
You're asking me why it doesn't work, and I'm trying to get the gist in words, because there might be a better solution to your problem, which is what I'm trying to find out.
Explain what you are trying to achieve.You ask me why it doesn't work, and I'm trying to get the gist in words, because there might be a better solution to your problem, which is what I'm trying to find out.
Explain what you want to get.So far I see _so_
So far I see _that_.
Yes, that's how human perception works. I, too, when I'm really passionate about an idea, I can barely hear the other person's arguments. Oh, well...
So far I see _ so_.
There is a levelLow_D1_Level , then we need to get the value of the next level Min_D_Level, which will be the next lowest in the history and will be lower than Low_D1_Level.
I do not know how to explain further. If you run the code in the tester with the visualization in my opinion everything is visible.
And in general, if you come to the post, please be so kind as to at least read the essence.
That's completely beside the point:
What's the "XY problem"?
It's a mistake that often wastes the time of both the person asking for help and the people trying to answer it. It is also called the "Hammer Problem". In short, people tend to ask about their unsuccessful attempts to solve the problem, rather than about the problem itself. It ends up going something like this:
So far I see _so_.
So I guess you still haven't found your X and Y !!!