Download MetaTrader 5

How to get the EA to realise the previous bar has closed above the BB?

To add comments, please log in or register
SAPERE
9
SAPERE  
Hi everyone,

I'm trying to get the EA to record when a bar closes outside the bollingerbands, then initiate a trade if this happened in the previous bar

and the ema's cross or something. My code so far looks like this:

int bar, sll;

if( Close[0] > bollingerband ){

bar = Bars;}

if( bar+1 == Bars){

if(ema1>ema2){

sll = 1}

if ( bar+2 == Bars ){
bar = 0;}

Unfortunately this doesn't seem to work and Ive also tried making it a static as well as a global variable. So I would be most grateful if someone could point me in the right direction
whroeder1
17063
whroeder1  
  1. int bar, sll;
    if( Close[0] > bollingerband ){
      bar = Bars;}
    if( bar+1 == Bars){
    Since bar is not a static or global its value can ONLY be zero or Bars. Therefor bar+1==Bars will NEVER be true.
  2. when a bar closes outside the bollingerbands
    int start(){
       // Wait for the start of a new bar.
       static datetime Time0; if (Time0==Time[0]) return(0); Time0=Time[0];
    
       // Check for close outside BB
       if (Close[1] > bollingerband){ ...


tasaoirse
33
tasaoirse  
its nt working..could u plz code it a right way which works perfectly
whroeder1
17063
whroeder1  
tasaoirse: its nt working..could u plz code it a right way which works perfectly
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. You have only three choices: Search for it, 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.
To add comments, please log in or register