Cant see text in separate window

 

Hello community,

want to show text in a separate window of an indicator:

#property indicator_separate_window
int OnInit()
{
    int chart_id=0;
    int sub_window=1;
    string name="my_test";
    if(!ObjectCreate(chart_id,name,OBJ_TEXT,sub_window,0,0.0) ) 
      return(INIT_FAILED);

   ObjectSetInteger(chart_id,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);   
   ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,20);      
   ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,20);     
   ObjectSetInteger(chart_id,name,OBJPROP_FONTSIZE,20);     
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,clrWhite);  
   ObjectSetString(chart_id, name,OBJPROP_FONT,"Calibri");    
   ObjectSetString(chart_id, name,OBJPROP_TEXT,"test text");
   
      
 
      
    return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
  
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
 
{
    
    
    return(rates_total);
}

No compilation error and also not text shown.

Whats wrong?

Thank you

 
chinaski:

Hello community,

want to show text in a separate window of an indicator:

No compilation error and also not text shown.

Whats wrong?

Thank you

Hello .

Use OBJ_LABEL , this is the text for use with screen coordinates while OBJ_TEXT is text for use with time and price coordinates 

Delete objects on DeInit

And add ChartRedraw() if on MT5

#property indicator_separate_window
int OnInit()
{
    int chart_id=0;
    int sub_window=1;
    string name="my_test";
   ObjectCreate(chart_id,name,OBJ_LABEL,sub_window,0,0.0);
   ObjectSetInteger(chart_id,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);   
   ObjectSetInteger(chart_id,name,OBJPROP_XDISTANCE,20);      
   ObjectSetInteger(chart_id,name,OBJPROP_YDISTANCE,20);     
   ObjectSetInteger(chart_id,name,OBJPROP_FONTSIZE,20);     
   ObjectSetInteger(chart_id,name,OBJPROP_COLOR,clrWhite);  
   ObjectSetString(chart_id, name,OBJPROP_FONT,"Calibri");    
   ObjectSetString(chart_id, name,OBJPROP_TEXT,"test text");
   ChartRedraw();
      
 
      
    return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason)
{
ObjectsDeleteAll(ChartID(),"my_test");
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
 
{
    
    
    return(rates_total);
}
 
Lorentzos Roussos #:

Hello .

Use OBJ_LABEL , this is the text for use with screen coordinates while OBJ_TEXT is text for use with time and price coordinates 

Delete objects on DeInit

And add ChartRedraw() if on MT5

Hello Lorentzos,

thank you for answer.  That works for me.

 
chinaski #:

Hello Lorentzos,

thank you for answer.  That works for me.

anytime


Reason: