Code of how to obtain the Price and Time of a point?

 
Hello everyone!

                  I am making an indicator to know with a rectangle how far the Sop Loss reaches for my configuration, the problem is that I have already made the indicator at 80% but I cannot find a way to give the second point, the premises that I set is that the starting point must be the current price point on the current candle or "0" candle and the end point 150 candles later, not the "150" candle which is backwards and the price is the Bid + Stop Loss, From these data it is precisely to obtain the value of "candle "150" forward and naturally that it adapts to the current Timeframe.

The code of the current rectangle that I have is this:
ObjectCreate(0, "ZonaSLBuy", OBJ_RECTANGLE, 0, Time[0],  Bid, time2, Ysize);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_COLOR, ClrZonaSLBuy);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_FILL, true);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_SELECTABLE, true);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_SELECTED, true);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_HIDDEN, false);
      ObjectSetInteger(0, "ZonaSLBuy", OBJPROP_BACK, true);
naturally from the Stop Loss BUY.

Could you help me?

Thank you very much.
 
Manuel de los Heros Soler:
Hello everyone!

                  I am making an indicator to know with a rectangle how far the Sop Loss reaches for my configuration, the problem is that I have already made the indicator at 80% but I cannot find a way to give the second point, the premises that I set is that the starting point must be the current price point on the current candle or "0" candle and the end point 150 candles later, not the "150" candle which is backwards and the price is the Bid + Stop Loss, From these data it is precisely to obtain the value of "candle "150" forward and naturally that it adapts to the current Timeframe.

The code of the current rectangle that I have is this: naturally from the Stop Loss BUY.

Could you help me?

Thank you very much.

It's difficult to understand what you're asking, but if you're asking how to draw the rectangle from Time[0] to 150 candles forward:

datetime time2 = Time[0] + (150 * PeriodSeconds());

ObjectCreate(0, "ZonaSLBuy", OBJ_RECTANGLE, 0, Time[0],  Bid, time2, Ysize);

If this is not what you need, can you show a picture of what you want to accomplish?

 
Alexander Martinez #:

It's difficult to understand what you're asking, but if you're asking how to draw the rectangle from Time[0] to 150 candles forward:

If this is not what you need, can you show a picture of what you want to accomplish?

Hello Alexander!

                Won't you speak Spanish? I am going to try your code, for more information my idea is the following:
1º I have these variables in the properties panel:
              1.1 Size of Stop Loss in pips: SL = 20;
              1.2 Length of the rectangle in candles: LongRect = 150;
My intention is that by pressing a button (there are three SL-BUY, SL-SELL and deletion of rectangles) whatever the SL is, I draw from candle "0" and current price a rectangle of length 150 candles and height of the Stop Loss 20 pips, the problem for me is two, the first is that as I give the value of the 150 candles depending on the Timeframe, since in M5 it is 750 minutes, in M1 it is 150 minutes and in H1 it is 150 hours, the height does not varies but the length depends a lot on the Timeframe.

Thank you very much
All the best
 
Hello Alexander!
                  I have tried your code and it is exactly what I needed.
Thanks a lot.
 
Manuel de los Heros Soler #:
Hello Alexander!
                  I have tried your code and it is exactly what I needed.
Thanks a lot.

Glad it helped. Take care, Manuel! 👍

 
Alexander Martinez #:

Me alegro de que haya ayudado. ¡Cuidado, Manolo! 👍

Igualmente.

¡Alejandro!

2 preguntas
1º ¿Hablas español?
2º tengo una duda, se como obtener el precio maximo y precio minimo de la ventana activa, pero en lugar de la ventana necesito que sea de una linea vertical dibujada previamente, sabes que comando o codigo para hacerlo?
Muchas gracias por adelantado.

 
Manuel de los Heros Soler #: Equally. Alexander! 2 questions: 1º Do you speak Spanish? 2º I have a doubt, I know how to obtain the maximum price and minimum price of the active window, but instead of the window I need it to be a previously drawn vertical line, do you know what command or code to do it? Thank you very much in advance.
This is the English forum. Please write in English. If you want to converse in Spanish, then please use the Spanish forum.
 
Alexander Martinez #:

Glad it helped. Take care, Manuel! 👍

Equally.

Alexander!

2 questions
1º Do you speak Spanish?
2º I have a doubt, I know how to obtain the maximum price and minimum price of the active window, but instead of the window I need it to be a previously drawn vertical line, do you know what command or code to do it?
Thank you very much in advance.
 
Fernando Carreiro #:
This is the English forum. Please write in English. If you want to converse in Spanish, then please use the Spanish forum.

Forgiveness. Thank you.

 
Manuel de los Heros Soler #:

Equally.

Alexander!

2 questions
1º Do you speak Spanish?
2º I have a doubt, I know how to obtain the maximum price and minimum price of the active window, but instead of the window I need it to be a previously drawn vertical line, do you know what command or code to do it?
Thank you very much in advance.

I can speak quite a bit of spanish, but writing/reading Spanish is tough for me. No worries, this website can translate between different languages.

To answer your question:

iHighest

int  iHighest(
   string           symbol,          // symbol
   int              timeframe,       // timeframe
   int              type,            // timeseries
   int              count,           // count
   int              start            // start
  );

iLowest

int  iLowest(
   string           symbol,          // symbol
   int              timeframe,       // timeframe
   int              type,            // timeseries id
   int              count,           // count
   int              start            // starting index
  );

One thing to note is that it checks from right to left.

So if start=4 and count=10, it will look from index 4,5,6,7...13.

If I recall correctly, you can set a negative value for count and it will check from left to right.

iHighest - Timeseries and Indicators Access - MQL4 Reference
iHighest - Timeseries and Indicators Access - MQL4 Reference
  • docs.mql4.com
iHighest - Timeseries and Indicators Access - MQL4 Reference
Reason: