Weekly MAx and Low - Previous and Current

 

Hi, 

I´m trygin to add in  my indicator the information in Text about the status of the week. I mean, current week with minimum, compared with previous week, max or neutral (wihtout max or min) . 

Values of max, min of previous week and current week are ok. I have printed it and confirmed throught the chart.

Problem, there is something else to do with if .. because, it doe show the correct value.  Not sure why it is not working - any help is appreaciated.

maxWAtual = Max value of current week 

maxWAnterior = Max value of Previous week

minWAtual = Min value of current week

minWAnterior = Min value of Previous week.



  // Weekly Max and Min 

  

    if (maxWAtual > maxWAnterior && minWAtual < minWAnterior){

    string Weekmax = " W - Max";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Weekmax); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    }

    

    if (minWAtual > minWAnterior && maxWAtual < maxWAnterior){

    string Weekmin = "W - Min";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Weekmin); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    

    }

    

    if (minWAtual < minWAnterior && maxWAtual < maxWAnterior) {

    string Weekneutral = "W - Neutral";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Weekneutral); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    }

    

    if (minWAtual > minWAnterior && maxWAtual > maxWAnterior){

    string Weekmaxmin = "W - Max,Min";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Weekmaxmin); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    

    }



    Thanks in advance!

 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button

 

Only thing I can see with this code not working the you expect is if you have the names wrong for the types of weeks you are trying to display in text. As it is now the logic is this...

W-Max = Higher High & Lower Low - Engulfing bar
W-Min = HL & LH - Inside bar
W-Neutral = LL & LH - Down
W-Max,Min = HL & HH - Up

I think you need to swap the names around for the Text variable, try this code...


maxWAtual = Max value of current week 

maxWAnterior = Max value of Previous week

minWAtual = Min value of current week

minWAnterior = Min value of Previous week.



  // Weekly Max and Min 

  

    if (maxWAtual > maxWAnterior && minWAtual < minWAnterior){

    string Week = " W - Max,Min";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Week); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    }

    

    if (minWAtual > minWAnterior && maxWAtual < maxWAnterior){

    string Week = "W - Neutral";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Week); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    

    }

    

    if (minWAtual < minWAnterior && maxWAtual < maxWAnterior) {

    string Week = "W - Min";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Week); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    }

    

    if (minWAtual > minWAnterior && maxWAtual > maxWAnterior){

    string Week = "W - Max";

    ObjectCreate (0, textWmax, OBJ_LABEL , 0 , 0 , 0 ); 

    ObjectSetInteger (0, textWmax, OBJPROP_CORNER , CORNER_LEFT_LOWER); 

    ObjectSetInteger (0, textWmax, OBJPROP_ANCHOR , ANCHOR_LEFT_LOWER ); 

    ObjectSetInteger (0, textWmax, OBJPROP_XDISTANCE , 130); 

    ObjectSetInteger (0, textWmax, OBJPROP_YDISTANCE , 03); 

    ObjectSetString (0, textWmax, OBJPROP_TEXT , Week); 

    ObjectSetInteger (0, textWmax, OBJPROP_COLOR , clrRed); 

    ObjectSetString (0, textWmax, OBJPROP_FONT , "Trebuchet MS" ); 

    ObjectSetInteger (0, textWmax, OBJPROP_FONTSIZE , 10); 

    ObjectSetInteger (0, textWmax, OBJPROP_BACK , true ); // object in the backgroun

    

    }
 
Chad Magruder:

Only thing I can see with this code not working the you expect is if you have the names wrong for the types of weeks you are trying to display in text. As it is now the logic is this...

W-Max = Higher High & Lower Low - Engulfing bar
W-Min = HL & LH - Inside bar
W-Neutral = LL & LH - Down
W-Max,Min = HL & HH - Up

I think you need to swap the names around for the Text variable, try this code...


Now, i is working properly . 


Thanks for your help ! really appreacited.

Reason: