What does p1-=1 mean? (in OBJ_TREND MQL4 documention example)

Back to topics list To post a new topic, please log in or register
avatar
2
DrTrueman 2016.08.04 07: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();
avatar
1316
jjc 2016.08.04 08: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 

avatar
2
DrTrueman 2016.08.04 15:14 #
 
Thank you very much jjc.
Back to topics list  

To add comments, please log in or register