High and low of the current candle

 
Good morning,
I would like to know if anyone has already tried to write some MQL5 code to determine the high and low of the current candle.
Thank you.
 

Do or do not, there is no try.

Perhaps you should read the manual. iHigh
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
Marco Tonchella:
Good morning,
I would like to know if anyone has already tried to write some MQL5 code to determine the high and low of the current candle.
Thank you.

A lot successfully did.

Start reading this! You'll find the answers of all your questions.

 
Thank you,
I have read the manual and have already developed several EAs that are based on already closed candle pattern data.
Now I am attempting to write functions that rely on the evaluation of the candle in progress NOT YET CLOSED.
From the manual I found (and already used) some functions like:

To be able to read an array of historical candle data.

I noticed that the MqlTick structure - https://www.mql5.com/en/docs/constants/structures/mqltick
It is used to read the data from the last NOT CLOSED candle.

But in this structure there are no Max and Min.
Now I have built some buffers and an algorithm to be able to identify the MAX and MIN but you will understand that on long TimeFrame candles (for example Daily) in order to work I have to reset the buffers after the candle closes in order to have a new candle NOT CLOSED the right values ​​to calculate the MAX and MIN values ​​in real time.
I was wondering, since in the data window on the chart, however, this information is displayed if someone has already done it without having to use buffers to reset at each candle start.

If anyone has already done this and can show me how to initialize my MAX and MIN buffers on the NON CLOSED candle I would be really grateful.
In the meantime, I read the manual to find new ideas.
 
Marco Tonchella:
Thank you,
I have read the manual and have already developed several EAs that are based on already closed candle pattern data.
Now I am attempting to write functions that rely on the evaluation of the candle in progress NOT YET CLOSED.
From the manual I found (and already used) some functions like:

To be able to read an array of historical candle data.

I noticed that the MqlTick structure - https://www.mql5.com/en/docs/constants/structures/mqltick
It is used to read the data from the last NOT CLOSED candle.

But in this structure there are no Max and Min.
Now I have built some buffers and an algorithm to be able to identify the MAX and MIN but you will understand that on long TimeFrame candles (for example Daily) in order to work I have to reset the buffers after the candle closes in order to have a new candle NOT CLOSED the right values ​​to calculate the MAX and MIN values ​​in real time.
I was wondering, since in the data window on the chart, however, this information is displayed if someone has already done it without having to use buffers to reset at each candle start.

If anyone has already done this and can show me how to initialize my MAX and MIN buffers on the NON CLOSED candle I would be really grateful.
In the meantime, I read the manual to find new ideas.

you are reinventing the wheel

https://www.mql5.com/en/docs/series/ihigh

https://www.mql5.com/en/docs/series/ilow

Documentation on MQL5: Timeseries and Indicators Access / iHigh
Documentation on MQL5: Timeseries and Indicators Access / iHigh
  • www.mql5.com
The High price of the bar (indicated by the 'shift' parameter) on the corresponding chart or 0 in case of an error. For error details, call the GetLastError() function. The function always returns actual data. For this purpose it performs a request to the timeseries for the specified symbol/period during each call. This means that if there is...
 
Ok, I apologize but I didn't know about the existence of the two functions: iHigh, iLow
However I have used them in the following way and it seems to work for what I wanted to do.

void OnTick()
  {
   double TestMax = iHigh(_Symbol, PERIOD_CURRENT, 0);
   double TestMin = iLow(_Symbol, PERIOD_CURRENT, 0);
  }

Thanks.
 
Marco Tonchella: I didn't know about the existence of the two functions: iHigh, iLow

iTime, iOpen, iHigh, iLow, iClose, iVolume, iBars, iBarShift, iLowest, iHighest, iRealVolume, iTickVolume, iSpread were added in
          New MetaTrader 5 Platform build 1860: MQL5 functions for operations with bars and Strategy Tester improvements - MQL5 programming forum 2018.06.14
          MQL5 ReferenceTimeseries and Indicators Access

Perhaps you should read the manual.
   How To Ask Questions The Smart Way. 2004
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 

Good morning everyone I will like to know how to specify next candle index ... I tried the below syntax

   double   open_current  = iOpen(Symbol(),Period(),0); // open price of current candle
   double   close_current = iClose(Symbol(),Period(),0); // close price of current candle

   double   open_next  = iOpen(Symbol(),Period(),-1); // open price of the candle next
   double   close_next = iClose(Symbol(),Period(),-1); // close price of candle next

        

I also want to know if I can set take profit at opening price of the next candle

Thanks in advance

 
Thanks for this. You saved a life.
Reason: