Object Create_Rectangle......Please help me

To add comments, please log in or register
Mahen Srv
31
Mahen Srv  

I want to add rectangle between particulate two HLINE like R1-R2 and s1-S2. and my HLines are coming on full of chart i need it from yesterdays low or high to current candle only. please help me to do this.

#property indicator_chart_window

#property strict

//---- input parameters

extern int GMTshift = 3;

extern double U_D_S = 11000.00;

//+------------------------------------------------------------------+

int start()

  {

 //---------------------------------------------------------------------+    

    int counted_bars = IndicatorCounted();

    double S = 0, R = 0, S1 = 0, R1 = 0, S2 = 0, R2 = 0, S3 = 0, R3 = 0,S4 = 0, R4 = 0,S5 = 0, R5 = 0,

    S6=0,R6=0,S7=0,R7=0,S8=0,R8=0,S9=0,R9=0,S10=0,R10=0,S11=0,R11=0,S12=0,R12=0,

//------ UDS------

    UDS =(U_D_S); //

    R1 = (UDS+40.0);

    R2 = (UDS+60.0);

    R3 = (UDS +90.0);

    R4 = (UDS +110.0);

    R5 = (R4 +30.0);

    R6 = (R4 +50.0);

    R7 = (R4 +80.0);

    R8 = (R4 +100.0);

    R9 = (R8 +30.0);

    R10 = (R8 + 50.0);

    R11 = (R8 + 80.0);

    R12 = (R8 +100.0);

    S1 = (UDS-40);

    S2 = (UDS-60);

    S3 = (UDS-90);

    S4 = (UDS-110);

    S5 = (S4 -30);

    S6 = (S4 -50);

    S7 = (S4 -80);

    S8 = (S4 -100);

    S9 =  (S8 -30);

    S10 = (S8 -50);

    S11 = (S8 -80);

    S12 = (S8 -100);

//----- UDS--------

      if(ObjectFind("UDS line") != 0)

      {

        ObjectCreate("UDS line", OBJ_HLINE, 0, Time[08], UDS);

        ObjectSet("UDS line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UDS line", OBJPROP_COLOR, White);

      }

    else

      {

        ObjectMove("UDS line", 0, Time[40], UDS);

      }

    if(ObjectFind("UR1 line") != 0)

      {

        ObjectCreate("UR1 line", OBJ_HLINE, 0, Time[40], R1);

        ObjectSet("UR1 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR1 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR1 line", 0, Time[40], R1);

      }

//----

    if(ObjectFind("US1 line") != 0)

      {

        ObjectCreate("US1 line", OBJ_HLINE, 0, Time[40], S1);

        ObjectSet("US1 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US1 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US1 line", 0, Time[40], S1);

      }

//----

    if(ObjectFind("UR2 line") != 0)

      {

        ObjectCreate("UR2 line", OBJ_HLINE, 0, Time[40], R2);

        ObjectSet("UR2 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR2 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR2 line", 0, Time[40], R2);

      }

    if(ObjectFind("US2 line") != 0)

      {

        ObjectCreate("US2 line", OBJ_HLINE, 0, Time[40], S2);

        ObjectSet("US2 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US2 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US2 line", 0, Time[40], S2);

      }

//----

    if(ObjectFind("UR3 line") != 0)

      {

        ObjectCreate("UR3 line", OBJ_HLINE, 0, Time[40], R3);

        ObjectSet("UR3 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR3 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR3 line", 0, Time[40], R3);

      }

    if(ObjectFind("US3 line") != 0)

      {

        ObjectCreate("US3 line", OBJ_HLINE, 0, Time[40], S3);

        ObjectSet("US3 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US3 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US3 line", 0, Time[40], S3);

      }

//----

    if(ObjectFind("UR4 line") != 0)

      {

        ObjectCreate("UR4 line", OBJ_HLINE, 0, Time[40], R4);

        ObjectSet("UR4 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR4 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR4 line", 0, Time[40], R4);

      }

    if(ObjectFind("US4 line") != 0)

      {

        ObjectCreate("US4 line", OBJ_HLINE, 0, Time[40], S4);

        ObjectSet("US4 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US4 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US4 line", 0, Time[40], S4);

      }            

//----

    if(ObjectFind("UR5 line") != 0)

      {

        ObjectCreate("UR5 line", OBJ_HLINE, 0, Time[40], R5);

        ObjectSet("UR5 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR5 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR5 line", 0, Time[40], R5);

      }

    if(ObjectFind("US5 line") != 0)

      {

        ObjectCreate("US5 line", OBJ_HLINE, 0, Time[40], S5);

        ObjectSet("US5 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US5 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US5 line", 0, Time[40], S5);

      }

    if(ObjectFind("UR6 line") != 0)

      {

        ObjectCreate("UR6 line", OBJ_HLINE, 0, Time[40], R6);

        ObjectSet("UR6 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR6 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR6 line", 0, Time[40], R6);

      }

    if(ObjectFind("US6 line") != 0)

      {

        ObjectCreate("US6 line", OBJ_HLINE, 0, Time[40], S6);

        ObjectSet("US6 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US6 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US6 line", 0, Time[40], S6);

      }

    if(ObjectFind("UR7 line") != 0)

      {

        ObjectCreate("UR7 line", OBJ_HLINE, 0, Time[40], R7);

        ObjectSet("UR7 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR7 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR7 line", 0, Time[40], R7);

      }

    if(ObjectFind("US7 line") != 0)

      {

        ObjectCreate("US7 line", OBJ_HLINE, 0, Time[40], S7);

        ObjectSet("US7 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US7 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US7 line", 0, Time[40], S7);

      }

     if(ObjectFind("UR8 line") != 0)

      {

        ObjectCreate("UR8 line", OBJ_HLINE, 0, Time[40], R8);

        ObjectSet("UR8 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR8 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR8 line", 0, Time[40], R8);

      }

    if(ObjectFind("US8 line") != 0)

      {

        ObjectCreate("US8 line", OBJ_HLINE, 0, Time[40], S8);

        ObjectSet("US8 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US8 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US8 line", 0, Time[40], S8);

      }           

     if(ObjectFind("UR9 line") != 0)

      {

        ObjectCreate("UR9 line", OBJ_HLINE, 0, Time[40], R9);

        ObjectSet("UR9 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR9 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR9 line", 0, Time[40], R9);

      }

    if(ObjectFind("US9 line") != 0)

      {

        ObjectCreate("US9 line", OBJ_HLINE, 0, Time[40], S9);

        ObjectSet("US9 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US9 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US9 line", 0, Time[40], S9);

      }

     if(ObjectFind("UR10 line") != 0)

      {

        ObjectCreate("UR10 line", OBJ_HLINE, 0, Time[40], R10);

        ObjectSet("UR10 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR10 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR10 line", 0, Time[40], R10);

      }

    if(ObjectFind("US10 line") != 0)

      {

        ObjectCreate("US10 line", OBJ_HLINE, 0, Time[40], S10);

        ObjectSet("US10 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US10 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US10 line", 0, Time[40], S10);

      }

    if(ObjectFind("UR11 line") != 0)

      {

        ObjectCreate("UR11 line", OBJ_HLINE, 0, Time[40], R11);

        ObjectSet("UR11 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR11 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR11 line", 0, Time[40], R11);

      }

    if(ObjectFind("US11 line") != 0)

      {

        ObjectCreate("US11 line", OBJ_HLINE, 0, Time[40], S11);

        ObjectSet("US11 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US11 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US11 line", 0, Time[40], S11);

      }

    if(ObjectFind("UR12 line") != 0)

      {

        ObjectCreate("UR12 line", OBJ_HLINE, 0, Time[40], R12);

        ObjectSet("UR12 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("UR12 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("UR12 line", 0, Time[40], R12);

      }

    if(ObjectFind("US12 line") != 0)

      {

        ObjectCreate("US12 line", OBJ_HLINE, 0, Time[40], S12);

        ObjectSet("US12 line", OBJPROP_STYLE, STYLE_SOLID);

        ObjectSet("US12 line", OBJPROP_COLOR, Lime);

      }

    else

      {

        ObjectMove("US12 line", 0, Time[40], S12);

      }

   

//----

Thanks in advanced , please guide me how to do it.


    return(0);

  }

//+---------

rrocchi
160
rrocchi  
Mahen Srv:

I want to add rectangle 


This function creates a Rectangle on the candle chart, and put it behind the bars.

Modify it for your needs, it is self explanatory:

//+------------------------------------------------------------------+
//| CRIA CAIXA RETANGULAR                                            |
//+------------------------------------------------------------------+
void CreateBox(color Cor = C'128,128,128') {
  
   // ObjectDelete(ChartID(),"obj_fundoInferior"); // This would delete the object, debug only

   int largura_barra_lateral = 200;  // rectangle width in pixels

   string obj_name = "obj_fundoSuperior";   
   
   if (ObjectFind(0,obj_name) == -1) {  
      ObjectCreate(ChartID(),obj_name,OBJ_RECTANGLE_LABEL,0,0,0) ;

      ObjectSetInteger(ChartID(),obj_name,OBJPROP_SELECTABLE,false);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_HIDDEN,true); 
       
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_XDISTANCE,largura_barra_lateral);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_YDISTANCE,0);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_WIDTH,1);  
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_COLOR,Cor);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_XSIZE,largura_barra_lateral);
      ObjectSetInteger(ChartID(),obj_name,OBJPROP_YSIZE,6000);  // rectangle Height in pixels
    }
    
   ObjectSetInteger(ChartID(),obj_name,OBJPROP_BGCOLOR,C'25,40,50');
   ObjectSetInteger(ChartID(),obj_name,OBJPROP_BACK,true);
   
}
To add comments, please log in or register