Drawing a square or rectangle. Really need help... - page 5

 
Alex_Profit:

I don't know how to do it. Can you give me a hint? The maximum period is a month.

In variablet_Line. we need to insert the value of 1st,2nd,3rd,4th, kv.

I can not understand.

I would appreciate it.

Ohhh, what a program this is... Did you understand what you wrote, or what? Why are there two loops on the same counter? At least manually check the value of variable i at each iteration.

What isbarsToProcess? Where is it declared and what is it equal to? Again, one limit for two loops, it does not lead to anything good; you must beat yourself when you write code like this, so that it won't be done in vain.

And it makes no sense to count bars of the TF, on which the chart is running, to work with the period of MN1.

I do not think it is necessary to write an indicator that draws one line per quarter, while running constantly on the chart, I think for these tasks and script will do, run, markup chart, unload.

 

I did not write it. I found an indicator like this and started to take it apart. I just started it myself, so I'm not very good at it. I've read the user manual but it is not always comprehensible. I am driving with a "creak". It is good that there is a forum where you can ask for advice. It would be nice to talk to someone on the subject of programming.

A special thanks for the critique. However, the question remains unsolved. Thanks anyway for your responsiveness.

 
Alex_Profit:

I did not write it. I found an indicator like this and started to take it apart. I just started it myself, so I'm not very good at it. I've read the user manual but it is not always comprehensible. I am driving with a "creak". It is good that there is a forum where you can ask for advice. It would be nice to talk to someone on the subject of programming.

A special thanks for the critique. However, the question remains unsolved. Thank you for your responsiveness, though.

Well, here's a rough sketch, for example, on my knee just now wrote a quick script:

void OnStart()
{
   int limit=iBars(_Symbol,PERIOD_MN1);
   for(int i=0;i<=limit;i++)
   {
      datetime timemn=iTime(_Symbol,PERIOD_MN1,i);
      int  month=TimeMonth(timemn);
      if(month==1 || month==4 || month==7 || month==10)
      {
         int qt=0;
         switch(month)
         {
            default:break;
            case 1: qt=1;break;
            case 4: qt=2;break;
            case 7: qt=3;break;
            case 10: qt=4;break;
         }
 
         string name=StringConcatenate("Qt"+IntegerToString(qt)+", "+TimeToStr(timemn));
         ObjectCreate (name,OBJ_VLINE,0,timemn,0);         //--- Создаём обьект вертикальную линию
         ObjectSet    (name,OBJPROP_STYLE,2);              //--- Со стилем
         ObjectSet    (name,OBJPROP_COLOR,DimGray);        //--- Со цветом  
         ObjectSet    (name,OBJPROP_WIDTH,0);              //--- С  толщиной
         ObjectSet    (name,OBJPROP_BACK,0);               //--- С типом отображения. Объект на заднем плане
      }
   }   
}

A small drawback - if the quarter starts on weekend, the line is drawn on the last bar on Friday. And the first quarter in the history will also remain without the line, if, for example, the history starts on the 2nd day. This is to specify the number of the month and if it is not the 1st, then the next following one should be taken.

To delete all lines of this script from the chart, you can run this script:

void OnStart()
{
     ObjectsDeleteAll(0,"Qt");
}

You can make a looped script, with checking the existence of a particular line on the desired bar, so that there are no attempts to put a line over an already drawn one and with deletion of the markup on deinitialization of the script.

You can also put line parameters in the settings, and a lot more can be done.

 
evillive:

Here's a rough sketch, for example, I just wrote a quick script on my knee:

It's great. Thank you very much.

I wonder how long it takes to learn these tricks?

 

About as long as it takes to read the language reference and remember what's there and where.

This is assuming that you have programming skills in at least one of the C-like languages. Skills are not just in syntax, you need to understand how the program will "live", what follows what.

If this is not available, but there is a desire to learn, a year should be more than enough.

 
evillive:

If you don't have that, but you want to learn, a year should be more than enough.

I get it.

 

I don't even know how to address it. I need to put the finishing touches on it. I can't figure out how to do it yet either.

The vertical lines are drawn, no problem with that. But how to draw the blue bars on the high bars is still a mystery to me.

The line is from the day. Trying to bind it to the buffer did not work.

I would be extremely grateful for your assistance.

Thank you.

 
Alex_Profit:

I don't even know how to address it. I need to put the finishing touches on it. I can't figure out how to do it yet either.

The vertical lines are drawn, no problem with that. But how to draw the blue bars on the high bars is still a mystery to me.

The line is from the day. Trying to bind it to the buffer did not work.

I would be extremely grateful for your assistance.

Thank you.

Show me the code, we'll fix it together.
 

Don't kick me, the code is "sloppy". I've already understood that. I would like to reach a logical result with examples and mistakes.

The minimum task, it works. And with experience it will become "prettier".

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

#property strict

#property indicator_chart_window

   

    //---  Внешние Глобальные переменные 

extern int     barsToProcess = 5;        //--- Кол-во отображаемых периодов (линий) 


    //---  Глобальные переменные    

string Name_VLine;     //--- Имя Элементов

string Name_CHECK;     //--- Имя Элементов


//MqlDateTime mqlDateTime;

MqlRates    mqlRates[1];


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

int init()

  {  

    return(0);

  }

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

int deinit()

  {

   int i;  

         for (i=0; i<Bars; i++)                              //--- Выбираем все установленные объекты  

           {

              ObjectDelete(Name_VLine + " VLine"  + DoubleToStr(i,0));          //--- Удаляем все объекты

              ObjectDelete(Name_CHECK + "H_CHECK"  + DoubleToStr(i,0));  //--- Удаляем все объекты

              ObjectDelete(Name_CHECK + "L_CHECK"  + DoubleToStr(i,0));  //--- Удаляем все объекты

           }       

   return(0);

  }

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

int start()

{                  

int counted_bars = IndicatorCounted();     //--- перем counted_bars = функц.  Возвращает количество баров

int limit;                                 //--- переменная  старт кол-во баров. Линии рисуем о по всем барам

   

if(counted_bars > 0) counted_bars --;      //--- последний посчитанный бар будет пересчитан 

  //--- основной цикл 

  limit = Bars - counted_bars;         

  for(int i = 0; i < limit; i ++)

      {

      

 //+------------------------ При выборе кол-ва линий отобразим их ко-во------------------------+                 

         if(limit > barsToProcess)                                     //--- Если кол-во линий > Кол-ву отображаемых периодов (линий) 

         {

          limit = barsToProcess;                                      //--- Тогда устанавливаем Кол-во отображаемых периодов (линий)

             while (i<limit)                                           //--- Пока есть линии в окне терминала. Или пока висит индикатор в окне терминала.                        

             {   

               datetime t_Line = iTime(Symbol(),PERIOD_H4,i);         //--- В ПЕРЕМ t_Line Будет Присваиваться значение времени открытия бара

               CopyRates(_Symbol, PERIOD_H4, t_Line, 1, mqlRates);

   {


         //--- кубики по хай (В место галочек нужно подставить кубики)

         ObjectCreate    (0,Name_CHECK + "H_CHECK" + DoubleToStr(i,0), OBJ_ARROW_CHECK, 0, t_Line, mqlRates[0].high, t_Line,mqlRates[0].high);

         ObjectSetInteger(0,Name_CHECK + "H_CHECK" + DoubleToStr(i,0), OBJPROP_COLOR, clrGreen); 

   

         //--- кубики по лоу (В место галочек нужно подставить кубики)

         ObjectCreate    (0,Name_CHECK + "L_CHECK" + DoubleToStr(i,0), OBJ_ARROW_CHECK, 0, t_Line, mqlRates[0].low, t_Line,mqlRates[0].low);

         ObjectSetInteger(0,Name_CHECK + "L_CHECK" + DoubleToStr(i,0), OBJPROP_COLOR, clrGreen); 

        

    //+------------------------ Рисуем вертикальную линии -----------------------------------------------------+                 

    ObjectCreate (Name_VLine + " VLine" + DoubleToStr(i,0),OBJ_VLINE,0,t_Line,0);         //--- Создаём обьект вертикальную линию

    ObjectSet    (Name_VLine + " VLine" + DoubleToStr(i,0),OBJPROP_STYLE,2);              //--- Со стилем

    ObjectSet    (Name_VLine + " VLine" + DoubleToStr(i,0),OBJPROP_COLOR,DimGray);        //--- Со цветом  

    ObjectSet    (Name_VLine + " VLine" + DoubleToStr(i,0),OBJPROP_WIDTH,0);              //--- С  толщиной

    ObjectSet    (Name_VLine + " VLine" + DoubleToStr(i,0),OBJPROP_BACK,0);               //--- С типом отображения. Объект на заднем плане

 }

  i++;

             }

          }

      }

      

   return(0);

}


 
Alex_Profit:

Don't kick me, the code is "sloppy". I've already understood that. I would like to reach a logical result by examples and mistakes.

The minimum task, it works. And with experience it will become "prettier".

Well, where does it work? The lines are drawn on each bar, not on TK. Or in the picture above TF=H1?

Calculate on a piece of paper what limit and i at each iteration of cycles will be equal to.

My example shown above is never accounted for, as I understand it.

The tick arrows can be drawn using indicator buffers, just like the lines connecting candlestick shadows.

Reason: