Here's a more complete code as defined in a cllaa (updated to use CopyOpen and CopyTime commands)
#include <Kerching!/libIndicators.mqh> #include <ChartObjects/ChartObjectsLines.mqh> class CPlayable : CCustomIndicator { private: bool _selectable; bool _hidden; color _l1Colour; color _l2Colour; bool _playable; datetime _t[]; double _o[]; CChartObjectTrendByAngle* _L1; CChartObjectTrendByAngle* _L2; double GetMa(int pAppliedPrice, int pShift); void UpdateMa(int pShift); public: void CPlayable(string pSymbol, int pTimeframe, bool pSelectable, bool pHidden, color pL1Colour, color pL2Colour); void ~CPlayable(void); bool Playable(int pShift); int Direction(int pShift); }; void CPlayable::CPlayable(string pSymbol, int pTimeframe, bool pSelectable, bool pHidden, color pL1Colour, color pL2Colour) { Init(pSymbol,pTimeframe); _selectable = pSelectable; _hidden = pHidden; _l1Colour = pL1Colour; _l2Colour = pL2Colour; _playable = false; _L1 = new CChartObjectTrendByAngle(); _L2 = new CChartObjectTrendByAngle(); const int m = 3; ArrayResize(_t,m); ArrayResize(_o,m); } void CPlayable::~CPlayable(void) { delete _L1; delete _L2; } bool CPlayable::Playable(int pShift) { if( _L1 != NULL ) _L1.Delete(); if( _L2 != NULL ) _L2.Delete(); int mt = ArraySize(_t); int mo = ArraySize(_o); CopyOpen(_symbol,_timeFrame,0,mt,_o); CopyTime(_symbol,_timeFrame,0,mo,_t); mt--; mo--; long chartid = ChartID(); _L1.Create(chartid,"L1",0,_t[mt-1],_o[mo-1],_t[mt],_o[mo]); // displays example screenshot // L1.SetDouble(OBJPROP_PRICE2,o0); //works with this line but shouldn't need it _L1.Selectable(_selectable); _L1.Selected(true); _L1.Hidden(_hidden); _L1.Color(_l1Colour); _L1.RayRight(true); _L2.Create(chartid,"L2",0,_t[mt-2],_o[mo-2],_t[mt-1],_o[mo-1]); // L2.SetDouble(OBJPROP_PRICE2,o1); _L2.Selectable(_selectable); _L2.Selected(true); _L2.Hidden(_hidden); _L2.Color(_l2Colour); _L2.RayRight(true); ObjectCreate(chartid,"Test",OBJ_TRENDBYANGLE,0,_t[mt-1],iClose(_symbol,_timeFrame,pShift+1),_t[mt],iClose(_symbol,_timeFrame,pShift)); //works double l1angle = _L1.Angle(); PrintFormat("&& l1angle = %f, l2angle = %f, initalAngle = %i",l1angle,_L2.Angle()); // displaying 0.00 PrintFormat("&& ObjectGetDouble(m_chart_id,m_name,OBJPROP_ANGLE) = %f,",ObjectGetDouble(chartid,"L1",OBJPROP_ANGLE)); // displaying 0.00 PrintFormat("&& ObjectGetDouble(Close) = %f,",ObjectGetDouble(chartid,"Test",OBJPROP_ANGLE)); // displaying 0.00 return _playable; }
And the output
Coordinates should be set after creation.
line1.Create(0,"line1",0,0,0,0,0); line1.Color(clrRed); line1.SetInteger(OBJPROP_TIME1,time[3]); line1.SetDouble(OBJPROP_PRICE1,close[3]); line1.SetInteger(OBJPROP_TIME2,time[50]); line1.SetDouble(OBJPROP_PRICE2,close[50]); printf("line angle: %.1f",line1.GetDouble(OBJPROP_ANGLE));
Thanks I'll give that a go

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
L1.SetDouble(OBJPROP_PRICE2,o0);