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

 
AlexeyVik:

I'm glad someone else understands me besides myself.

It's just the right thing to do. High current day no matter how much time is left in the day.

If I understand the question correctly.

It's a little different from what I understood. That's how it is.
bar=iBarShift(NULL,0,t1,false);   //по времени, находим индекс бара
barH=iHighest(NULL,0,MODE_HIGH,bar+1,1);  //находим максимум, в этом промежутке    
 
r772ra:
Slightly different, as I understand it. That's how it is.

Well, that's exactly what I was advised before.
But iHighest(NULL, MODE_HIGH, bar+1, 1) returns bar index High which is higher than all others in this interval, while you asked about current day High.

 
AlexeyVik:

Well, that's exactly what I was advised before.
But iHighest(NULL, MODE_HIGH, bar+1, 1) returns bar index High which is higher than all others in this interval, and you asked about current day High.

I agree,"iHighest(NULL, MODE_HIGH, bar+1, 1) returnsthe index of bar High which is higher than all others in this interval" . And I mean High remaining current day of the day.

I will try to explain more clearly...

#property indicator_separate_window
#property indicator_buffers 1

#property  indicator_label1  "longBars"

#property  indicator_color1 clrBlue

#property  indicator_width1 2

//---углубление в историю на...
extern int barsToProcess = 100;
//---indicators Buffers
double   longBarsBuffer[];        
                

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,longBarsBuffer);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   
   IndicatorDigits(Digits);
  
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   int counted_bars=IndicatorCounted(), 
       limit;

   if (counted_bars<0) return(-1);
   if (counted_bars>0)       
       counted_bars--;       
      
   limit=Bars-counted_bars;
   if(limit>barsToProcess)                                  
      limit=barsToProcess;
  
   double  longValue;
      
                            
   for(int i=0;i<limit;i++)
      {
       longValue = Close[i+1]-Open[i+3];
       
//--- само условие
         
       if(longValue>0) 

//---собственно что необходимо получить: если на i-том баре выполнилось условие(i>0), то находим High от этого бара и 
//---до конца этого дня,я имею ввиду максимум всего этого промежутка. Примерно: Если условие выполнилось 
//---на i=12h,то High от 12 до 00:00,
//--- если i=01:00, то High от 01:00 до 00:00, если i=22:00, то High от 22:00 до 00:00. Как то так.  Возможно ли это реализовать?  
//---Может я не правильно сделал цикл? Как его правильно организовать?
                  
       longBarsBuffer[i]=High[от i - и до конца дня] - то что необходимо получить. 
       else 
          longBarsBuffer[i]=0.0; 
       

If you can not scold me too much :) ...please explain how to do it?

 
Vadim_2015:

I agree, "iHighest(NULL, MODE_HIGH, bar+1, 1) returnsthe index of bar High which is higher than all others in this interval" . And I mean High the remainder of the current of the day.

I'll try to be more specific...

If you can please don't scold me too much :) ...can you please explain how to do it?

At first I thought it was a simple misspelling, but now there is no doubt, do you want to look into the future??? Then only the Doc from Back to the Future can help you.
 
AlexeyVik:
At first I thought it was a simple typo, but now there's no doubt, you want to look into the future??? Then only the Doc from Back to the Future can help you.

I'm afraid Doc can't help me...he's in the wrong business:)

Yeah, that question, "Highthe rest of the current one. of the day." It's a bit confusing. It's just come to me, you'd really think it's an attempt to look into the future on this day. That's a bit off. I wanted to count the _HighThe rest of the current one. of the day from the beginning of the price array to the penultimate day(yesterday), because all the data is there. And the last (today's) day should be recalculated as soon as it has finished. Otherwise it will look like you said - an attemptto look into the future! If I start at the beginning of the price array, and move up to the end (yesterday's day), High will change on each subsequent bar checked. That's why I asked how to subtract High from the rest of the day. I forgot to tell you, the current day is not taken into account, because it is not completed yet. Sorry, I did not understand it at once :) . Can you tell me how to organize such a calculation? Is it even possible?

 
Vadim_2015:

I'm afraid Doc can't help me...he's in the wrong business:)

Yeah, that question, "Highthe rest of the current one. of the day.", it's a bit confusing. It's only just come to me, one would really think it's an attempt to look into the future on this day . It's a bit of a misnomer. I wanted to count the _High♪ the rest of the current one ♪ of the day from the beginning of the price array to the penultimate day(yesterday), because all the data is there. And the last (today's) day should be recalculated as soon as it has finished. Otherwise it will look like you said - an attemptto look into the future! If I start at the beginning of the price array, and move up to the end (yesterday's day), High will change on each subsequent bar checked. That's why I asked how to subtract High from the rest of the day. I forgot to tell you, the current day is not taken into account, because it is not completed yet. Sorry, I didn't get it right away :) . Can you tell me how to organize such a calculation? Is it even possible?

Let me try to understand your question. You need to find High among bars 1) previous day and what you have today, or 2) only what you have today? Maybe iHighest() will help?
 
paladin80:
Let me try to understand your question. Do you need to find High among bars 1) the previous day and today's date, or 2) only the date you have today? Maybe iHighest() will help?

Dear friends, I'll try to explain as best I can what I want to achieve... ..or I'll get it right ...or I'll confuse everybody!

Look, there is an array of prices, let's say from _1.02.2015. to 15.12.2015(today's day), take PERIOD_H1.

1_I take a simple formula _val=Close[i]-Open[i]

2_set a simple condition if (val>0) - check should start from _1.02.2015.

-If the condition is fulfilled, for example, on some bar, then from this bar till the end of this day find _High. For example:Close[4]-Open[4]>0, i.e. suppose bar with index[i=4] belongs to _1.02.2015 10:00, sofrom 10:00 - of this day till 00:00 - the end of this day- we find _High. Correspondingly, if the condition has worked on other day, we act by the same principle. And so it goes through the whole price array. Calculation should start from _1.02.2015 to 14.12.2015 (the penultimate day), why till the penultimate day, - because the last day is not completed yet and the High of the whole day is not known. As soon as the last day is finished, we check it also for the condition. Since the data from _1.02.2015. to 14.12.2015 (the penultimate day) is known, it will not look like -tryingto look into the future :)

- If condition is not fulfilled - nothing is done, empty value is written to the array.

That's actually the whole "idea". How to do it, how to define it through a loop - I can't think!

 
Vadim_2015:

I'm afraid Doc can't help me...he's in the wrong business:)

Yeah, that question, "Highthe rest of the current one. of the day.", it's a bit confusing. It's only just come to me, one would really think it's an attempt to look into the future on this day . It's a little off. I wanted to count the _High♪ the rest of the current one ♪ of the day from the beginning of the price array to the penultimate day(yesterday), because all the data is there. And the last (today's) day should be recalculated as soon as it has finished. Otherwise it will look like you said - an attemptto look into the future! If I start at the beginning of the price array, and move up to the end (yesterday's day), High will change on each subsequent bar checked. That's why I asked how to subtract High from the rest of the day. I forgot to tell you, the current day is not taken into account, because it is not completed yet. Sorry, I didn't get it right away :) . Can you tell me how to organize such a calculation? Is it even possible?

If so, we return to iHighest(), but how many bars to count and from which to start should be calculated using iBarShift()
 
AlexeyVik:
If so, we go back to iHighest(), but how many bars to count and which one to start from must be calculated using iBarShift()

Could you show me how to do this in a loop? I can't figure out how to do it properly.

 
Vadim_2015:

Dear friends, I'll try to explain as best I can what I want to achieve... ..or I'll get it right ..or I'll confuse everyone!

...

Let's continue the conversation... As I understood the task can be reduced to the following. To simplify, we will only investigate yesterday, the H1 period.

First, we look for the earliest candle (looking from the left side of yesterday's chart) with the Close higher than the Open, i.e. we look for the first bullish candle. If this one is found, then starting from it (including it) to the latest candle of the current day, we should find the candle with the highest High. E.g., if the opening time of the first bullish candle is 10:00, then from it till the 23:00 candle we should look for the candle with the highest High. Right?

Reason: