Download MetaTrader 5
To add comments, please log in or register
What are the latest MQL5.community news? The Wall section will tell you!
DrTrueman
7
DrTrueman 2016.08.04 05:26 

I am trying to add trendlines to a chart based on OBJ_TREND in the MQL4 documentation example. https://docs.mql4.com/constants/objectconstants/enum_object/obj_trend

Can someone please explain what p1-=1 means in the for loop 

  

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

     {
      //--- use the following value
            if(p1>1)

         p1-=1;
      //--- move the point
      if(!TrendPointChange(0,InpName,0,date[d1],price[p1]))
         return;
      //--- check if the script's operation has been forcefully disabled
      if(IsStopped())
         return;
      //--- redraw the chart
      ChartRedraw();
JC
1395
JC 2016.08.04 06:33  
DrTrueman:

Can someone please explain what p1-=1 means in the for loop  

It's simply a shorter way of writing this:

p1 = p1 - 1

Another, and more usual, way of writing the same thing would be:

p1--

Documentation of this at the following addresses:

https://docs.mql4.com/basis/operations/assign 

https://docs.mql4.com/basis/operations/mathoperation 

DrTrueman
7
DrTrueman 2016.08.04 13:14  
Thank you very much jjc.
/
To add comments, please log in or register