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

 
evillive:

I gave an example of a working script, we need to add arrows and trendlines to it, and re-do it for H4 instead of month. All you need to do is to move away from the indicator concept and look at the problem from a different angle.

This line was taken from the script. The script is very useful. Thank you.

The trend line is plotted for the whole period but in a straight line. I need it to go from high to high. "Fence."

        ObjectCreate    (0,Name_Obj + " V_Line" + DoubleToStr(i,0), OBJ_TREND, 0, t_Line, mqlRates[0].high, t_Line,mqlRates[0].low);
 
AlexeyVik:

Reading the help is what helps you learn the programming language. Then, if you don't understand anything in the help, you can ask questions.

How can you advise a person who has not read the documentation and has no idea where to place SetIndexStyle(0, DRAW_SECTION);; and inserts it into OnCalculate with bewilderment?

No experience, that's why you make silly mistakes.

As Kiyosaki says. First make a mistake, and then analyze it. To understand what was done wrong.

 
Alex_Profit:

This line was taken from the script. The script is very useful. Thank you.

The trend line is drawn for the whole period but in a straight line. I need a high and a high. "Fence" it is.

Think, head, I'll give you a pie ))))

Here's onOBJ_TRENDand need to read the help. What line should be obtained if the time at both points is the same?

And no, this is not my script.

 
evillive:

This is theOBJ_TRENDand the help should be read, how and what is there. Which line should be obtained if the time at both points is the same?

A straight line, respectively.

I do not understand how to find the 2nd anchor point. Where to insert it is also clear.

 

Thank you for that too. You've been a great help. It's just a pity I couldn't get it all figured out, there's not much left to do.

Anyway, thank you for your responsiveness. Have more profits and have a good weekend.

 

Good afternoon everyone. I'm asking for help from the experts. I have this code.

Please advise what should be corrected to ensure that the trend line is drawn on the maximums of the daily TF.

I really need it. Please help.

#property indicator_chart_window
#property strict
extern int   limit = 30;
extern bool  Sho_bars = true;
string txt = "TRADE_";
//+------------------------------------------------------------------+
int init()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   GetDellName (txt);
   Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limits;
   int counted_bars=IndicatorCounted();   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limits = Bars-counted_bars;        
//----
   if(limits>0)                      
   {
    for(int i=limit; i>=0; i--)
    {
     double   _High      = iHigh(Symbol(), 1440,i);   
     double   _Low       = iLow(Symbol(),  1440,i);   
     double   _Open      = iOpen(Symbol(), 1440,i);   
     double   _Close     = iClose(Symbol(),1440,i);                
     datetime _Time_Open = iTime(Symbol(), 1440,i);      // Открытие бара
     //datetime _start_day = 11*60*60;                   // Начало дня  
     datetime _End_Day   = 1440*60;                      // Конец дня 
       
     string   _Time_Open_txt  = TimeToStr(_Time_Open,TIME_DATE ); // Преобразуем время открытия в строку   
     if(Sho_bars)
      {
       // Функция рисующая объекты на графике
       TrendLineGraff(txt + _Time_Open_txt +" start_day",_Time_Open,_High,_Time_Open,_Low);                      // левая граница     
       TrendLineGraff(txt + _Time_Open_txt +" End_Day",_Time_Open + _End_Day,_High,_Time_Open + _End_Day, _Low); // правая граница           
       TrendLineGraff(txt + _Time_Open_txt +" High",_Time_Open,_High,_Time_Open + _End_Day,_High);               // верхняя граница  
       TrendLineGraff(txt + _Time_Open_txt +" Low",_Time_Open,_Low,_Time_Open + _End_Day,_Low);                  // нижняя граница      
       
       TrendLineGraff(txt + _Time_Open_txt + " T_Line", _Time_Open, _Open, _Time_Open + _End_Day, _Close);
      }          
   }
 }  
   return(0);
  }
//+------------------------------------------------------------------+
//| Функция отображения трендовой линии                              |
//+------------------------------------------------------------------+
 void TrendLineGraff(string labebe,datetime time1,double price1,datetime time2,double price2)
  {
   if (ObjectFind(labebe)!=-1) ObjectDelete(labebe);
   ObjectCreate(labebe, OBJ_TREND, 0,time1,price1,time2,price2);
   ObjectSet(labebe, OBJPROP_COLOR,clrDarkOrchid);
   ObjectSet(labebe, OBJPROP_STYLE,0);
   ObjectSet(labebe, OBJPROP_RAY,0);
   ObjectSet(labebe, OBJPROP_BACK, true);
  }
//+------------------------------------------------------------------+
//| Функция удаляет объекты                                          |
//+------------------------------------------------------------------+

 void GetDellName (string name_n = "ytg_")
  {
   string vName;
   for(int i=ObjectsTotal()-1; i>=0;i--)
    {
     vName = ObjectName(i);
     if (StringFind(vName,name_n) !=-1) ObjectDelete(vName);
    }  
  }
//+------------------------------------------------------------------+
 
Alex_Profit:

Good afternoon everyone. I'm asking for help from the experts. I have this code.

Please advise what should be corrected to ensure that the trend line is drawn on the maximums of the daily TF.

I really need it. Please help.

When working with data of another one's TF, the bars should be calculated from that one. But this lesson is no use...

iBars()!!!

And instead of deleting objects, we can give all objects a unique prefix (in this case it is"TRADE_") and delete them all at once in deinit with ObjectsDeleteAll() function.

Here it is: datetime _End_Day = 1440*60;// End of Day -it' s not "End of Day" at all, it is two months later))) The "end of day" value is not needed, because it is the beginning of the next day and the indicator draws the line there anyway.

 
evillive:

When working with data of another TF, the bars should be counted from that TF too. But the lesson is not useful...

iBars()!!!

I'm sorry. But I still do not get it. Can I just fix it in the code?

And as an example too. It's always easier with examples.

I really need it. Thanks, man.

 
Alex_Profit:

I'm sorry about that. But I still don't get it. Can we just fix it in the code?

And as an example, too. It's always easier with examples.

I really need it. Thanks, man.

So what's the result? Did it work?