Calling values of candle next to highest candle using iHighest

 

Hello,


I hope this is not a duplicate topic, and if it is please direct me.


I have been writing a code to identify the highest day of the previous week (easy stuff), and the highest 4HR candle of the highest day of the previous week.  

Not so easy since I have to identify and hold the highest 4HR candle of last week as the new week progresses so it took a few thousand lines of code to accomplish that.

That being said I want to identify if last weeks high was friday, was the highest 4hr candle open broken to the downside by the next candle or candles.

is there a way using the information store in iHighest to call the values of the following candles in the iHighest array?  Or would I have to manually code 4hr by 4hr candles?


I tried using datetime, but since using datetime you need to specify the day or it defaults to the current day I have not found a way to call previous days without using a specific date.

If there is a way to do it using currenttime or datetime or any other method please let me know.  


If I need to attach code please let me know thanks.


Thank you.

 

JamilPotts: Not so easy since I have to identify and hold the highest 4HR candle of last week as the new week progresses so it took a few thousand lines of code to accomplish that.

If there is a way to do it using currenttime or datetime or any other method please let me know.  

Thousands? No! You know when the week starts and when it ends. iBarShift gives you the index range and iHighest tells you which.

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 (2019)

 
William Roeder #:

Thousands? No! You know when the week starts and when it ends. iBarShift gives you the index range and iHighest tells you which.

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 (2019)


I've been coding only a few months and the description for using ibarshift on the mql4 website isn't written in a way that I understand that it can be used in the way you are saying.

To clarify what I wrote thousands of lines of code for is there are 6 4hr candles a day.  if for example the high of last week was wednesday, and the highest 4hr candle was the 08:00 candle, then I would need to reference that candle every day of the new week. On Monday at 00:00 that would be 16 candles back but by Friday 00:00 that would be 40 candles back.  In the way I wrote the code to my understanding of how to use iHighest for example...

int Highest4HR12=0;
if (FHOW && Mon && (iTime(NULL,240,0) == D'00:00:00'))
Highest4HR12 = Htwelve1;
if (FHOW && Mon && (iTime(NULL,240,0) == D'04:00:00'))
Highest4HR12 = Htwelve2;
if (FHOW && Mon && (iTime(NULL,240,0) == D'08:00:00'))
Highest4HR12 = Htwelve3;
if (FHOW && Mon && (iTime(NULL,240,0) == D'12:00:00'))
Highest4HR12 = Htwelve4;
if (FHOW && Mon && (iTime(NULL,240,0) == D'16:00:00'))
Highest4HR12 = Htwelve5;
if (FHOW && Mon && (iTime(NULL,240,0) == D'20:00:00'))
Highest4HR12 = Htwelve6;

something like posted above for every day of the previous week and this week.  In the example FHOW = Friday High Of Week, Mon = Today is Monday, and current time is (candle specified)

//Last Weeks High is Friday
//If Monday
//If Monday 00 and Last Week High is Friday
int Htwenty1  = iHighest(_Symbol,240,MODE_HIGH,6,1) == 1;
int Hsixteen1 = iHighest(_Symbol,240,MODE_HIGH,6,1) == 2;
int Htwelve1  = iHighest(_Symbol,240,MODE_HIGH,6,1) == 3;
int Height1   = iHighest(_Symbol,240,MODE_HIGH,6,1) == 4;
int Hfour1    = iHighest(_Symbol,240,MODE_HIGH,6,1) == 5;
int Hzero1    = iHighest(_Symbol,240,MODE_HIGH,6,1) == 6;

Here are the variables for one day back if Monday, I wrote code for each day back and each day forward as explained above.


Also it would be helpful if you wrote an example, for instance, am I to use ibarshift somehow inside the ihighest parameters?  

int High = ibarshift(parameters)

iHighest(NULL,0,High,0)


Would that be correct?  I will be troubleshooting myself until you reply again.

And while using the code that will consolidate my code into simpler language, I would still need to know how to call forward the values of the highest 4HR candle of the previous week and the candles following it.  Can you break that down for me.

Thank you.

 
William Roeder #:

Thousands? No! You know when the week starts and when it ends. iBarShift gives you the index range and iHighest tells you which.

On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
          Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26.4 (2019)

Also from my current understanding of datetime, using ibarshift I run into the same issue of having to put the specific date of last Monday and last Friday.  Quite possibly a small task to do once a week, however the ultimate goal of coding is that the algorithm can run on it's own without me having to do that.  Is there a way to use datetime where a previous Monday and Friday can be automatically called?
 
JamilPotts #:
Also from my current understanding of datetime, using ibarshift I run into the same issue of having to put the specific date of last Monday and last Friday.  Quite possibly a small task to do once a week, however the ultimate goal of coding is that the algorithm can run on it's own without me having to do that.  Is there a way to use datetime where a previous Monday and Friday can be automatically called?

use DayOfWeek to determine the day

https://docs.mql4.com/dateandtime/dayofweek

DayOfWeek - Date and Time - MQL4 Reference
DayOfWeek - Date and Time - MQL4 Reference
  • docs.mql4.com
DayOfWeek - Date and Time - MQL4 Reference
 
Paul Anscombe #:

use DayOfWeek to determine the day

https://docs.mql4.com/dateandtime/dayofweek

Please explain what you mean in context to what I’m looking for because I already use DayOfWeek to determine current day and the days of the previous week.  My question is how to determine the highest 4hr candle of last week with simpler code as William implied with iHighest and iBarShift, and call the values of the following 4hr candle.  

Thank you. 
 
JamilPotts # My question is how to determine the highest 4hr candle of last week with simpler code as William implied with iHighest and iBarShift, and call the values of the following 4hr candle. 

You need to learn to code.

int iEOW(int iBar){                     // Find the last bar of the week
   int DOW = TimeDayOfWeek( Time[iBar) );
   for(;; ++iBar){
      int pDOW = TimeDayOfWeek( Time[iBar) );
      if(pDOW > DOW) break;             // Curr. was Monday(1) Prev. is Friday(7)
      DOW = pDOW;
   }
   return iBar;
}
//////////////////////////
   int iBeg = iBow(0), iEnd = iBow(iBeg), count = iEnd - iBeg;
   int iHH  = iHighest(NULL,0,MODE_HIGH,count,iBeg);

Was that so hard you couldn't try it?

 
William Roeder #:

You need to learn to code.

Was that so hard you couldn't try it?

I am learning how to code, that’s why I’m here. If the forums are made to ask questions why do you feel the need to be condescending?  Did you have all the answers to your questions in your first 3 months of coding?

& I did try it, all last night.  

You’re not gonna bully me from a computer. Talk to your kids that way.  If you don’t want to help.  Don’t.  Just because you feel like you’re in a position of power cause you know already, doesn’t make me your subordinate.  I spoke politely and gave examples of what I tried.  I only expect the same. 
 
William Roeder #:

You need to learn to code.

Was that so hard you couldn't try it?

Thank you for showing the code though.  
 
JamilPotts #: I am learning how to code, that’s why I’m here. If the forums are made to ask questions why do you feel the need to be condescending? 
Because you are just being lazy. Learn to code. Code your attempt. If you can't get it to work, show your attempt and state your problem. You did nothing.
 
William Roeder #:
Because you are just being lazy. Learn to code. Code your attempt. State the problem. You did nothing.
I literally showed you lines from my code of my attempt.  Did you want me to post all the thousands of lines of code that you said wasn't necessary?  I definitely stated the problem too.  So are you just on autopilot or did you not read my posts?
Reason: