Anyone able to give me some help on this To add comments, please log in or register

Hi All,

I think I have a drawing problem with my indicator. Works perfectly on my MT4 but doesnt on other peoples. cant suss it out any tips?

image

Where as on other peoples it does this without the labels:
image

My Code Draws these labels using this code: and the Show Stochastic is fixed to True in the variables so its not user input errors thought it was so locked it and still got the same problem. Thinking it could be by using the WindowFind but i didn’t want to use Window Index in case someone wants to use it with other indicators it will mess it up otherwise

if(Show_StochLabels==true)
     {
      ObjectCreate("stoLABEL", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL","STOCH #1 :   "+STF1+"", 9, "Tahoma Narrow", indicator_color1);
      ObjectSet("stoLABEL", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL", OBJPROP_YDISTANCE, 5);
//----
      ObjectCreate("stoLABEL1", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL1","STOCH #2 :   "+STF2+"", 9, "Tahoma Narrow", indicator_color3);
      ObjectSet("stoLABEL1", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL1", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL1", OBJPROP_YDISTANCE, 20);
//----
      ObjectCreate("stoLABEL2", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL2","STOCH #3 :   "+STF3+"", 9, "Tahoma Narrow", indicator_color5);
      ObjectSet("stoLABEL2", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL2", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL2", OBJPROP_YDISTANCE, 35);
//----
      ObjectCreate("stoLABEL4", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL4","STOCH #4 :   "+STF4+"", 9, "Tahoma Narrow", indicator_color7);
      ObjectSet("stoLABEL4", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL4", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL4", OBJPROP_YDISTANCE, 50);
//----
      ObjectCreate("stoLABEL5", OBJ_LABEL,WindowFind("BigBroking MTF STOCH #1 "), 0, 0);
      ObjectSetText("stoLABEL5","STOCH #5 :   "+STF5+"", 9, "Tahoma Narrow", indicator_color9);
      ObjectSet("stoLABEL5", OBJPROP_CORNER, 0);
      ObjectSet("stoLABEL5", OBJPROP_XDISTANCE, 1165+Shift_Text);
      ObjectSet("stoLABEL5", OBJPROP_YDISTANCE, 65);
     }

You might just need to use ChartSetInteger to set chart objects to show. Here’s a script to toggle it on and off to see if you can replicate the objects not shoeing on the screen.


//+------------------------------------------------------------------+
//|                                   ChartObjDescriptionsON_OFF.mq5 |
//|                                                      nicholishen |
//|                                   www.reddit.com/u/nicholishenFX |
//+------------------------------------------------------------------+
#property copyright "nicholishen"
#property link      "www.reddit.com/u/nicholishenFX"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long value;
   
   ResetLastError(); 
//--- receive the property value 
   if(!ChartGetInteger(ChartID(),CHART_SHOW_OBJECT_DESCR,0,value)) { 
      //--- display the error message in Experts journal 
      Print(__FUNCTION__+", Error Code = ",GetLastError()); 
      return; 
   } else {
      Print("Chart was displaying Objects = ",valueToString(value));
   } 

   value = value == true ? value = false : value = true;

   if(!ChartSetInteger(ChartID(),CHART_SHOW_OBJECT_DESCR,0,value)) { 
      //--- display the error message in Experts journal 
      Print(__FUNCTION__+", Error Code = ",GetLastError()); 
      return; 
   } else {
      Print("Chart is now displaying Objects = ",valueToString(value));
   }
}
//+------------------------------------------------------------------+

string valueToString(const long value){
   if(value == true)return "TRUE";
   else if( value == false)return "FALSE";
   else return "ERROR";
}

Your code is doing something a little different.

CHART_SHOW_OBJECT_DESCR controls whether the description of an object is visible, not the object itself.

It is controlling this:
image

Example:

ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,true); 

image

ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,false); 

image

By the way, you can simplify this:

value = value == true ? value = false : value = true;
 To this:

value = !value;

Check this out

value = !value;