Download MetaTrader 5

dymatic trend line by angle dgree is always 90

To add comments, please log in or register
Suibo Wen
3415
Suibo Wen  

Hi,  Below code draw a dymatic trend line by angle,  but mt5 always draw a vertica line as trend line and the angle value return is always 90.  

     When i remove the code with underline below,  mt5 draw trend line correctly.   Is it a mt5 bug(build 842)?     

#property version   "1.00"
#property indicator_chart_window
#property indicator_plots   0


int OnInit()
  {
   return(INIT_SUCCEEDED);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
    ArraySetAsSeries(time,true);
    ArraySetAsSeries(high,true);
    ArraySetAsSeries(low,true);
  
   if(ObjectFind(0,"trendline2")<0)
   { 
      if( ObjectCreate(0,"trendline2",OBJ_TRENDBYANGLE,0,time[1],high[1],time[10],low[10])==true)
        {
           ObjectSetInteger(0,"trendline2",OBJPROP_SELECTABLE,true);    
           //when i remove this line, trendline is correct.       
           double trendline1_angle=ObjectGetDouble(0,"trendline2",OBJPROP_ANGLE,0);  printf("trendline1_angle " + trendline1_angle);
        }
        
    }    

   return(rates_total);
  }
Alain Verleyen
Moderator
29908
Alain Verleyen  
wsuib:

Hi,  Below code draw a dymatic trend line by angle,  but mt5 always draw a vertica line as trend line and the angle value return is always 90.  

     When i remove the code with underline below,  mt5 draw trend line correctly.   Is it a mt5 bug(build 842)?     

This seems effectively a mql5 bug, you have to write to ServiceDesk.
Get in touch with developers using Service Desk!
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Simon Gniadkowski
Moderator
18058
Simon Gniadkowski  
wsuib:

Hi,  Below code draw a dymatic trend line by angle,  but mt5 always draw a vertica line as trend line and the angle value return is always 90.  

     When i remove the code with underline below,  mt5 draw trend line correctly.   Is it a mt5 bug(build 842)?     

You are drawing the Trendline by Angle incorrectly.  For a standard trendline you give 2 price and time coordinates,  for a trendline by angle you give one set of price and time coordinates and one angle.
Alain Verleyen
Moderator
29908
Alain Verleyen  
RaptorUK:
You are drawing the Trendline by Angle incorrectly.  For a standard trendline you give 2 price and time coordinates,  for a trendline by angle you give one set of price and time coordinates and one angle.

Nope. See documentation and example in your link.

Both angle and the second anchor point's coordinates can be used to set the slope of the line.

Simon Gniadkowski
Moderator
18058
Simon Gniadkowski  
angevoyageur:

Nope. See documentation and example in your link.

Ah OK,  I looked at the code and missed this  "Both angle and the second anchor point's coordinates can be used to set the slope of the line."  sorry for my error.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Methods of Object Binding
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Methods of Object Binding
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Methods of Object Binding - Documentation on MQL5
Suibo Wen
3415
Suibo Wen  
Thank you guys,  i submited a request to ServiceDesk.
Luiz Tim
2277
Luiz Tim  
Does anyone found a solution for this ?
Alain Verleyen
Moderator
29908
Alain Verleyen  
Luiz Tim:
Does anyone found a solution for this ?
Still not fixed ?
To add comments, please log in or register