How can I find out high/low for a specific bar please

 

Hi 

I want to write the following into my indicator but I don't know how, can someone help me please?

On each day, check the 5min bar at 08:05, and draw out the high and low for this 5min bar. (Basically is the high low between 8:00 to 8:05)

Many thanks for helping

 
luckyvictor: can someone help me please?
Help you with what? You haven't stated a problem.

You have only four choices:

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem. No free help
urgent help.

 
whroeder1:
Help you with what? You haven't stated a problem.

You have only four choices:

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using SRC) and the nature of your problem. No free help
urgent help.


I understand your point, so i am having difficulty to locate this bar.

Can I use something like this?

If (Hour() == 8 && Minute() == 5)
    High = iHigh(_symbol, Period_M5,0)

My code here just doesn't work
 
luckyvictor: Can I use something like this?

If (Hour() == 8 && Minute() == 5)
    High = iHigh(_symbol, Period_M5,0)

My code here just doesn't work
  1. What part of "using SRC" was unclear?

  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.

  3. You said you want "the high low between 8:00 to 8:05" when minute is 5, the 8am bar is shift one.

  4. Unless the chart is that specific pair/TF, you must handle 4066/4073 errors. Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

  5. What if there is no tick during that specific minute? There can be minutes between ticks during the Asian session. What if you loose connection during that minute?
    "Free-of-Holes" Charts - MQL4 Articles
    No candle if open = close ? - MQL4 and MetaTrader 4 - MQL4 programming forum

 
luckyvictor:

Hi 

I want to write the following into my indicator but I don't know how, can someone help me please?

On each day, check the 5min bar at 08:05, and draw out the high and low for this 5min bar. (Basically is the high low between 8:00 to 8:05)

Many thanks for helping



Hi,


here I created for you, and you can use it for any time frame, despite you want to check it for period M5

datetime barcheck_at_once;
string look_for_time="08:05";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   barcheck_at_once=iTime(_Symbol,PERIOD_M5,1);
//---
   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[])
  {
//---
   if(barcheck_at_once!=iTime(_Symbol,PERIOD_M5,0)) //--check on each new bar at M5
   {
     //--time at current bar
     Print("Time at current Bar: ",StringSubstr(TimeToString(iTime(_Symbol,PERIOD_M5,0)),11,5));
     //--time at previous bar
     Print("Time at previous Bar: ",StringSubstr(TimeToString(iTime(_Symbol,PERIOD_M5,1)),11,5));
     
     //--check your conditions
     if(StringSubstr(TimeToString(iTime(_Symbol,PERIOD_M5,1)),11,5)==look_for_time)
     {
       //--write your strategy here
       Print("Hey, I am now at ",look_for_time," :)");
     }
     //--
     barcheck_at_once=iTime(_Symbol,PERIOD_M5,0);  //--new initial time at current bar
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

Many ways to do that, but I give you the easiest logic to understand ^_^

Good luck,

Yohana

 

I just try it, look for time: "23:50"

string look_for_time="23:50";


Reason: