BreakMinMax

To add comments, please log in or register
texcs81
45
texcs81  



void AllertoPerIlRialzo()
{
 ObjectCreate(ChartID(),IntegerToString(Time[0],0,0),OBJ_VLINE,0,Time[0],0);
 ObjectSetInteger(ChartID(),IntegerToString(Time[0],0,0),OBJPROP_COLOR,clrDarkGreen);
// Alert("Teo_CI rialzista su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
}

void AllertoPerIlRibasso()
{
 ObjectCreate(ChartID(),IntegerToString(Time[0],0,0),OBJ_VLINE,0,Time[0],0);
 ObjectSetInteger(ChartID(),IntegerToString(Time[0],0,0),OBJPROP_COLOR,clrDarkRed);
 //Alert("Teo_CI ribassista su "+Symbol()+" a TF "+IntegerToString(Period(),0,0));
 
}

int BreakMinMax()
{
//         Candela Verde            rotto il max buy
   if ((Open[2] > Close [2]) && (Close[1] > Close[2]))
      return +1;
//         Candela Rosso           Rotto il min  sell
   if ((Open[2] < Close [2]) && (Close[1] < Close[2]))
      return - 1;
return 0;
}

static datetime TempoUltimaCandela; 

bool NuovaCandela(){
  datetime TempoCandelaAttuale = Time[0]; 
  if (TempoCandelaAttuale != TempoUltimaCandela){
       TempoUltimaCandela = TempoCandelaAttuale;
       return (true); 
  }else{
       return (false); 
  }
}  
void OnTick()
{
if (NuovaCandela()==true)
  {
   if (BreakMinMax()==1)
       AllertoPerIlRialzo();
   if (BreakMinMax()==-1)
      AllertoPerIlRibasso();
   }
}


Hi guys, this little function should send me a signal (which I will then decide, for now are horizontal lines on the candle) in the following cases:

previous candle "x+1" candle just closed (signal) "x"    

   Trand long: if the candle "x+1" closes at a price > of the just closed candle "x" should "draw" a vertical green line on this last candle  
   Trand short: if the candle "x+1" closes at a price < of the just closed candle "x" should "draw" a vertical red line on this last candle  
   the function sometimes skips "do not draw the lines continuously" can you tell me where the error is? you have ideas
William Roeder
19843
William Roeder  
texcs81:    Trand long: if the candle "x+1" closes at a price > of the just closed candle "x" should "draw"
  1. That isn't what your code tests for, (down candle, followed by a higher close.)

  2. 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.

Keith Watford
Moderator
18436
Keith Watford  
I moved this topic to the MQL4 section and deleted the duplicate topic that the OP posted 
To add comments, please log in or register