Download MetaTrader 5
To add comments, please log in or register
Publish your articles and improve your rating!
Carl Schreiber
5957
Carl Schreiber 2011.04.23 01:43 

Hi,

I finally managed to run a variation of the support and resistance Indicator, where I place a price-label at the bar with either a high or a low forming a resinstance or a support:

...

      //---- Upper Fractal
      if(High[i]>High[i+1] && High[i]>High[i+2] && High[i]>=High[i-1] && High[i]>=High[i-2]) {
          vUpp = High[i]; 
          aUppsLine[i]  = EMPTY_VALUE; //vUpp;
          plcLeftLabel(Time[i], vUpp, Yellow, 1);
          if (i > maxUpp) maxUpp = i;
      }  else { 
         aUppsLine[i]  = vUpp; 
      }
      if ( aUppsLine[i] != EMPTY_VALUE && High[i] > aUppsLine[i] ) vUpp = EMPTY_VALUE; 
...

void plcLeftLabel(datetime _dt,double _price,color _clr, int _pos){
   string name;
   if (_pos > 0 ) name = GetUniqName("Res ");
   else           name = GetUniqName("Sup ");
   CChartObjectArrowLeftPrice *up_obj=new CChartObjectArrowLeftPrice();
   if(CheckPointer(up_obj)!=POINTER_INVALID)   {
      up_obj.Create( 0, name, 0, _dt, _price );
      up_obj.Color( _clr );
      up_obj.Width( 1 );
      if (_pos > 0)  ResPtrList.Add(up_obj); // Resistance-Pointer-List
      else           SupPtrList.Add(up_obj); // Support-Pointer-List
   }
}

The problem occurs when I change the time frame e.g. from 1M to 5M to 15M t 4H :(

The Label-Objects of the former chart are not destroyed, so everytime I change a hugh amount of labels is add.

To delete or destroy the labels I unsuccsessfully tried what I have found here to destroy - that's what I thought - all Label-Objects at once:

void DeleteGraphObjects()  {
   if(CheckPointer(ResPtrList)==POINTER_DYNAMIC) {
      delete(ResPtrList);
   }
   
   if(CheckPointer(SupPtrList)==POINTER_DYNAMIC) {
      delete(SupPtrList);
   }
}

 I called of this function above in DeInit() - nothing happened. I called it (see below) at the beginning of OnCalculate( .. ):

   if(prev_calculated<7){
      limit=2;
      //--- clean up arrays
      ArrayInitialize(aUppsLine,EMPTY_VALUE);
      ArrayInitialize(aLowsLine,EMPTY_VALUE);
      DeleteGraphObjects();
      getNewList();
   }

Please, how can I get id of all the label at once as soon as I change the time-frame?  Where do I have to put what kind of lines?

Thanks in advance and a wonderfull Eastern to all,

gooly

Carl Schreiber
5957
Carl Schreiber 2011.04.23 12:54  

ha! - found it my self:

ObjectsDeleteAll(0,0,OBJ_ARROW_LEFT_PRICE);
Hve nice days..

Carl Schreiber
5957
Carl Schreiber 2011.04.23 13:18  

sigh - this simple function creats this messages:

2011.04.23 11:13:30     mySnR (EURUSD,M5)       1759664 bytes of leaked memory
2011.04.23 11:13:30     mySnR (EURUSD,M5)       27492 objects of type CChartObjectArrowLeftPrice left
2011.04.23 11:13:30     mySnR (EURUSD,M5)       2 objects of type CList left
2011.04.23 11:13:30     mySnR (EURUSD,M5)       27494 undeleted objects left
2011.04.23 11:13:30     mySnR (EURUSD,M5)       27492 leaked strings left
Is this of no importance or do I have to change s.th. or at least what does this mean?
CU gooly



Rashid Umarov
Admin
6605
Rashid Umarov 2011.04.24 09:03  
gooly:

sigh - this simple function creats this messages:

Is this of no importance or do I have to change s.th. or at least what does this mean?

See article The Order of Object Creation and Destruction in MQL5
/
To add comments, please log in or register