Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 977

 

Thank you for your feedback.

1_Yes, I tried to use _iHighest, but it returns the index (bar number) of the highest value found (offset relative to "current bar"). What I mean is, a certain condition is fulfilled at the i-th bar, this bar corresponds to the time, say, 10:00, I need the maximum value from _10:00 to the end of day _00:00. If you can, at least a little scribble, how? How to link iHighest High[] / Low[] you were talking about.

2_iBarShift after all returns the index of the bar where the specified time falls. The index of one bar. I meant you need to calculate how many bars there are in the history (on the chart), with a specific time_12:00_13:00_14:00, etc. iBars is not the same either.

atztek:

See the help for functions, and the forum for examples using them:

1. iHighest/iLowest
- to avoid confusion, these functions return an index corresponding to the maximum/minimum price.
Then you should put their values into High[] / Low[]. You will find a lot of examples on the forum.

2. iBarShift

 
Vadim_2015:

Thank you for your feedback.

1_Yes, I tried to use _iHighest, but it returns the index of the highest value found (offset relative to "current bar"). What I mean is, a certain condition on i-th bar has come true, this bar corresponds to the time, say, 10:00, so I need the maximum from _10:00 to the end of day _00:00. If you can, at least a little scribble, how? How to link iHighest High[] / Low[] you were talking about.

2_ iBarShift after all returns the index of the bar where the specified time falls. The index of one bar. I meant you need to calculate how many bars there are in the history (on the chart), with a specific time_12:00_13:00_14:00, etc. iBars is not the same either.

1. On the segment you are considering, iHighest will return some value which can be stored in a variable, say 'Index_Max'. To get the value you need to perform a simple => High[Index_Max] operation.

2. iBarShift will return the number of bars up to the specified time.

Forget what you have to program for a while, create small examples for each case and use them to show how it works.
 
atztek:
1. In the section you are considering iHighest will return some value which can be stored in a variable, say 'Index_Max'. To get the value you need to perform a simple => High[Index_Max] operation.

2. iBarShift will return the number of bars up to the specified time.

Forget what you have to program for a while, create small examples for each case and use them to show how it works.

Maybe I don't understand something, but I ...MQL4 Handbook/Access to timeseries and indicators/ iBarShift

" iBarShift - Search for the bar by time. The function returns the index of the bar, in which the specified time falls.

The returned value -Index of the bar, the specified time falls into.If there is no bar for the specified time ("hole" in the history), the function returns -1 or the index of the nearest bar." ,

not the number of bars before the specified time.

Yes, I already use the examples, but it's all wrong. I've tried different functions. I will try your version. What should I do when calculating bars-time? How to calculate them?

Thank you!

 
Vadim_2015:


Maybe I don't understand something, but I ...MQL4 Handbook/Access to timeseries and indicators/ iBarShift

" iBarShift - Search for bar by time. The function returns the index of the bar, in which the specified time falls.

The returned value -Index of the bar, the specified time falls into.If there is no bar for the specified time ("hole" in the history), the function returns -1 or the index of the nearest bar." ,

not the number of bars before the specified time.

Yes, I already use the examples, but it's all wrong. I've tried different functions. I will try your version. What should I do when calculating bars-time? How to calculate them?

Thank you!

You're right, but knowing the bar index you can also find out the number of bars in the plot, can't you?
 
Vadim_2015:

2_ not all, pardon my impertinence, there is a function 'iBars'( Returns the number of bars in the history for the corresponding symbol and period). Can you please tell me which combination of functions can calculate not only the number of bars with time, say, '12:00' or say '15:00' in history(PERIOD_H1), but also how many bars with time.

12:00 and / or 15:00 happens only once a day. Accordingly, if we define the number of bars or the number of the last bar of the period PERIOD_D1, it will be the number of bars with the time 12:00, or any other time.

This may not be very clear at first glance, but the algorithm is approximately as follows:

We define the time of the oldest bar of the current period using Bars. datetime time = Time[Bars-1];

Define bar number iBarShift(_Symbol, PERIOD_D1, time, false);

 
How do I identify the current active chart symbol? I.e. the chart which tab/window is active at the moment, and not the one where the indicator/expert is attached. I.e., the Expert Advisor working on some chart knows the symbol of the chart, which has been selected by the user.
 
r772ra:
maybe.
THANK YOU SO MUCH!
 
AlexPORT:
How do I identify the current active chart symbol? I.e. the chart which tab/window is active at the moment, and not the one where the indicator/expert is attached. I.e., the Expert Advisor working on some chart knows the symbol of the chart, which has been selected by the user.
There is no such a thing, that defines the programmatically active chart symbol. You can only define the symbol of the chart, on which the indicator/advisor works _Symbol, Symbol().
 

AlexeyVik:

It may not make sense at first glance, but the algorithm is roughly like this:

Determine the time of the oldest bar of the current period using Bars. datetime time = Time[Bars-1];

Define bar number iBarShift(_Symbol, PERIOD_D1, time, false);

The algorithm is clear, figured it out. I've made an example and it works.

Thank you very much!

And, with the first question (about the maxima), could you explain in more detail how to implement it? If possible, please give me a small algorithm. You are good at it :)

 
Vadim_2015:

The algorithm is clear, figured it out. Did the example, it all works.

Thank you very much!

And, with the first question (about maxima), could you explain in more detail how to implement it? If possible, please give me a small algorithm. You are good at it :)

I'm glad I am understood by someone other than myself.

Vadim_2015:
Hello Dear forum users!

I have started studying the MQL4 language and although I am writing a simple indicator I have faced a problem that I cannot solve. The gist of the problem:

1_How to find the High[i - end of day]. I have a simple cycle Close[i]-Open[i+1], I need to find the High[i - end of day]. For example, from[i],[1],[2] and to the end of the day (PERIOD_H1) . I'm not sure how to do it. There is the 'iHigh' function, but it is not quite the same thing.


This is exactly what we need. High of the current day regardless of how much time remains to the end of the day.

double  iHigh( 
   string           symbol,          // _Symbol
   int              timeframe,       // PERIOD_D1
   int              shift            // 0
   );

If I understand the question correctly.

Reason: