CODING HELP, trying to call values of first 1hr candle to break 4hr candle

 

Hi, new here but have been studying the forums here for a few years.

I'm trying to update my code with a new idea that I can't quite solve on my own.  I want to be able to call the the first 1hr candle to break higher than the lowest 4hr candle of the week. So that I can use the low of that candle as a sign of a possible change in direction and trade idea.  I created an array for all the 1hr candles that are printed after the lowest 4hr candle is formed, but I can not for the life of me figure out the correct logic to pinpoint the specific candle after new candles have formed.  

I am currently trying a static double, which is what I posted here, but I'm not sure what other parameters I would need to close in on that candle.  I'm also considering a for loop and somehow incorporating a NewBar() function but again running into logic issues (you can see the for loop hashed out in this code as I was trying to figure out the right parameters).

Any help would be appreciated thank you.

int HR4candlesM = Bars(NULL,PERIOD_H4,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_MN1,0)),
    Highest4HRCloseM = iHighest(NULL,PERIOD_H4,MODE_CLOSE,HR4candlesM,0),
    Lowest4HRCloseM = iLowest(NULL,PERIOD_H4,MODE_CLOSE,HR4candlesM,0),
    
    H4HR1hrbrkrArray = Bars(NULL,PERIOD_H1,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_H4,Highest4HRCloseM-1)),
    L4HR1hrbrkrArray = Bars(NULL,PERIOD_H1,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_H4,Lowest4HRCloseM-1));
    
    
    //L4HR1hrbrkr = iHighest(NULL,PERIOD_H1,MODE_CLOSE,0-(iClose(NULL,PERIOD_H1,L4HR1hrbrkrArray) > iClose(NULL,PERIOD_H4,Lowest4HRCloseM)),0);
    
double H4HRclose = iClose(NULL,PERIOD_H4,Highest4HRCloseM),
       H4HRopen = iOpen(NULL,PERIOD_H4,Highest4HRCloseM),
       
       L4HRclose = iClose(NULL,PERIOD_H4,Lowest4HRCloseM),
       L4HRopen = iOpen(NULL,PERIOD_H4,Lowest4HRCloseM);
  
//First 1hr breaker finder
//static double ONEhrbrkr;
//     for(int i=0;i>Bars;i--)
// {
//  if(iHigh(NULL,PERIOD_H1,L4HR1hrbrkrArray) > L4HRopen)
//  }  
       
static double ONEhrBrkr;
//if(iHigh(NULL,PERIOD_H1,L4HR1hrbrkrArray) > iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
//if(iLow(NULL,PERIOD_H1,L4HR1hrbrkrArray) > iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
//ONEhrBrkr = iLowest(NULL,PERIOD_H1,MODE_CLOSE,L4HR1hrbrkrArray,0);
if(iHigh(NULL,PERIOD_H1,L4HR1hrbrkrArray) > iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
if(iLow(NULL,PERIOD_H1,L4HR1hrbrkrArray) < iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
ONEhrBrkr = iHighest(NULL,PERIOD_H1,MODE_CLOSE,L4HR1hrbrkrArray,0); 
Files:
image.png  51 kb
 

To anyone else who might be facing a similar challenge of trying to call values for one specific candle in an array I figured out the for loop necessary to achieve this.  No help from the forums directly this time but I did find a similar code to identify bullish and bearish candles by @Chim Wong & @Keith Watford, from this post, that I used along with another for loop I have to put the pieces together. Still open to suggestions if there is an even simpler way than this. 

int brkr;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {

int HR4candlesM = Bars(NULL,PERIOD_H4,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_MN1,0)),
    Highest4HRCloseM = iHighest(NULL,PERIOD_H4,MODE_CLOSE,HR4candlesM,0),
    Lowest4HRCloseM = iLowest(NULL,PERIOD_H4,MODE_CLOSE,HR4candlesM,0),
    
    H4HR1hrbrkrArray = Bars(NULL,PERIOD_H1,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_H4,Highest4HRCloseM-1)),
    L4HR1hrbrkrArray = Bars(NULL,PERIOD_H1,iTime(NULL,PERIOD_H4,0),iTime(NULL,PERIOD_H4,Lowest4HRCloseM-1)); 
  
brkr=0;
   for(int i=0; i<L4HR1hrbrkrArray;i++)
{
if(iClose(NULL,PERIOD_H1,i)>iOpen(NULL,PERIOD_H1,i))
if(iClose(NULL,PERIOD_H1,i)>iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
if(iLow(NULL,PERIOD_H1,i)<iOpen(NULL,PERIOD_H4,Lowest4HRCloseM))
brkr=i;
}