I tried to create a trendline in the indicator window and its just only a horizontal line.

 

So I'm trying to make a bullish/bearish divergence here but halfway through, the line on the MACD is just a horizontal. 

Would it be possible to make it the same as the trendline in the chart as in the attached picture?

Files:
picture.png  9 kb
 
Nimoonphob noobiris:

So I'm trying to make a bullish/bearish divergence here but halfway through, the line on the MACD is just a horizontal. 

Would it be possible to make it the same as the trendline in the chart as in the attached picture?

use OBJ_TREND 

https://www.mql5.com/en/docs/constants/objectconstants/enum_object/obj_trend

Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_TREND
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types / OBJ_TREND
  • www.mql5.com
OBJ_TREND - Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Oh I forgot to provide the code, well I actually did use OBJ_TREND tho I'll try to test again..

ObjectCreate(
                  _Symbol,
                  "trendline",
                  OBJ_TREND,
                  ChartWindowFind(0,"MACD(12,26,9)"),
                  PriceInfo[0].time,
                  
                  myMACD(1,0),
                
                  PriceInfo[1].time,
               
                  myMACD(2,1)
               
                  
                  
   );
   
   ObjectSetInteger(0,"trendline",OBJPROP_COLOR,Green);
   ObjectSetInteger(0,"trendline",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,"trendline",OBJPROP_WIDTH,1);
 

What if

 ChartWindowFind(0,"MACD(12,26,9)"),
fails? It would be better set in OnInit() and use shortname, see here: https://www.mql5.com/en/docs/chart_operations/chartwindowfind
Documentation on MQL5: Chart Operations / ChartWindowFind
Documentation on MQL5: Chart Operations / ChartWindowFind
  • www.mql5.com
ChartWindowFind - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
give the buffer value a variable instead of a constant .  
 
Roberto Quan #:
give the buffer value a variable instead of a constant .  

What buffer are you referring to>

Reason: