how to get when was the last time price/bar touched an indicator

 

Hi all,

anybody knows how to get the distance between the last time bar touches an indicator to current indicator ? so lets say i have a simple moving average, and i need to find how many bars have gone since last time the bar touches the simple moving average until current bar.

Thank you in advance

 
the_justin:
anybody knows how to get the distance between the last time bar touches an indicator
for(int iTouched=0; iTouched < Bars; iTouched++){
   double indicator = iCustom(..., iTouched); // Your indicator here
   if (High[iTouched] >= indicator && indicator >= Low[iTouched]) break;
}
if (iTouched == Bars) Print("never in available history");
:
 

Hi WHRoeder,

thank you very very very much for your reply. works like a charm....

 
Justin:

Hi WHRoeder,

thank you very very very much for your reply. works like a charm....

how to get the last close on upper or lowerband???
 
tasaoirse: how to get the last close on upper or lowerband???
  1. learn to code it, or pay (Freelance) someone. We're not going to code it FOR you.
    We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. There is no close on anything. The == operand. - MQL4 forum
  3. There is a close above or below. Perhaps you should read the manual and Close - Predefined Variables - MQL4 Reference