Bruce Smith:
Can someone help me figure out how I can get the latest highs and lows of custom sessions? (mql5)
For example the highest price and lowest price between 12:00pm and 3pm, I want to record each into a variable which should update at 7pm each night for the following day.
Try code below and thread to this discussion https://www.mql5.com/en/forum/470805
//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { datetime tBegin = iTime(_Symbol,PERIOD_D1,0); datetime tEnd = TimeCurrent(); vector high; high.CopyRates(_Symbol,_Period,COPY_RATES_HIGH,tBegin,tEnd); PrintFormat("tBegin[%s] tEnd[%s] Max[%2d][%.2f]",TimeToString(tBegin),TimeToString(tEnd),high.ArgMax(),high.Max()); int iBegin = iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_D1,0))-1; int iMax = iHighest(_Symbol,_Period,MODE_HIGH,(iBegin-0),0); PrintFormat("tBegin[%d][%s] Max[%2d][%.2f]",iBegin,TimeToString(iTime(_Symbol,_Period,iBegin)),iMax,iHigh(_Symbol,_Period,iMax)); /* 2024.08.01 18:33:48.495 ArgMax (XAUUSD,H1) tBegin[2024.08.01 00:00] tEnd[2024.08.01 16:03] Max[ 3][2458.38] 2024.08.01 18:33:48.495 ArgMax (XAUUSD,H1) tBegin[15][2024.08.01 01:00] Max[12][2458.38] */ } //+------------------------------------------------------------------+

ArgMax() returns bar index different than iHighest() | Guide me why?
- 2024.08.01
- Anil Varma
- www.mql5.com
Is there a vector can be set AsSeries? Seems vectors dont follow timeseries settings...
Use MqlDateTime to get the highs and lows related to a specific hour in a day or range of hours
example I made to get the highs and lows of the most recent Monday
U could get highs and lows of a specific time range in hours with this example by putting the chart on the H1 timeframe and you would use dt.hour instead of day_of_week

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can someone help me figure out how I can get the latest highs and lows of custom sessions? (mql5)
For example the highest price and lowest price between 12:00pm and 3pm, I want to record each into a variable which should update at 7pm each night for the following day.