Alexey Kozitsyn: Well... I don't think we need to dig that deep, but the request in a loop is really the first thing that catches your eye.
What if it needs this data one time, or once an hour? Why make a useless loop?
None of us, except for the questioner himself, know what he wants. So we can only advise what he was advised to do - to go and read in a telepathic club his failings in formulating the question. And do not be offended by those who decided to laugh a little.
#property indicator_chart_windowexternint boom = 1;
//=================================void fishka(int ma,int mi,double map,double mip) // ф-ция
{
ObjectCreate("Макс_Мин",OBJ_TRENDBYANGLE,0, Time[ma], map, Time[mi], mip);// Проводим линиюObjectSet("Макс_Мин",OBJPROP_RAY,false); // Выключить свойство бесконечного луча
}
int deinit()
{
ObjectsDeleteAll();// Удалим все объектыreturn(0);
}
void start()
{
string Символ = "GBPUSD";
datetime Первый, Последний;
int Период=PERIOD_H1;
Последний = iTime(Символ, Период, 0);// Прежде всего узнаем дату и время последнего бараif(boom){
Alert("Последний бар на часовом ",Последний);}
MqlDateTime MqlПервый; // Теперь получить начало суток, обнулив часыTimeToStruct(Последний,MqlПервый); // Для этого преобразуем время последнего бара в структуру
MqlПервый.hour=0;
Первый=StructToTime(MqlПервый); // Терерь надо обратно преобразовать во времяif(boom){
Alert("Первый бар на часовом ",Первый);} // Смотрим начало первого бара сутокint НомерПервого=iBarShift(Символ, PERIOD_H1,Первый);// По времени определим номер первого бара сутокif(boom){
Alert("Первый бар на часовом под номером ",НомерПервого);}
// Можно было просто узнать время начала бара на D1// Теперь у нас есть НомерПервого бара, а номер послелнего = 0// Найдем на этом интервале номера баров, где макс и мин// iHighest и iLowest находят номер бара с макс и мин ценойint БарМакс = iHighest(Символ, // symbol = инструмента
Период, // timeframe = ПериодMODE_HIGH, // Наибольшая цена бара
НомерПервого+1, // Количество баров0); // Начальный барint БарМин = iLowest(Символ,Период,MODE_LOW,НомерПервого+1,0); // Наименьшая цена бараif(boom){
Alert("Максимальный бар = ", БарМакс, " Минимальный бар = ", БарМин);}
double max_price=iHigh(Символ, Период, БарМакс); // iHigh и iLow дают макс и мин цены указанного бараdouble min_price=iLow (Символ, Период, БарМин);
fishka(БарМакс,БарМин,max_price,min_price); // ф-цияif(boom){
Alert("Максимум цены = ", max_price, " Минимум цены = ", min_price);
Alert("Угол = ", ObjectGetDouble(0,"Макс_Мин",OBJPROP_ANGLE));} // Теперь хорошо бы узнать угол
}
how to put it in a loop to display not just one day but the history, all twisted like a snake does not work, the interest is technical, I'm itching))
missha32: Please advise how to get a correct and more accurate price where two machines intersect with each other
The intersection is between the bars, and the calculation is based on the bars. Or do you need to be more precise? You can interpolate, but do you have to? The slow Ma has the same value.
Intersection between bars, and the calculation is done on a bar-by-bar basis. Or do you need to be more precise? You could interpolate, but should you? Slow Ma has the same value.
In this figure, MA1(1)>MA2(1) and MA1(2)<=MA2(2) is the fact of crossing. The bar in brackets shows the bar at which MA1 and MA2 are taken
MA crossing occurs between bars - caught a clear example
The MA on the bars to the left and right of the crossing is different from the price at the crossing point. I understand that the questioner wants the value at the exact crossing point instead of the value on one of the adjacent bars. This exact value can be obtained using linear interpolation - because the MA between bars is constructed as straight line segments. Or take the coordinates of each MA on the adjacent bars. Construct analytically 2 straight lines and calculate their intersection point. It is possible to calculate by considering 2 similar triangles. A counter question arises - why do we need it? Are the costs commensurate with the value of the result? After all, the intersection points will move if the MA parameters are changed minimally. Most likely, it is required by the head of the course project
Well... I don't think we need to dig that deep, but the request in a loop is really the first thing that catches your eye.
What if it needs this data one time, or once an hour? Why make a useless loop?
None of us, except for the questioner himself, know what he wants. So we can only advise what he was advised to do - to go and read in a telepathic club his failings in formulating the question. And do not be offended by those who decided to laugh a little.
Trollers:) A better suggestion would be to get the prices in a loop. Accordingly, store in arrays.
In my opinion, it is simpler like this
Alert outputs immediately to the screen. This is the end of the table
Have you read the question? You seem to have missed it.
You should have just answered that my question was not clear to you. And you "salt, pepper..." Offensive
Read my first reply to you, it was a question to you. If you had answered it clearly, it might have been a different conversation.
What kind of signals were you asking about?
What does this have to do with candle data?
how to put it in a loop to display not just one day but the history, all twisted like a snake does not work, the interest is technical, I'm itching))
Please advise how to get a correct and more accurate price for where the two machines intersect
The intersection is between the bars, and the calculation is based on the bars. Or do you need to be more precise? You can interpolate, but do you have to? The slow Ma has the same value.
Intersection between bars, and the calculation is done on a bar-by-bar basis. Or do you need to be more precise? You could interpolate, but should you? Slow Ma has the same value.
The MA on the bars to the left and right of the crossing is different from the price at the crossing point. I understand that the questioner wants the value at the exact crossing point instead of the value on one of the adjacent bars. This exact value can be obtained using linear interpolation - because the MA between bars is constructed as straight line segments. Or take the coordinates of each MA on the adjacent bars. Construct analytically 2 straight lines and calculate their intersection point. It is possible to calculate by considering 2 similar triangles. A counter question arises - why do we need it? Are the costs commensurate with the value of the result? After all, the intersection points will move if the MA parameters are changed minimally. Most likely, it is required by the head of the course project