Questions..

 

Hi everyone,

First of all, I'm still learning the MQL4 language(newbie here only at lesson 2), and I'm not really a programmer. I just have several questions:

1.How do you determine the high and low of a candlestick and everything in between? Like, I want to know if a certain value has been included in the candlestick.


2.Is it possible to get the value of an indicator? like alligator, zigzag, etc

Indicator value

3.How do I get value of previous candles, like 1hr or 30min ago?

Thank you everyone!!!

 

https://docs.mql4.com/indicators/icustom

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

 

mode = buffers, shift = bar number beginning with bar zero (0)

on a related note anyone; how do you use the stoch levels???

without indicators using HLCO and what bar like double f = Close[1];
 
cyberhealth:

Hi everyone,

First of all, I'm still learning the MQL4 language(newbie here only at lesson 2), and I'm not really a programmer. I just have several questions:

1.How do you determine the high and low of a candlestick and everything in between? Like, I want to know if a certain value has been included in the candlestick.


2.Is it possible to get the value of an indicator? like alligator, zigzag, etc

3.How do I get value of previous candles, like 1hr or 30min ago?

Thank you everyone!!!


1.  If you want to know if during a tick that made up that candle was bid price at x.x ,  you can't,  MT4 holds the following data for each bar, OHLC datetime and volume (tick count).  If you want to know if a particular bar covers a certain price . . . test if the price in question lower than the Bar's High and higher than the Bar's low

2.  Yes,  use iCustom . . .  use the Search in the top right corner of this page

3.   You can use functions like iHigh(), iLow(), iOpen() & iClose() to get bar values for other timeframes . . . the currently forming bar is bar 0,  one to the left is 1, then 2, etc   is that what you meant ?

 

1.How do you determine the high and low of a candlestick and everything in between?
High[] || iHigh(), Low[] || iLow(), Open[] || iOpen, Close[] || iClose.

Like, I want to know if a certain value has been included in the candlestick.
if( Certain_Value<=iHigh() && Certain_Value>=iLow() ){ bool Included=true; }

2.Is it possible to get the value of an indicator? like alligator, zigzag, etc
Yes, use iCustom() and find_values Example. https://www.mql5.com/en/forum/131897

      while(found<4){
         if(iCustom(Symbol(),period,"ZigZag",12,5,3,0,i)!=0){
            swing.value[found]=iCustom(Symbol(),period,"ZigZag",12,5,3,0,i);
            swing.date[found]=iTime(Symbol(),period,i);
            found++;
         }
         i++;
      }

3.How do I get value of previous candles, like 1hr or 30min ago?
Again: High[] || iHigh(), Low[] || iLow(), Open[] || iOpen, Close[] || iClose.
Examples:
iHigh(Symbol(),Period_H1,1) //<--High of Last H1 Bar.
iLow(Symbol(),Period_M1,29) //<--Low of the 30th Minute Bar.
iLow(Symbol(),Period_M30,1) //<--Low of the Last M30 Bar.

iRSI(Symbol(),Period_H1,14,PRICE_CLOSE,0)
iCustom(Symbol(), Period, "SampleInd",13,1,0);
https://docs.mql4.com/indicators/iCustom

 
Wow, thanks everyone, ubzen, I'll try your examples, I'll update you. Thanks a bunch!!!
 
Everything works great, just one more question though, how do I call the last peak of an indicator, like in zigzag?
 

https://www.mql5.com/en/code/7796.

https://www.mql5.com/en/code/7796.

I'm no expert on this indicator. However, my thinking is that you take the highest value of the last two swing_locations found. Ps- From what I've read on this forum & else-where, be careful with this indicators [ current | last ] swing because it changes it's [ mind | repaints ]. Also, when observing this indicator, the swings you're seeing historically usually isn't what it was in real-time.

 
No worries, I may have a solution for that, but still working on it :)