brekin

 
Hello all friends I would like to graphize this situation (in the attached image) and issue an alert when the shadow of the second candle is higher than the shadow of the first candle, I created the following function but I can not understand what is wrong at the theoretical level seems right but when I go to do the test does not work as I want, someone has ideas
 Thank you in advance
double HighPrec= High[1], HighCurr= High[0], LowPrec= Low[1], LowCurr= Low[0];
      
      if(High[1]<High[0])// Sell
       {
        AllertoPerIlRibasso();
        return - 1; 
       }


 
return - 1;

which function do it ?

 
texoro: but I can not understand what is wrong at the theoretical level seems right but when I go to do the test does not work as I want,
  1. We can't know what is wrong either because you haven't stated a problem. "Does not work as I want" requires a mind-reader.

  2. Only MT4 has a predefined array High. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  3. High[1] < High[0] is the test for what your images shows (circled part.) State your problem.

  4. This image also has a higher high. Are you sure you still want to sell? Higher high
 
 int breakIn()
   {
   //double HighPrec= High[1], HighCurr= High[0], LowPrec= Low[1], LowCurr= Low[0];
      
      if(High[1]<High[0])// Sell
       {
        AllertoPerIlRibasso();
        return - 1; 
       }
      else if(Low[1] < Low[0])//buy
       {
        return + 1;
       }
       
       return 0;
   }
   



I'm sorry, I realized I posted half a service, basically:


Sell

when the upper shadow of the candle in formation exceeds the maximum of the previous candle therefore "high[0] > high[1] " must return -1;


Buy 

the opposite situation

 
if(High[1]<High[0])// Sell

do you want to sell when bulls are burgeoning ?

 

I think what the OP is referring to is a retraction from the previous close, indicating a price contraction.

I'd formulate it as this:

if(High[1]<High[0] && Close[1]>Close[0])// Sell
 {
   AllertoPerIlRibasso();
 }

This means, if the current high topped the previous high, but the Bid (which is denoted in Close[0]) fell below the previous close, then sell.

Be aware that such a premise might right away burn your position.

 
Guys then I update the post 
Practically this function must work to tick to not to closed candle, therefore between is in formation the last candle;

Sell
If the upper shadow of the candle in formation exceeds the maximum of the previous candle then "high[0] > high[1] " 
I need to get a -1;

Buy
If the lower shadow of the candle in formation is lower than the minimum of the previous candle then "Low[0]< Low [1] " 
must come back to me +1;


 Attached explanatory image

 
Ragazzi allora ho fatto una modifica al codice visto che deve funzionare a ogni tick e non a chiusura candela, infatti ho modificato usando il valore del prezzo;

però mi succede che richiama le funzioni "AllertoPerIlRibasso() e AllertoPerIlRialzo()(che creano delle linee verticali rosse e verdi"per ogni candela  anziché solo quanto è verificata la condizione

{
    if(Bid>High[1])
      AllertoPerIlRibasso();
    if(Bid<Low[1])
      AllertoPerIlRialzo();
}

Guys then I made a change to the code since it must work at each tick and not at candle closure, in fact I changed using the value of the price;

but it happens to me that it calls the functions "AllertoPerIlRibasso() and AllertoPerIlRialzo() (which create vertical lines red and green "for each candle instead of only when the condition is verified)as a solution?

thanks

Files:
Cattura.JPG  107 kb
 

Did you try this:

if(High[1]<High[0] && Close[1]>Bid)// Sell
 {
   AllertoPerIlRibasso();
 }

It works on every tick not just candle closure, just give it a go.

 
Bare in  mind that the terminal(s) in many cases don't get all the ticks but it could be that the missed extreme prices has come in with the actual or recent 1-Min-bar!
 
Guys, after a little absence here I am after a period of absence, I changed the code but still does not work as it should sometimes from the right signal sometimes not, (I attach image), you have tips how to change,
Ps. I tried to "shift the attention" on the last two candles instead of on the one in formation for a test

thanks in advance


void OnTick()
{
   // 1    candela verde       | ombra  superiore |            
   if ((Close[2] > Open[2]) && (High[2] > Close [2])){
      //    candle rossa             Ombra sup        
      if ((Close[1] < Open[1]) && (High[1] >Open[1]))
         //sell
         if (High[1] > High[2])
            AllertoPerIlRibasso();    
       }
       
           // 1 candela rossa   |Ombra inferiore |      | 2 candle verde |       condizione buy   
   if (((Close[2] < Open[2]) && (Low[2] < Close[2]))&& ((Close[1] > Open[1]) &&((Low[1]<Open[1]) && (Low[1] < Low[2])))) 
       AllertoPerIlRialzo();
       
}
       


Reason: