Download MetaTrader 5
To add comments, please log in or register
Do you have Linux? Find out how to install MetaTrader on it!
JPS1
239
JPS1 2014.02.11 06:56 

Simple label create and delete code

CREATE PRICE LABEL

extern color UpperPrice = Blue;

int deinit() {
    return( 0 );
}

int start()
  {

   double CreateLabel = ObjectCreate("UPPER", OBJ_ARROW,0,TimeCurrent(),Bid,0);
                        ObjectSet("UPPER",OBJPROP_ARROWCODE,6); 
                        ObjectSet("UPPER",OBJPROP_COLOR,UpperPrice);
                        ObjectSet("UPPER",OBJPROP_WIDTH,4);
                        WindowRedraw();
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


DELETE PRICE LABEL
int deinit() {
    return( 0 );
}

int start()
  {
       
 ObjectDelete( "UPPER");
 WindowRedraw();
 
//----
   return(0);
  }
//+------------------------------------------------------------------+

1. Drop Create Price Label onto chart ---- good!

2. Drop Delete Price Label onto chart ---- good!

3. Drop Create Price Label onto chart again (before next incoming price tick) ---- Label appears in objects list, but can't be seen on chart because it's given a price value of 0.

However, if one waits for NEW price tick or refreshes chart, it works, but then repeats above cycle again.

JPS1
239
JPS1 2014.02.11 08:20  
Build 604, same thing. New tick needed :(
Wyatt
16
Wyatt 2014.02.11 08:38  

Try OnStart() instead of start()

btw this is a guess, I've been coding for less then a week.

qjol
3243
qjol 2014.02.11 09:03  
JPS:
Build 604, same thing. New tick needed :(

so fake a tick
Slawa
Moderator
6681
Slawa 2014.02.11 09:20  

Thank you. There was a bug.

Fixed

JPS1
239
JPS1 2014.02.11 19:07  
Thank you stringo !!! :)
/
To add comments, please log in or register