How to get candlestick High, Low, Close everyday at 20:00 (Timeframe H4)

 

Hello, i'm newbie please help. I want to get pivot from candlestick value at 20:00 everyday at Timeframe H4. I already try this code but it seems not worked well.


if(Hour() == 00||Hour() == 01||Hour() == 02||Hour() == 03)
    {
    RefreshRates();
     cHigh = iHigh(NULL, PERIOD_H4, 1);
     cLow = iLow(NULL, PERIOD_H4, 1);
     cClose = iClose(NULL, PERIOD_H4, 1);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
     
     if(Hour() == 04||Hour() == 05||Hour() == 06||Hour() == 07)
    {
    RefreshRates();
     cHigh = iHigh(NULL, PERIOD_H4, 2);
     cLow = iLow(NULL, PERIOD_H4, 2);
     cClose = iClose(NULL, PERIOD_H4, 2);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
     
    if(Hour() == 08||Hour() == 09||Hour() == 10||Hour() == 11)
    {
    RefreshRates();
     cHigh = iHigh(NULL, PERIOD_H4, 3);
     cLow = iLow(NULL, PERIOD_H4, 3);
     cClose = iClose(NULL, PERIOD_H4, 3);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
     
      if(Hour() == 12||Hour() == 13||Hour() == 14||Hour() == 15)
    {
    RefreshRates();
    cHigh = iHigh(NULL, PERIOD_H4, 4);
     cLow = iLow(NULL, PERIOD_H4, 4);
     cClose = iClose(NULL, PERIOD_H4, 4);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
     
      if(Hour() == 16||Hour() == 17||Hour() == 18||Hour() == 19)
    {
    RefreshRates();
     cHigh = iHigh(NULL, PERIOD_H4, 5);
     cLow = iLow(NULL, PERIOD_H4, 5);
     cClose = iClose(NULL, PERIOD_H4, 5);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
     
      if(Hour() == 20||Hour() == 21||Hour() == 22||Hour() == 23)
    {
    RefreshRates();
     cHigh = iHigh(NULL, PERIOD_H4, 6);
     cLow = iLow(NULL, PERIOD_H4, 6);
     cClose = iClose(NULL, PERIOD_H4, 6);
     pivot = cHigh + cLow + cClose;
     pivot = pivot / 3;
     }
 
  1. Don't double post
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. Your code assumes that every H4 bar exists, false over the week end/market holidays. Don't assume, convert the iBarShift to MT5.
              Find bar of the same time one day ago - Simple Trading Strategies - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. On MT5: Unless the chart is that specific pair/TF, you must Synchronize the terminal Data from the Server.
              Timeseries and Indicators Access /  Data Access - Reference on algorithmic/automated trading language for MetaTrader 5