Issue on Getting Smaller TF's Shift from Higher TF Bar0

 

Hi Coders, kindly help. My mission is to get H1's Bar Shift Number (Smaller TF) based on Higher TF's Bar0 for D1 and W1.

   int H1D1Sf=iBarShift(sym,60,iTime(sym,1440,0),true);
   if(H1D1Sf==-1) H1D1Sf=iBarShift(sym,60,iTime(sym,1440,0),false)-1;

   int H1W1Sf=iBarShift(sym,60,iTime(sym,10080,0),true);
   if(H1W1Sf==-1) H1W1Sf=iBarShift(sym,60,iTime(sym,10080,0),false)-1;

   Print(sym+" /H1D1Sf "+IntegerToString(H1D1Sf)+" /H1W1Sf "+IntegerToString(H1W1Sf));

Based on the formulas above, the print output (you must really check the H1 shift number from chart and compare the Open prices for H1 and D1/W1) :-

1) Currency symbols - 100% Correct Shift Number

2) Metal symbols - 100% Correct Shift Number

3) Crypto symbols - 100% Wrong Shift Number


Note that the Currency and Metal symbols are trading 24/5 but Crypto symbols are trading 24/7, in my opinion, I guess the issues is due to different trading days. Furthermore, for Crypto symbols, the 1st day of trading is on Sunday but not Monday.


Could you please advise and modify my codes in order to get the correct output for crypto symbols, thanks

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Calculations of technical indicators require price values and/or values of volumes, on which calculations will be performed. There are 7 predefined...