buffer issues :( - page 2

 

mqlearner:

I will do the print statements as soon as the market is open and I can get some movement on the indy to produce results to test.

Wait for the markets to open! No way. You shouldn't waste valuable debugging time just because the market isn't open, and in any case debugging with the strategy tester is faster because you don't have to wait a minute for a one minute candle to expire. Instant EA to show the idea ...

int start(){
   
   string str="";
   if( Close[1] > Open[1] )
      str = str + "Close 1 is greater than open 1\n";
   else
      str = str + "Open 1  is greater than close 1\n";
      
   if( Close[2] > Open[2] )
      str = str + "Close 2 is greater than open 2";
   else
      str = str + "Open 2  is greater than close 2";
      
   Comment(str);

   return(0);
}

Run this in the strategy tester using Visual Mode at speed 28 (drag the visual mode slider bar) on an M1 period and you will be able to see the results live. Obviously you can adapt the idea to the debugging your code. The \n in the strings makes a new line.

 

thank you I appreciate that help...im so frustrated tho...my limited understanding of mql4 is driving me nuts!

I have tried the print statement debuggin and it works perfectly like you suggested (as below) :

if(red15last>blue15last){
    Print("That test worked");
    if(blue5current>red5current){
      AlertOnce("15min RED , 5min BLUE",1);
      return(0);
    }
}


But when I add one more criteria like below, then it stops working

 if(red15last>blue15last){
    Print("That test worked");
    if(blue5last>red5last){
      if(blue5current<red5current){
      AlertOnce("15min RED , 5min BLUE",1);
      return(0);
    }
}
}


all im trying to do here is go from the code you posted earlier that alerts me when the : 15min candle is red and then the 5min candle is blue..

to an alert when the 15min candle is red and the 2nd last 5min candle [2] is blue and the the last 5min candle [1] closed red


its a simple idea to ask the indicator to look for when the 15min is red and the 5min changes from blue to red.

but every time i add the look back to the 2nd last candle [2] on the 5min the indicator goes silent... if I use just the last 5min candle [1] it alerts perfectly.


Im so frustrated, please help me before my head explodes :)

many thanx

 

Maybe blue5current is not less than red5current ? add a print statement before that line and print the values of blue5current & red5current then you will know.

you should sort your braces too { } so you code is clearer.

My personal preference is this . . .

if(red15last>blue15last)
   {
   Print("That test worked");
   if(blue5last>red5last)
      {
      if(blue5current<red5current)
         {
         AlertOnce("15min RED , 5min BLUE",1);
         return(0);
         }
      }
   }
 

thanx Raptor, I am certain it is because the indicator that Im calling to get these values plots a blue or red block depending on if the blue or red buffer is greater...

Im simply trying to get an audible alert after the block has been created on the chart...so if the block has been created as red then I am certain the red buffer is greater than the blue buffer.


I hope that makes sense, if I misunderstood your comment please excuse me and explain as to a newbie :)

thanx


maybe a chart example willmake me more understood, i dont think im explaining myself very well. :(



so as long as the blocks are created the buffers are determined, red>blue or blue>red ... please correct me if im wrong.

 
mqlearner:

thanx Raptor, I am certain it is because the indicator that Im calling to get these values plots a blue or red block depending on if the blue or red buffer is greater...

Add a print statement . . . the you will KNOW for certain . . . maybe you are calling the indicator wrong, maybe there is an error in the Indicator . . . maybe, maybe, maybe . . . . add the Print statement and you will KNOW what the values actually are.

if(red15last>blue15last)
   {
   Print("That test worked");
   if(blue5last>red5last)
      {
      Print("is blue5current ", blue5current, " < red5current ? ", red5current);   // add this . . .  run and check the experts/journal tab
      if(blue5current<red5current)
         {
         AlertOnce("15min RED , 5min BLUE",1);
         return(0);
         }
      }
   }
 

ok thanx will do that now, sorry if I seem difficult...I am just frustrated with myself and the code... wi

I will try anything you guys suggest because I am REALLY wanting to get to grips with all this.

thanx for your answers and suggestions.

 
mqlearner:

I will try anything you guys suggest

Print is your friend . . . learn to use him and he will help you . . .
 

I have tried the code you suggested...it only prints the first criterias print statement like before have a look :


it just wont do anything if I add a second criteria. its weird.

 
mqlearner:

I have tried the code you suggested...it only prints the first criterias print statement like before have a look :


it just wont do anything if I add a second criteria. its weird.


Add another Print statement before if(blue5last>red5last) to see what blue5last & red5last are, I suspect that you will find that blue5last is less than or equal to red5last
 
mqlearner:

Thank you for for continued help...

thank you for your advice and hopefully now that Ive got my head around these Print statements I will be able to debug my code much more efficiently..[ and without bother the pro's on this forum :) ]

Cool, now you you can chase down what is your real issue rather than what you think is your issue :-)
Reason: