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; }
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
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.